<< Chapter < Page | Chapter >> Page > |
G is a high level, data-flow graphical programming language designed to develop applications that are
The program is a block diagram edited in the Block Diagram programming window.
The program input data and results are manipulated and displayed in the Front Panel window.
The first program is to display the text “Hello graphical interactive parallel multicore world” in the Front Panel window.
Right click on the Block Diagram window and select String Constant from the Functions>>Programming>>String menu.
Drag and drop the String Constant onto the Block Diagram window as show in [link] .
Type in “Hello graphical interactive parallel multicore world.” in the String Constant .
Right click in the Front Panel window and select a String Indicator from the Controls>>Modern>>String&Path menu.
Drop it into the Front Panel window.
Return to the programming window. Notice the string terminal corresponding to the string indicator in the Front Panel window. As you approach the string constant from the right, the wiring terminal is highlighted and the pointer turns to wire spooler.
Click the “Hello graphical interactive parallel multicore world” terminal and then click on the String Indicator triangular terminal to wire the terminals.
Save your program as Hello, World.vi . Return to the Front Panel window. Click the run button (➯). You have successfully completed and executed your first G program.
The next program converts degrees from Fahrenheit to Celsius using the formula
.
In the Block Diagram window, select the subtract, multiply and divide from the Functions>>Mathematics>>Numeric menu
Wire the subtract , multiply and divide functions as shown in [link] .
Right click on the upper left terminal of the subtract function and select Create>>Control from the pop-up menu.
Re-label x as Fahrenheit and wire the terminal as shown in [link] .
Right click on the lower left terminal of the subtract function and select Create>>Constant and type 32.0 .
Repeat the process to generate numeric constants for the multiply and divide function with 5.0 and 9.0 respectively.
To complete the program, right click on the right terminal of the divide function and select Create>>Indicator . Re-label x/y as Celsius . The final diagram is shown in [link] .
Switch to the Front Panel window to run the program. Save the program as Celsius.vi . Try various Fahrenheit values to see the corresponding Celsius values. You have successfully finished a Fahrenheit to Celsius calculator.
Click on empty space and drag to select the entire diagram.
Notification Switch
Would you like to follow the 'Introduction to g programming' conversation and receive update notifications?