12
CHAPTER 3. DESIGN PATTERN FOR MACHINE VISION APPLICATIONS
to maintain the current state, and a case structure to implement the activities
for each state and also to determine the next value of the state register. On each
while-loop iteration the value of the state register is read to select a particular
subdiagram of the case structure, therefore, each subdiagram embodies a single
state. Each subdiagram calculates the next value of the state register which is
then fed back via the while-loop’s shift register to become the next value of the
state register. Refer to
for a more complete discussion
of the LabVIEW implementation of a classic state machine.
3.2
Queued State Machine
The “Queued State Machine” (QSM) is a more sophisticated approach that
decouples a state’s activity from the mechanism to determine the next state.
This decoupling makes the QSM much easier to develop and maintain because
it promotes a “divide and conquer” approach to breaking up the application
design into manageable and well-defined activities. Each state can be developed
and debugged independently of all the other states.
But how is the next state determined? A special state called the
scheduler
takes care of this. The scheduler examines image analysis results, front-panel
buttons, and external sensors to determine which
task
— an ordered sequence of
states — should be performed next. The scheduler applies this ordered sequence
of states comprising a task to the input of a
queue
, also known as a FIFO (first-in,
first-out) memory structure. Once
enqueued
the states are now ready to be read
out one at a time, i.e.,
dequeued
, on each while-loop iteration to select the asso-
ciated case-structure subdiagram activities in the proper sequence. The queue
serves the same role as the state register in the classic state machine. After en-
queueing a single task, the scheduler must finish by enqueueing itself so that that
state machine will return to the scheduler state after completing the current task.
Figure 3.1 on page 19 illustrates the task diagram for a generic QSM intended
for machine vision applications that target NI myRIO. Each box corresponds to a
state, and a bundle of states indicates a task. The QSM executes the start-up task
and then schedules tasks according to conditions determined by analysis results,
front-panel buttons, and external controls and sensors. The scheduler typically
selects the default task when all other task conditions evaluate to “false.” The
default task retrieves an image from the webcam, analyzes the image, adds a
nondestructive overlay, and reads and writes NI myRIO on-board and external
devices. When the front-panel
Stop
button is pressed or an error condition is
detected the scheduler selects the shutdown task to halt the application.
(6:53)
Содержание NI myRIO
Страница 1: ...Ed Doering NI myRIO Vision Essentials Guide...
Страница 2: ......
Страница 11: ...Part I Machine Vision Fundamentals...
Страница 12: ......
Страница 31: ...Part II Introductory Machine Vision Projects...
Страница 32: ......
Страница 38: ...32 CHAPTER 4 CAMERA SETUP...
Страница 44: ...38 CHAPTER 5 STEREO VISION...
Страница 61: ...Part III Machine Vision Application Projects...
Страница 62: ......
Страница 72: ...66 CHAPTER 8 COIN COUNTER...
Страница 85: ...CHAPTER 10 KEYED OPTICAL LOCK 79 Figure 10 3 Typical expected results for the Geometric Matching step...
Страница 86: ...80 CHAPTER 10 KEYED OPTICAL LOCK...
Страница 92: ...86 CHAPTER 11 DMM TEST STAND...
Страница 134: ...128 CHAPTER 17 MARBLE SORTER...
Страница 135: ...Part IV Appendices...
Страница 136: ......
Страница 143: ...B MXPandMSPConnectorDiagrams Figure B 1 MXP myRIO eXpansion Port connector diagram...
Страница 144: ...138 APPENDIX B MXP AND MSP CONNECTOR DIAGRAMS Figure B 2 MSP miniSystem Port connector diagram...
Страница 148: ...142 APPENDIX D BUILD A STAND ALONE APPLICATION...
Страница 149: ...E MarbleSorterConstructionDetails To be continued...
Страница 150: ...144 APPENDIX E MARBLE SORTER CONSTRUCTION DETAILS...