LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how do you create array of enums for transitions in a state machine?

Solved!
Go to solution

@dav2010 wrote:

What is the indicator you have in the lower left corner labelled "Current State"?  Where is this icon found on the pallette?  I cannot reproduce this one.  Also, what data type is coming out of the shift register?  Is the state label a text string?  I can't get a string indicator to work to display the state from the shift register.

Thanks,

Dave


It is an enum indicator.  Just right click on the wire and pick Create Indicator.  Enum is the datatype.

 

A state machine implies an architecture where you are in a certain state, and you may go to one or more different states as a function of different conditions and where you are now.  What you are describing sounds like it doesn't matter where you are now, it is strictly based on a set of conditions.  In that case, you just need to set up your decisions at the beginning of the while loop and have that drive a case structure.  You won't need to have the shift register which is a key feature that makes a state machine a state machine.

 

If you have 2 inputs (A, B) and 3 conditions for each (Low, High, OK) you have have 3x3 decision tree like you said.  Create a 2-D array of 3 rows and 3 columns.  Populate it with enums.  Have the A condition index out a row, and a B condition index out a column.  The resulting enum will determine which case of the case structure to run.

0 Kudos
Message 21 of 23
(666 Views)

Thanks RAvens fan, I will try what you suggested.  It sounds easier than the state machine.  I'm sure I'll have more questions once I get into it a bit.  Thanks for your help. 

 

Actually, I can reduce the matrix to a 1-d matrix of 9 elements instead of a 2-d matrix of 3x3 elements. Would you expect the 1-d to be a better approach than the 2-d, or are they the same in your mind?

 

Dave

0 Kudos
Message 22 of 23
(654 Views)
Solution
Accepted by topic author dav2010

I think 2-D is better.  Since you have 2 different inputs with 3 possible cases, that sounds exactly like a lookup table to me.  Read the value of one input across and the other input down.  You've got a value that tells you which case of a case structure to execute.

Message 23 of 23
(634 Views)