0% found this document useful (0 votes)
76 views15 pages

EEN-625 Virtual Instrumentation: Dr. P. Sumathi Associate Professor Department of Electrical Engineering IIT Roorkee

The document discusses state machines in LabVIEW. It explains that state machines revolve around states, events, and actions. States describe the status of programming and can change over time. Events are occurrences that have meaning, and actions are responses to events. A state machine is like a case structure inside a while loop. The document also discusses variables, loops, structures like sequences and cases, and functions in LabVIEW like the formula node. It provides an example of Barnsley's fern, which is a fractal created mathematically. Finally, it discusses digital filters in LabVIEW.

Uploaded by

Arpan Gayen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views15 pages

EEN-625 Virtual Instrumentation: Dr. P. Sumathi Associate Professor Department of Electrical Engineering IIT Roorkee

The document discusses state machines in LabVIEW. It explains that state machines revolve around states, events, and actions. States describe the status of programming and can change over time. Events are occurrences that have meaning, and actions are responses to events. A state machine is like a case structure inside a while loop. The document also discusses variables, loops, structures like sequences and cases, and functions in LabVIEW like the formula node. It provides an example of Barnsley's fern, which is a fractal created mathematically. Finally, it discusses digital filters in LabVIEW.

Uploaded by

Arpan Gayen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

INDIAN INSTITUTE OF TECHNOLOGY ROORKEE

EEN-625
Virtual Instrumentation

Dr. P. Sumathi
Associate Professor
Department of Electrical Engineering
IIT Roorkee
Synchronization

2
State machines in LabVIEW

State machines revolve around three concepts:


the state, the event, and the action.

States describe the status of a piece of programming and are subject to change
over time.

states are “waiting for command,” “processing command,” and “generating report.”
The “waiting for command” state indicates that the application is idle until the
remote control issues a command to take action.

Events are occurrences in time that have significant meaning to the piece of code
controlled by the state machine.

Events that may occur when the code is executing are “command received,” “abort
received,” “error occurred,” and “status requested.”

Actions are responses to events, which may or may not impact external code to the
state machine.
The state machine determines which actions need to be taken when a given event
occurs.
3
A state machine, in simple terms, is a case structure inside a While loop.

The enumerated type control is basically a list of text values associated with a
numeric value.

4
Formula block

Matrix operations

Solving linear simultaneous equations

The Formula Node in the LabVIEW software: C++ syntax structure

The MathScript Node implements similar functions but with the additional
functionality of a full .m file compiler .

5
Variables

Local variables: passing data from one location to another in a single VI

Global variables: pass data between two VIs or VI and sub VI .

Correct variable execution

1. Read the value of the variable


2. Change the value read
3. Write the changed value to the variable

6
1. Loop 1 reads the variable
2. Loop 2 reads the variable
3. Loop 1 changes the value it read
4. Loop 2 changes the value it read
5. Loop 1 writes result to the variable
6. Loop 2 writes result to the variable

Race condition

Each loop expecting the last value it wrote


Loop 1 output never read
Loop 2 overwrites output of Loop 1
Race conditions when programming with variables

7
More on structures

For loop
While loop
Case structure

Sequence structure—Contains one or more subdiagrams that execute in sequential order.


● Event structure—Contains one or more subdiagrams that execute depending on how the
user interacts with the VI.
● Timed Structures—Execute one or more subdiagrams with time bounds and delays.
● Diagram Disable Structure—Has one or more subdiagrams, or cases, of which only the
enabled subdiagram executes.
● Conditional Disable Structure—Has one or more subdiagrams, or cases, exactly one of
which LabVIEW uses for the duration of execution, depending on the configuration

8
The Flat Sequence structure, shown as follows, displays all the frames at once and
executes the frames from left to right and when all data values wired to a frame are
available, until the last frame executes. The data values leave each frame as the frame
finishes executing.
Use the Flat Sequence structure to avoid using sequence locals and to better document
the block diagram. When you add or delete frames in a Flat Sequence structure, the
structure resizes automatically.

9
The Stacked Sequence structure, shown as follows, stacks each frame so you see
only one frame at a time and executes frame 0, then frame 1, and so on until the
last frame executes.

The Stacked Sequence structure returns data only after the last frame executes.

Invoke node : reinitialize to default value

Property node : set the properties of a node (visible, disable etc)

10
Barnsley’s Fern “fractals everywhere”

A fractal is an image created mathematically that has a high degree of repetition, or


self-similarity
11
x = an x + bny
y =cnx + dny + fn

Where an,bn,cn,dn and fn are fixed numbers and n is index from 1 to 4

Barnsley, M. Fractals Everywhere, 2nd ed., Boston, MA, Academic Press, 1993, pp. 86,
90, 102 and Plate 2,193.
As reported by Weisstein, Eric W., “Barnsley’s Fern.” From MathWorld—A Wolfram
Web Resource,
http://mathworld.wolfram.com/BarnsleysFern.html, accessed October 15, 2009.

12
Digital Filters

An exponential filter uses the current signal value and the previous signal
value to reduce signal noise.
The equation is
xfiltered = (1 – a) xprevious + a xcurrent

a is the filter coefficient, which is reduced to increase the extent of filtering.

13
Moving average filter

Exponentially weighted running average filter

Feedback node as delay element

Reading from spreadsheet

LUT

14
15

You might also like