<< Chapter < Page Chapter >> Page >
Block Diagram of a Signal Generation System
Front Panel of a Signal Generation System

Building a periodic signal generation system using hybrid programming

In this section, build a simple periodic signal generation system in hybrid mode to set the stage for the chapters that follow. This system involves generating a periodic signal in textual mode and displaying it in graphical mode. Modify the shape of the signal (sine, square, triangle or sawtooth) as well as its frequency and amplitude by using appropriate front panel controls. The block diagram and front panel of this system using a LabVIEW MathScript node are shown in [link] and [link] , respectively. The front panel includes the following three controls:

Waveform type – Select the shape of the input waveform as either sine, square, triangular or sawtooth waves.

Amplitude – Control the amplitude of the input waveform.

Frequency – Control the frequency of the input waveform.

Periodic Signal Generation System Block Diagram
Periodic Signal Generation System Front Panel

To build the block diagram, first write a .m file code to generate four types of waveforms using the .m file functions sin , square and sawtooth . To change the amplitude and frequency of the waveforms, use two controls named Amplitude (A) and Frequency (f). Waveform Type (w) is another input controlled by the Enum Control for selecting the waveform type. With this control, one can select from multiple inputs. Create an Enum Control from the front panel by invoking Controls Modern Ring&Enum Enum . Right-click on the Enum Control to select properties and the edit item tab to choose different items as shown in [link] . After inserting each item, the digital display shows the corresponding number value for that item, which is the output of the Enum Control .

Finally, display the waveforms with a Waveform Graph (Controls Express Waveform Graph) and a Build Waveform function (Function Programming Waveform Build Waveform) .

Enum Control Properties

Lab exercises

Write a .m file code to add all the numbers corresponding to the even indices of an array. For instance, if the array x is specified as x = [1, 3, 5, 10], then 13 (= 3+10) should be returned. Use the program to find the sum of all even integers from 1 to 1000. Run your code using the LabVIEW MathScript interactive window. Also, redo the code where x is the input vector and y is the sum of all the numbers corresponding to the even indices of x.

Insert Solution Text Here

2. Explain what the following .m file does:

L=length(x);

for j=1:L

if x(j)<0

x(j)=-x(j);

end

end

Rewrite this program without using a for loop.

Insert Solution Text Here

3. Write a .m file code that implements the following hard-limiting function:

x ( t ) = { 0 . 2 t 0 . 2 0 . 2 t < 0 . 2 size 12{x \( t \) = left lbrace matrix { 0 "." 2 {} # t>= 0 "." 2 {} ## - 0 "." 2 {} # t<0 "." 2{} } right none } {}

For t size 12{t} {} , use 1000 random numbers generated via the function rand.

Insert Solution Text Here

4. Build a hybrid VI to generate two sinusoid signals with the frequencies f1 Hz and f2 Hz and the amplitudes A1 and A2, based on a sampling frequency of 8000 Hz with the number of samples being 256. Set the frequency ranges from 100 to 400 Hz and set the amplitude ranges from 20 to 200. Generate a third signal with the frequency f3 = (mod (lcm (f1, f2), 400) + 100) Hz, where mod and lcm denote the modulus and least common multiple operation, respectively, and the amplitude A3 is the sum of the amplitudes A1 and A2. Use the same sampling frequency and number of samples as specified for the first two signals. Display all the signals using the legend on the same waveform graph and label them accordingly.

Insert Solution Text Here

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, An interactive approach to signals and systems laboratory. OpenStax CNX. Sep 06, 2012 Download for free at http://cnx.org/content/col10667/1.14
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'An interactive approach to signals and systems laboratory' conversation and receive update notifications?

Ask