You are on page 1of 4

Case Structure and Formula Node

Lesson 6 on Case Structure Pages 6-3 to 6-4


A case structure has two or more sub-diagrams or cases. Only
one sub-diagram is visible at a time, and the structure executes only
one case at a time. An input value via a control determines which
sub-diagram executes. The structure is similar to if then else
statement in text- based programming languages.
Build the three programs that appear on pages 6-3 and 6-4:
a)

Addition or subtraction with a True or False Boolean input.

b)

Addition or subtraction with an Integer input; for example,


the number 0 (zero) performs addition and the number 1
(one) performs subtraction.

c)

Addition or subtraction with a String input. For example,


the string word add written in the input control window of
the front panel will perform addition; and the string word
subtract written in the input window of the front panel will
perform subtraction.

A comment: The string case structure must have the two words add
and subtract written into the top small window on the upper border
of each structure. See the block diagram on the next page. The
quotation symbols and indicate a string; and the alpha-numeric
characters that appear in your string expression will be converted to
ASCII coded characters. Note also the comma symbol , must appears
after the string add followed by the word Default. For example, the
word add or any other string expression except for the word subtract
will chose the addition case and perform the addition. Only the entry
of the string expression subtract will perform the subtraction.

Block Diagram and Front Panel of Several Case Structures


Case (Boolean,integer,string).vi
Connector Pane

Front Panel

Block Diagram

Formula Node
Exercise 6-4: Pages 6-12 to 6-14
Use the Formula Node to perform mathematical operations on the
block diagram. You can copy and paste the existing text-based code into
a Formula Node rather than recreating it graphically on the block
diagram. Formula Nodes are useful for equations that have many
variables or are complicated and for using existing text-based codes.
Build Exercise 6-4 on pages 6-13 and 6-14 and run the program
displaying the expression y = [f(x)]3 + f(x) where
f(x) = tanh(x) x cos(x).
Some comments: Each mathematical expression must end with a
semi-colon symbol; or your program wont work. If you use an
intermediate variable such as in this example
a = tanh(x) + cos(x), then you must add an output tunnel junction of
the right hand border of the frame for each intermediate variable.
You do not need to connect any wires to this tunnel junction! Each
trigonometric function has its argument enclosed by parenthesis
symbols ( and ); square brackets [ and ] and curly brackets { and }
wont work. The arguments for the trigonometric functions must be in
units of RADIANS and NOT degrees! Remember 1 Radian 57.3
degrees. Note that the symbol ** refers to a number raised to some
power; most programs use the symbol ^.
Write and run the program shown on page, 4.

Formula (node).vi
Connector Pane

Front Panel

Block Diagram

You might also like