Saturday, September 25, 2010

Interactive Programming

Summary: The creation of this content was supported in some part by NSF grant 0538934.
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 1: Creating Interactive Programs
A small diagram containing a small blue box containing an 'i' in the lower left hand corner and a red button icon on the lower right corner. In the middle of the diagram is a small box containing the phrase 'Interactive G Program'.
In the Front Panel window, from the Functions >> Modern >> Numeric select the vertical pointer slide. From the Functions >> Modern >> Graph select Waveform Chart.
Figure 2: Vertical Pointer Slide and Waveform Chart
A diagram of a 'Vertical Pointer Slide and Waveform Chart'. There are two directory levels identified above two rows of three icons. The upper level is labeled  'Modern' and the level directly underneath that is labeled 'Numeric'. below 'Numeric' is a listing two rows of three icons.
Figure 3: Vertical Pointer Slide and Waveform Chart
A diagram of a 'Vertical Pointer Slide and Waveform Chart'. There are two directory levels identified above two rows of three icons. The upper level is labeled  'Modern' and the level directly underneath that is labeled 'Graph'. Below 'Graph' is a listing two rows of three icons.
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 4: Slide & Waveform Chart in Front Panel window
An empty graph.
Right click on Sine Wave and select Properties from the pop-up menu.
Figure 5: Selecting Chart Properties
An empty graph with a menu on top of it. The item 'Properties' is highlighted.
Select the Scales tab and change Maximum to 1023. Sine Wave will display 1024 samples.
Figure 6: X-Axis Maximum
A screencap of a window with many tabs along the top of the window. The fourth tab 'scales' is selected. Then on this tab there are many fields with the lower right field surrounded by a red box and containing the number 1023 . This field is labeled Maximum.
Click on the down arrow located to the right of Time (X-Axis) and select Amplitude (Y-Axis).
Figure 7: Selecting Y-Axis
A screencap of a window with many tabs along the top of the window. The fourth tab 'scales' is selected and a drop down menu is selected with the menu item 'Time (X-Axis)' has a check mark next to it. The menu item 'Amplitude (Y-Axis)' is highlighted in blue.
De-select Autoscale and change the Minimum and Maximum values to -10 and 10. Click OK.
Figure 8: De-Selecting Autoscale
A screencap of a window with many tabs along the top of the window. The fourth tab 'scales' is selected. In the lower right of the tab is a red box surround a radio box labeled 'Autoscale' and two fields one labeled 'Minimum' containing the value '-10' and the other field is labeled 'Maximum' containing the value '10'.
Rearrange Amplitude and Sine Wave terminals and finish the program as shown in Figure 9.
Scroll the mouse pointer over the Loop Control
Figure 9: Interactive Sine Wave Diagram
A screen cap of a diagram of an 'Interactive Sine Wave Diagram'. The diagram consists of several icons. From left to right the there is a orange box containing '0.02' and below that a blue box containing 'i'. Lines connect these boxes to a triangular box containing 'x. A line connects this to a wave icon which is connected to another triangular box containing 'x'. A line connects this triange to an icon labeled 'Sine Wave'. Below this row of icons there is an icon labeled 'Amplitude' that is connected to the second triangle. A red button icon is located in the bottom right corner.
Figure 10: Loop Condition
A screen cap of a diagram of an 'Interactive Sine Wave Diagram'. The diagram consists of several icons. From left to right the there is a orange box containing '0.02' and below that a blue box containing 'i'. Lines connect these boxes to a triangular box containing 'x. A line connects this to a wave icon which is connected to another triangular box containing 'x'. A line connects this triange to an icon labeled 'Sine Wave'. Below this row of icons there is an icon labeled 'Amplitude' that is connected to the second triangle. A red button icon is located in the bottom right corner. This button icon has a mouse arrow over it and below the mouse is box containing 'Loop Condition'.
And right click on the Loop Control and from the pop-up menu select Create Control.
stop terminal is created.
Figure 11
A screen cap of a diagram of an 'Interactive Sine Wave Diagram'. The diagram consists of several icons. From left to right the there is a orange box containing '0.02' and below that a blue box containing 'i'. Lines connect these boxes to a triangular box containing 'x. A line connects this to a wave icon which is connected to another triangular box containing 'x'. A line connects this triange to an icon labeled 'Sine Wave'. Below this row of icons there is an icon labeled 'Amplitude' that is connected to the second triangle. A red button icon is located in the bottom right corner. Over this button there is a menu with the menu item 'Create Control' highlighted in blue.
Figure 12: Interactive G Program
A screen cap of a diagram of an 'Interactive Sine Wave Diagram'. The diagram consists of several icons. From left to right the there is a orange box containing '0.02' and below that a blue box containing 'i'. Lines connect these boxes to a triangular box containing 'x. A line connects this to a wave icon which is connected to another triangular box containing 'x'. A line connects this triange to an icon labeled 'Sine Wave'. Below this row of icons there is an icon labeled 'Amplitude' that is connected to the second triangle. A red button icon is located in the bottom right corner. To the left of this button is a 'stop' icon connected to it via a line.
With the corresponding stop Boolean input control. Save the G program as Interactivity.vi.
Figure 13: Interactive Program
An empty graph.
Run the G program.
Figure 14: Interactive Program
A graph with an straight line running along y=0.
While the program is running, change the Amplitude and watch the graph update to reflect the interactive changes.
Figure 15: Interactive Program
A graph with a sine wave with an amplitude of 6.93878
To end the G program, simply click on the stop button.
Figure 16: Interactive Program
A graph with a sine wave with an amplitude of 6.93878. The stop button to the left of the wave is highlighted Red.
Congratulations. You have successfully completed and executed your first interactive G program.

Content actions

GIVE FEEDBACK:

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

Popular Projects

My Blog List

Give support

Give support
Encourage Me through Comments & Followers

Followers