Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
67 views

Lesson 10 - Using Sequential and State-Based Designs

The document discusses using sequential and state-based programming in LabVIEW. It covers using sequential programming with flow-through parameters, sequence structures, and error case structures. State programming is also covered using state transition diagrams to change the order or repetition of sequences based on conditions. State machines are described as useful for sequential or UI-driven processes. The document provides an example of a weather station project using a state machine design pattern.

Uploaded by

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

Lesson 10 - Using Sequential and State-Based Designs

The document discusses using sequential and state-based programming in LabVIEW. It covers using sequential programming with flow-through parameters, sequence structures, and error case structures. State programming is also covered using state transition diagrams to change the order or repetition of sequences based on conditions. State machines are described as useful for sequential or UI-driven processes. The document provides an example of a weather station project using a state machine design pattern.

Uploaded by

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

Lesson 10

Using Sequential and State Machine


Programming
Recognize the benefits of sequential and state-based algorithms and apply
techniques in LabVIEW to enforce sequential or state execution.

A. Using Sequential Programming


B. Using State Programming
C. State Machines

1
LESSON 10 Using Sequential and State-Based Designs

A. Using Sequential
Programming
Use dataflow to ensure sequential execution of nodes.

• Why Use Sequential Programming?


• Flow-Through Parameters
• Sequence Structures
• Error Case Structures

2
A. Using Sequential Programming

Why Use Sequential Programming?

3
A. Using Sequential Programming

Flow-Through Parameters

4
A. Using Sequential Programming

Sequence Structures
Sequence structures are a structure with frames, where
each frame executes in order.

5
A. Using Sequential Programming

Avoid Overuse of Sequence Structures


Cannot stop the execution in the middle of a sequence.

6
A. Using Sequential Programming

Error Case Structures

7
LESSON 10 Using Sequential and State-Based Designs

B. Using State
Programming
Describe the functionality represented by a state transition
diagram.

• Why Use State Programming?


• State Transition Diagrams

8
B. Using State Programming

Why Use State Programming?


• Change the order of a sequence
• Repeat an item in sequence more often than others
• Execute only if certain conditions are met
• Stop the program immediately

9
B. Using State Programming

State Transition Diagram

State—Part of a program that satisfies a


condition, performs an action, or waits for
an event

Transition—Condition, action, or event that


causes the program to move to the next
state

10
B. Using State Programming

State Transition Diagram

11
LESSON 10 Using Sequential and State-Based Designs

C. State Machines
Determine when to use a state machine.

• What is a State Machine?


• When to Use a State Machine?
• Building a State Machine
• Event-Based State Machine
• Simple State Machine Project Template

12
C. State Machines

What is a State Machine?

13
C. State Machines

When to Use a State Machine


Sequential Process UI-Driven Process

14
LESSON 10 Using Sequential and State-Based Designs

Multimedia Module
Building State Machines

• State Machine Infrastructure


• State Machine Transitions
• Building State Machines

15
C. State Machines

Course Project Transition Diagram


LESSON 10 Using Sequential and State-Based Designs

Exercise 10-1
Weather Station Project

Create a Weather Station application using a state machine design pattern.


Practice skills learned throughout this course.
LESSON 10 Using Sequential and State-Based Designs

Exercise 10-1
Weather Station Project

How would you change the diagram to add an Initialize and Shutdown state?
C. State Machines

Event-Based State Machine


LESSON 10 Using Sequential and State-Based Designs

Demonstration
Simple State Machine Project Template
Use the Create Project dialog box to expedite implementing an
event-based state machine application.

20
LESSON 10 Using Sequential and State-Based Designs

Activity 10-1
Lesson Review

Refer to the participant guide to answer questions about what you have learned in
this lesson and then discuss the answers as a group.

21
Lesson Review

1. When using a Sequence structure, you


can stop the execution in the middle of a
sequence.
a. True
b. False

22
Lesson Review

1. When using a Sequence structure, you


can stop the execution in the middle of a
sequence.
a. True
b. False

You cannot stop the execution in the middle of a


sequence.

23
Lesson Review

2. Which of the following are benefits of


using a state machine instead of a
sequential structure?
a. You can change the order of the sequence.
b. You can repeat individual items in the sequence.
c. You can set conditions to determine when an
item in the sequence should execute.
d. You can stop the program at any point in the
sequence.

24
Lesson Review

2. Which of the following are benefits of


using a state machine instead of a
sequential structure?
a. You can change the order of the sequence.
b. You can repeat individual items in the
sequence.
c. You can set conditions to determine when an
item in the sequence should execute.
d. You can stop the program at any point in the
sequence.
25

You might also like