You are here

Interactivity

26 July, 2019 - 09:47
Available under Creative Commons-ShareAlike 4.0 International License. Download for free at http://cnx.org/contents/5b6e61df-b830-48cb-9764-94696cb47c80@1.3

This G program shows how G allows programmers to develop interactive programs. Create the following G program and wire it as shown in the figure below.

media/image78.png
Figure 1.77 Creating Interactive Programs 

In the Front Panel window, from the Functions » Modern » Numeric select the vertical pointer slide. From the Functions » Modern » Graph select Waveform Chart.

media/image79.png
Figure 1.78 Vertical Pointer Slide and Waveform Chart  

Re-label the vertical pointer slide as Amplitude and the waveform chart as Sine Wave. Re-arrange to GUI to look like the figure below.

media/image80.png
Figure 1.79 Slide & Waveform Chart in Front Panel window  

Right click on Sine Wave and selectProperties from the pop-up menu.

media/image81.png
Figure 1.80 Selecting Chart Properties 

Select the Scales tab and change Maximum to 1023. Sine Wave will display 1024 samples. Click on the down arrow located to the right of Time (XAxis) and select Amplitude (YAxis).

media/image82.png
Figure 1.81 X-Axis Maximum 
media/image83.png
Figure 1.82 Selecting Y-Axis 

De-select Autoscale and change the Minimum and Maximum values to -10 and 10. Click OK.

De-Selecting Autoscale

media/image84.png

In the Block Diagram window, re-arrange the Amplitude and Sine Wave terminals and finish the program as shown in Interactive Sine Wave Diagram.

media/image85.png
Figure 1.83 Interactive Sine Wave Diagram 

Scroll the mouse pointer over the Loop Control...

media/image86.png
Figure 1.84 Loop Condition 

And right click on theLoop Control and from the pop-up menu selectCreate Control. A stop terminal is created...

media/image87.png
Figure 1.85 Create Loop Control 
media/image88.png
Figure 1.86 Interactive G Program 

With the correspondingstop Boolean input control. Save the G program as Interactivity.vi.

media/image89.png
Figure 1.87 Interactive Program  

Run the G program.

media/image90.png
Figure 1.88 Interactive Program 

While the program is running, change the Amplitude and watch the graph update to refect the interactive changes.

media/image91.png
Figure 1.89 Interactive Program 

To end the G program, simply click on the stop button. Congratulations. You have successfully completed and executed your first interactive G program.

media/image92.png
Figure 1.90 Interactive Program