You are here

Interactive Programming

26 July, 2019 - 09:47
Available under Creative Commons-ShareAlike 4.0 International License. Download for free at

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.

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.

Figure 8.2 Vertical Pointer Slide and Waveform Chart 
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.

Figure 8.4 Slide & Waveform Chart in Front Panel window 

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

Figure 8.5 Selecting Chart Properties 

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

Figure 8.6 X-Axis Maximum  

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

Figure 8.7 Selecting Y-Axis 

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

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...

Figure 8.9 Interactive Sine Wave Diagram 
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.

Figure 8.11 Create Control 
Figure 8.12 Interactive G Program 

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

Figure 8.13 Interactive Program  

Run the G program.

Figure 8.14 Interactive Program 

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

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.