LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

well-oiled typical state machine

 https://decibel.ni.com/content/community/zone


The community zone is probably the most likely place for this collection state machines I'm looking for. However, it doesn't have a searchable format for architecture type. 

 

If there was a tag or descriptor for the author to post the architecture type, then someone could search for state machine examples, producer consumer examples, or any other architecture.

 

 

This small addition could be a great benefit for many people wanting examples of a class. 

 

There are three state machine examples that I could find in the Community Zone. They are on the simple side of the spectrum. 

I'm sure out of the 6,000+ examples on the site, there are more complex state machines. However, I can't find a way to sort them by architecture. 

 

 

 

 

0 Kudos
Message 11 of 19
(1,330 Views)

With absolutely no intention of being facetious, I think you'd be better served doing than asking.  I believe you now have all the tools necessary to get started.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 12 of 19
(1,316 Views)

@Carmen92126 wrote:

 

If there was a tag or descriptor for the author to post the architecture type, then someone could search for state machine examples, producer consumer examples, or any other architecture.

 

 

This small addition could be a great benefit for many people wanting examples of a class. 

 


Look at the bottom of any of the posts on the forum.  There is a place to add tags.  Now if we could just force people somehow to add tags to their posts....

 

|

|

\/

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 13 of 19
(1,298 Views)

Well made is pretty objective but here is something I made for a coworker to show how to solve a few problems he was having.

 

In general this demonstrates data logging from an instrument (but has no actual instrument communications) and saving data in a file for a long term test.

A new data file is generated every day with a unique file name.

A proper Excel OLE time stamp is added to every data scan and save.

File references are used to avoid file sharing violations caused by opening a data file when LabView is still attempting to write to it.

Error handling concept with safe shutdown shown

Use of Enumerated Type Def and decisions to control state machine shown

 

Unzip the files to a new directory and run State Machine Example 3.vi

 

Start with the default state (setup1) and follow through the states

========================
=== Engineer Ambiguously ===
========================
Message 14 of 19
(1,285 Views)

Once you're asking about a moderately-complex state machine, each one will be somewhat unique, and will probably contain so much more task-specific logic than architecture that it would be difficult to use as an example (assuming one was even allowed to post it, as such logic might be considered company proprietary information).

 

For example, I worked on a system for dispensing, packaging, and labeling chemicals. There's one master state machine, and inside of that, one state machine for each individual station (the vial labeler, the dispenser, the capper, etc). The architecture for the state machines is simple: each one is an enumeration, a case structure, and a shift register, plus a cluster of data also stored in a shift register.

 

The actual logic, however, is complex: after each of the inner state machines completes, the master state machine moves to the next state, where it rotates each vial to the next station, transfers all the vial information to the next station, resets each individual station, then triggers them all to run again. There's some logging, too - each vial that is processed is logged. There's also error handling, for example if there are no caps at the capper station, it prompts the user to clear the jam or reload more caps. So it does most of the things about which you're asking, but nearly all the code is the logic that actual drives the motors, actuators, and sensors. I doubt that sharing the code would be helpful or meaningful since the amount of code that implements the state machine is overwhelmed by the amount of code that handles the operating logic (which would be difficult to follow without seeing the real machine in action). You definitely couldn't use it as a template.

Message 15 of 19
(1,257 Views)

Thanks RTSLVU. This is the sort of vi I knew was out there, a pre-existing state machine vi. 

 

Thank you for posting this. 

 

Yes, well made is subjective, but if you feel it's well made, then that is good enough for this thread. 

 

 

 

0 Kudos
Message 16 of 19
(1,255 Views)

If you are looking for some code to browse through, you may want to also take a look at some of the sample projects. They are quite extensive and have state machines, messages, multiple loops, etc.

 

SampleProject.PNGps, etc already set up.

Message 17 of 19
(1,220 Views)
Assuming you have gone through the tutorials that were recommended, i just finished a two part series on state machines. Check my signature block for the URL.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 18 of 19
(1,195 Views)

@Carmen92126 wrote:

 

 

Please I'm trying to get a focused reponse. 

 

vi's only. Thank you for your suggestions. I do appreciate your helping thoughts. 

 

Please limit this conversation to posts of vi's and comments about why a particular state machine is a good one. 


In all fairness, you're not in a position to declare what's most relevant as an answer to your question.  If you were, you wouldn't have the question you have.  You asked a generally poor question.  It's was vague.  Most of what you want has nothing to do with what you asked. (File IO isn't a part of a state machine.  Your state machine can do it.  But, it's not a part of the architecture.) 

 

The state machine is really a simple construct.  i'm not going to attach the template VI.  You need to take time to understand that before looking at anything more complex.  It's just a while loop, a shift register, a case structure, and an enum.  The while loop keeps the machine running.  The shift register stores the next state to run.  The enum is a pretty way to list all of your possible states and pass them to the shift register.  The case structure is a collection of states.

 

Give yourself a simple state machine to work with and usee the template.  Build what you want to see.  Get used to the architecture.  But, don't ever demand the form in which you'll recieve an answer to a broad question.

0 Kudos
Message 19 of 19
(1,157 Views)