You are here

Interactive Programming

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

The heart of interactive programming in G is the while loop. Any input control within the while loop can be modified from the Front Panel window at run time to provide seamless interaction with the G program.

media/image1.png
Figure 8.1 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/image2.png
Figure 8.2 Vertical Pointer Slide and Waveform Chart 
media/image3.png
Figure 8.3 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/image4.png
Figure 8.4 Slide & Waveform Chart in Front Panel window 

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

media/image5.png
Figure 8.5 Selecting Chart Properties 

Select the Scales tab and change Maximum to 1023. Sine Wave will display 1024 samples.

media/image6.png
Figure 8.6 X-Axis Maximum  

Click on the down arrow located to the right of Time (XAxis) and select Amplitude (YAxis).

media/image7.png
Figure 8.7 Selecting Y-Axis 

De-selectAutoscale and change the Minimum and Maximum values to-10 and 10. ClickOK.

media/image8.png
Figure 8.8 De-Selecting Autoscale 

Rearrange Amplitude and Sine Wave terminals and finish the program as shown in Figure Figure 8.9. Scroll the mouse pointer over the Loop Control...

media/image9.png
Figure 8.9 Interactive Sine Wave Diagram 
media/image10.png
Figure 8.10 Loop Condition 

And right click on the Loop Control and from the pop-up menu select Create Control. A stop terminal is created.

media/image11.png
Figure 8.11 Create Control 
media/image12.png
Figure 8.12 Interactive G Program 

With the corresponding stop Boolean input control. Save the G program asInteractivity.vi.

media/image13.png
Figure 8.13 Interactive Program  

Run the G program.

media/image14.png
Figure 8.14 Interactive Program 

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

media/image15.png
Figure 8.15 Interactive Program  

To end the G program, simply click on the stop button.

Interactive Program media/image16.png
Figure 8.16

Congratulations. You have successfully completed and executed your first interactive G program.