Skip to content Skip to navigation Skip to collection information

Connexions

You are here: Home » Content » Introduction to G Programming » Interactive Programming

Navigation

Lenses

What is a lens?

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

This content is ...

Affiliated with (What does "Affiliated with" mean?)

This content is either by members of the organizations listed or about topics related to the organizations listed. Click each link to see a list of all content affiliated with the organization.
  • NSF Partnership display tagshide tags

    This collection is included inLens: NSF Partnership in Signal Processing
    By: Sidney Burrus

    Click the "NSF Partnership" link to see all content affiliated with them.

    Click the tag icon tag icon to display tags associated with this content.

  • Featured Content display tagshide tags

    This collection is included inLens: Connexions Featured Content
    By: Connexions

    Click the "Featured Content" link to see all content affiliated with them.

    Click the tag icon tag icon to display tags associated with this content.

Recently Viewed

This feature requires Javascript to be enabled.

Tags

(What is a tag?)

These tags come from the endorsement, affiliation, and other lenses that include this content.
 

Interactive Programming

Module by: Eduardo Perez. E-mail the author

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.

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

Collection Navigation

Content actions

Download:

Collection as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Module as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Add:

Collection to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks

Module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks