LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Binary pattern detector using state machine

Greetings All,

I'm trying to learn how to do state machines in LabVIEW. I do NOT have access to the Statechart Module or the State Diagram Toolkit, so I'm trying to do this from "scratch" using the WHILE loop structures, CASE statements, and EVENT structures. I hope that part is right so far. I've been looking at the tutorials (e.g. http://zone.ni.com/devzone/cda/tut/p/id/7595) but there are some things still unclear to me.

Having created a state diagram (attachment follows this post), I do NOT have what they refer to as an INIT state or a DONE/EXIT state. This sequence detector is supposed to detect when the sequence 011 has come through. The machine has one input, x, and one output, z. There are four states. I made this as a Moore machine (per comments from another tutorial).

Has anyone done anything like this before? Is this really the best tutorial for state machines? If you have done EXACTLY this, would you care to share your solution? This is strictly for my learning. Ultimately, I need to create a state (machine) process for a data acquisition system where LV is the Master Controller for initiating data collection, starting/stopping various process (e.g. fault injection), and system resets (i.e. sending out a binary signal to reset external processors). I'm trying to crawl before I run.

Any assistance would be invaluable. Thanks in advance!

Michael

Sequence Detector for Pattern x=011
0 Kudos
Message 1 of 17
(4,650 Views)

There is a template in the default start menu too. 

File -> New... 

Regards, -SS



Message Edited by ShotSimon on 07-16-2008 03:03 PM


0 Kudos
Message 2 of 17
(4,645 Views)
Thanks. I'll give it a look Smiley Happy
0 Kudos
Message 3 of 17
(4,622 Views)
I have a follow-up question that may actually be the "real" first question.

The state machine examples seem to require a FINAL state. Outside of having an external STOP signal (separate from the "x" input), I want this machine to continuously cycle through the states.

For example,

x = 00001011011000011
z = 00000001001000001

but if I implement it like the examples, The machine would stop at the FIRST "011" pattern detected. Can someone explain to me what needs to be done or if I'm misunderstanding this?

Thanks,
Michael
0 Kudos
Message 4 of 17
(4,618 Views)
Dr. Reynolds,
 
I ended up using a for loop with auto indexing to allow binary values into the state machine.  This machine doesn't stop until all the data is processed.
Is this what you are looking for?
 
Regards,
 
-SS


0 Kudos
Message 5 of 17
(4,599 Views)
Hey Simon,

This looks pretty close to what I'm trying to do. Would you be willing to post the code (or email it to me)? I may be able to recreate it with the screenshots you provided or at least modify mine. I think I'm understanding a little more.

As for the Queued Message Handler solution and/or the User Interface Event Handler, I'll have to look into those. I haven't explored those options at all. Is there a good (or better or GREAT) tutorial for those?

Thanks again for all of your assistance!!!!!!!!

Cheers,

Michael
0 Kudos
Message 6 of 17
(4,582 Views)
Dr. Reynolds,
 
Begin by recreating it.  If you get stuck we will help out, you will learn more by doing this.
 
Regards,
 
-SS


0 Kudos
Message 7 of 17
(4,563 Views)
Can you explain a bit more about what you're trying to do? It seems that you're trying to find which element in a list of a string of numbers contains a specific pattern. A state machine may be overkill for this.
0 Kudos
Message 8 of 17
(4,550 Views)
It may be. I chose the pattern detector as a simple example. It takes in a steam of binary data (user input) and outputs a 1 whenever the sequence 011 is detected. It's a basic 4-state machine [start, has 0, has 01, has 011 (or done). That's it.

This is a learning exercise for the more complex master controller project I have. Labview will initiate and terminate various sub-processes. It monitors 6 analog signals and 3 digital signal and performs certain functions based on these signals. I figured a state machine would be the best way to implement this.

Thoughts?

-Michael
0 Kudos
Message 9 of 17
(4,541 Views)
In what form are your sequences entered? As an array of ones and zeros, or as a string? Are they entered one value at a time? Are you going to stick with the state machine, or do you need to consider an alternate solution?
0 Kudos
Message 10 of 17
(4,524 Views)