From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

well-oiled typical state machine

In my new-to-LV adventures I feel like I'm spinning my wheels to revinvent the wheel.

My project has modest complexity and it was advised to be a state machine architecture.

 

Can you post an example of a well-made state machine that of low to medium complexity?

I think If I could study several good examples, I could answer most of my questions. 

 

Please post if you would like to share. 

 

0 Kudos
Message 1 of 19
(3,378 Views)

Hi Carmen,

 

create a new VI by selecting "Create project" from GettingStartedWindow. Then a dialog with several options will open - one of them is a simple statemachine!

(Atleast when you use LV2014…)

 

It's all described in the LabVIEW help!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 19
(3,372 Views)

I would also recommend reading Effective LabVIEW Programming.  There are some really good concepts in ther for state machines.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 19
(3,363 Views)

My issue is going beyond the empty stock.

 

I hope to see some examples where people have dealt with some issues like:

getting data or tasks into an out of a shift register. 

enabling and disabling loops of the state machine

decision making in the state machine

time stamp

file saving/opening

+ many other issues

 

So if you have a good state machine, I'd love to see it. 

Thanks. 

 

 

 

 

 

 

 

 

 

 

 

0 Kudos
Message 4 of 19
(3,360 Views)

Hi Carmen,

 

getting data or tasks into an out of a shift register. 

Well, use wires to do so!

 

enabling and disabling loops of the state machine

What "loops"? There is just one loop surrounding the state machine…

 

decision making in the state machine

That's up to you and depends on your task. You need to define those decisions before even starting to program…

 

time stamp

??? Is there any relation to a state machine?

 

file saving/opening

??? Is there any relation to a state machine?

 

+ many other issues

Which ones?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 19
(3,351 Views)

Do a search for JKI State Machine.  I like it for the most part.  I have modified it to remove the event structure because i didn't want the processing of the events to be delayed by the state machine.  My app would run a series of states back to back and I had to inject an IDLE state to check for events, which wasn't ideal for me.  May be okay for you however.

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 6 of 19
(3,346 Views)

 

 

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. 

0 Kudos
Message 7 of 19
(3,323 Views)

http://www.ni.com/tutorial/7595/en/

http://www.ni.com/white-paper/7604/en/

http://k12lab-support-pages.s3.amazonaws.com/lvadvancedhome4.html

https://www.youtube.com/watch?v=vtw6HMwaTIQ

 

This lot took me at least 8 seconds to find with Google. Invest a little more time and you could probably do even better 😉

(there really is a lot of stuff out there!)

 

EDIT - okay so this crossed with your last post, and is probably a tad sarcastic and looks even worse following your last reply. But you will do well with a bit of searching because, like you want to not re-invent the wheel, neither does everyone else when there are already so many good examples out there.

 

EDIT - for a little more complexity, check out the Continuous Measurement and Logging sample project template - althogh a slightly different architecture it has all the elements you listed and more.

Message 8 of 19
(3,315 Views)

You could also look at the CLD sample exams.  The solutions are almost guaranteed to use a State Machine architecture and should have all of the elements it sounds like you are looking for.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 19
(3,297 Views)

@crossrulz wrote:

You could also look at the CLD sample exams.  The solutions are almost guaranteed to use a State Machine architecture and should have all of the elements it sounds like you are looking for.


This is what I thought as well.  Click the CLD Sample Exams link to download four sample exams each with a solution.  

 

http://www.ni.com/gate/gb/GB_EKITCLDEXMPRP/US

 

Make sure to at least read the full prompt and think about how you might go about solving this before looking at the solution.  If you can, take the time to try and program one yourself.  You think you will learn a lot by just looking at the solution but you will learn a lot more by actually trying it yourself, struggling a bit, then seeing how you can avoid the problems that you were running into.

 

 

Matt J | National Instruments | CLA
Message 10 of 19
(3,261 Views)