<< Chapter < Page Chapter >> Page >
The creation of this content was supported in some part by NSF grant 0538934.

G is a high level, data-flow graphical programming language designed to develop applications that are

  • Interactive
  • Execute in Parallel
  • Multicore

The program is a block diagram edited in the Block Diagram programming window.

A flow chart showing connections and movement between items like graphs, dice, arrows containing a plus-sign, and other objects in a G-block.
G Block Diagram

The program input data and results are manipulated and displayed in the Front Panel window.

A screen capture of the G user interface with a sinusoidal graph plotted on a horizontal axis, labeled time, and a vertical axis, amplitude.
G User Interface

Hello graphical world

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

A screen capture of a window titled functions, with buttons to search and view, a hierarchical list beginning with Programming, then String, and two objects, labeled string constant and empty string.
String Constant

Type in “Hello graphical interactive parallel multicore world.” in the String Constant .

A string constant that reads, Hello graphical interactive parallel multicore world.
"Hello…world" String Constant

Right click in the Front Panel window and select a String Indicator from the Controls>>Modern>>String&Path menu.

A screen capture of a window titled controls, with buttons to search and view, a hierarchical list beginning with Modern, then String and Path, and two objects, labeled string control and string indicator.
Select String Indicator

Drop it into the Front Panel window.

A beveled rectangle inside a gridded box labeled string.
String Indicator

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.

A pink box containing the caption, hello graphical interactive parallel multicore world. To the right of the pink box is another pink box labeled string, containing a shaded grey rectangle containing the letters a, b, c. The boxes are not connected, but an object that resembles a spool of wire is connected to the box on the left.
Wiring the G Diagram

Click the “Hello graphical interactive parallel multicore world” terminal and then click on the String Indicator triangular terminal to wire the terminals.

A pink box containing the caption, hello graphical interactive parallel multicore world. To the right of the pink box is another pink box labeled string, containing a shaded grey rectangle containing the letters a, b, c. The boxes are connected by a zig-zag pink line.
Wired G Block Diagram

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.

A grey grid labeled String containing a grey rectangle with a caption that reads, hello graphical interactive parallel multicore world.
Hello, World G Program Executed

Arithmetic expressions

The next program converts degrees from Fahrenheit to Celsius using the formula

C = 5 9 ( F 32 ) size 12{C= { {5} over {9} } \( F - "32" \) } {} .

In the Block Diagram window, select the subtract, multiply and divide from the Functions>>Mathematics>>Numeric menu

A screen capture of a window containing a hierarchical list, beginning with Mathematics, and below it, numeric. Below the list are four objects, which are yellow triangles containing operators, and they are labeled add, subtract, multiply, and divide.
Numeric Operations

Wire the subtract , multiply and divide functions as shown in [link] .

A diagram connecting three yellow triangles containing operations together. Subtract is connected to Multiply, and multiply is connected to divide.
Subtract, Multiply and Divide

Right click on the upper left terminal of the subtract function and select Create>>Control from the pop-up menu.

A screen capture of the pop-up menu out of the subtract triangle, with the option Create, then Control selected.
Create Control

Re-label x as Fahrenheit and wire the terminal as shown in [link] .

An orange box labeled Fahrenheit, with the orange outside line labeled DBL, and containing the value 1.23, is connected to subtract, which is connected to multiply, which is connected to divide.
Fahrenheit Input Control

Right click on the lower left terminal of the subtract function and select Create>>Constant and type 32.0 .

An orange box labeled Fahrenheit, with the orange outside line labeled DBL, and containing the value 1.23, is connected to subtract, which is connected to multiply, which is connected to divide. Also connected to subtract is an orange box containing the number 32.
Fahrenheit Numeric Constant

Repeat the process to generate numeric constants for the multiply and divide function with 5.0 and 9.0 respectively.

An orange box labeled Fahrenheit, with the orange outside line labeled DBL, and containing the value 1.23, is connected to subtract, which is connected to multiply, which is connected to divide. Also connected to subtract is an orange box containing the number 32. Also connected to multiply is an orange box containing the number 5. Also connected to divide is an orange box containing the number 9.
Fahrenheit Numeric Constants

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

An orange box labeled Fahrenheit, with the orange outside line labeled DBL, and containing the value 1.23, is connected to subtract, which is connected to multiply, which is connected to divide. Also connected to subtract is an orange box containing the number 32. Also connected to multiply is an orange box containing the number 5. Also connected to divide is an orange box containing the number 9. Divide is then connected at the end to an orange box labeled celsius, containing the value 1.23.
Fahrenheit to Celsius G Diagram

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.

A grey grid containing two boxes. The first is labeled Fahrenheit, and contains the value 100, with up-down arrows to the left of it allowing the user to adjust the value. The second is labeled celsius, and contains the value 37.7778.

Functions

Click on empty space and drag to select the entire diagram.

An orange box labeled Fahrenheit, with the orange outside line labeled DBL, and containing the value 1.23, is connected to subtract, which is connected to multiply, which is connected to divide. Also connected to subtract is an orange box containing the number 32. Also connected to multiply is an orange box containing the number 5. Also connected to divide is an orange box containing the number 9. Divide is then connected at the end to an orange box labeled celsius, containing the value 1.23. The entire diagram has a dashed box around it.
Select G Block Diagram

Questions & Answers

what is defense mechanism
Chinaza Reply
what is defense mechanisms
Chinaza
I'm interested in biological psychology and cognitive psychology
Tanya Reply
what does preconceived mean
sammie Reply
physiological Psychology
Nwosu Reply
How can I develope my cognitive domain
Amanyire Reply
why is communication effective
Dakolo Reply
Communication is effective because it allows individuals to share ideas, thoughts, and information with others.
effective communication can lead to improved outcomes in various settings, including personal relationships, business environments, and educational settings. By communicating effectively, individuals can negotiate effectively, solve problems collaboratively, and work towards common goals.
it starts up serve and return practice/assessments.it helps find voice talking therapy also assessments through relaxed conversation.
miss
Every time someone flushes a toilet in the apartment building, the person begins to jumb back automatically after hearing the flush, before the water temperature changes. Identify the types of learning, if it is classical conditioning identify the NS, UCS, CS and CR. If it is operant conditioning, identify the type of consequence positive reinforcement, negative reinforcement or punishment
Wekolamo Reply
please i need answer
Wekolamo
because it helps many people around the world to understand how to interact with other people and understand them well, for example at work (job).
Manix Reply
Agreed 👍 There are many parts of our brains and behaviors, we really need to get to know. Blessings for everyone and happy Sunday!
ARC
A child is a member of community not society elucidate ?
JESSY Reply
Isn't practices worldwide, be it psychology, be it science. isn't much just a false belief of control over something the mind cannot truly comprehend?
Simon Reply
compare and contrast skinner's perspective on personality development on freud
namakula Reply
Skinner skipped the whole unconscious phenomenon and rather emphasized on classical conditioning
war
explain how nature and nurture affect the development and later the productivity of an individual.
Amesalu Reply
nature is an hereditary factor while nurture is an environmental factor which constitute an individual personality. so if an individual's parent has a deviant behavior and was also brought up in an deviant environment, observation of the behavior and the inborn trait we make the individual deviant.
Samuel
I am taking this course because I am hoping that I could somehow learn more about my chosen field of interest and due to the fact that being a PsyD really ignites my passion as an individual the more I hope to learn about developing and literally explore the complexity of my critical thinking skills
Zyryn Reply
good👍
Jonathan
and having a good philosophy of the world is like a sandwich and a peanut butter 👍
Jonathan
generally amnesi how long yrs memory loss
Kelu Reply
interpersonal relationships
Abdulfatai Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Introduction to g programming. OpenStax CNX. Mar 15, 2010 Download for free at http://cnx.org/content/col11192/1.1
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Introduction to g programming' conversation and receive update notifications?

Ask