LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

State machine with DAQ

Solved!
Go to solution

Hello everybody,

 

So, it's my first time working with the concept of a state machine for a LabVIEW project. I've watched some videos and made some basic projects using examples/tutorials using state machines but for what I'm doing it has to be a bit different and I was wondering if you guys could give me some specific/detailed info on how to make this happen.

 

I'm currently working with an NI-DAQ USB6423 in order to monitor multiple types of sensors' data, as well as control a few components using the DAQ. I've made all components work together already (data monitored from all sensors simultaneously and controlling components individually and simultaneously) but this is not using a state machine structure which makes the project run less efficiently - and if I incorporate the security features I intend to include, some of the processes stop working completely. So, for now, I'd like to create a simplified version of this and test it at a scale which can help me understand what I'm working with.

 

The goal at the moment is to hook up a temp sensor to the DAQ and retrieve the data, display the data, include some controls in the front panel to manually adjust the upper and lower thresholds while the code is running, have one light per threshold and have them light up when either one of the thresholds are met, include a warning sign (custom image of mine) when either threshold is met for more than 10 seconds, include a countdown once the warning sign appears which counts down from 15 seconds and stops the code entirely when it hits 0. There should also be two individual "Gather Sample" buttons on the Front Panel which should only turn on for 3 seconds when pressed and then automatically turn off after this time (this button also triggers a boolean which is a valve in the system in order to physically gather the sample). Aside from this, the data is to be stored on an excel file for when the code runs until the code fully stops. The data should be stored with date/time in one column and the value read from the sensor in another. The sample rate doesn't matter at the moment since that is always adjustable but let's say for now once every 5 seconds is fine. There are other features involved such as when pH is too low, it triggers a pump which refills the solution from a reserve and other cause/effect actions but I'm leaving those excluded for now.

 

Also, considering this would be used as a framework to later build up on and incorporate more sensors - if including two sensors provides a better basis for this setup structure then using two temperature sensors can be used as an example on how to expand on incorporating more sensors since this setup already uses two sensors anyways.

I'm already aware of how to connect everything individually and which functions to use in order to make the components work together so setting up the DAQ and everything else component-wise is accounted for but if anybody can provide an example similar to what I just described using a state machine, have a similar project they've already created in the past which they are willing to share or even just some tips on how to achieve this goal, I'd greatly appreciate your help or input.

The image I've included is how I've set up my Front Panel. Hopefully, this provides a bit more information on how things are supposed to work. If there's any questions or any additional information needed, just let me know.

Thank you in advance!!

Kind regards,
PDB

PDBSteenhuisen_0-1768315464952.png

 

0 Kudos
Message 1 of 7
(177 Views)

Hey PDB

 

Maybe it worth to take a look at the DQMH Framework https://dqmh.org/

It has a good docuemntation and examples -> https://documentation.dqmh.org/dqmh/7.1/ and a good active community.

 

Maybe thats something for you.

 

Best regards & good luck with your project

0 Kudos
Message 2 of 7
(166 Views)

Are you aware of the "Enhanced State Diagram Toolkit"?

 

You basically, draw the state machine as a state diagram and it creates the code for handling the state machine for you

 

joshualguthrie2civ_0-1768326184853.png

 

Message 3 of 7
(133 Views)

Don't you think both of these solutions are a bit advanced for someone who has never used a state machine? We should make sure he can drive a grocery-getter before we commit him to a 5,000 HP dragster.

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.
Message 4 of 7
(125 Views)

Ya know, I had the same thought. 

 

But with that said, I'm not seeing that many states.  

 

I don't see a state machine being the sole design pattern (IMHO).  But w/o digging into his particular application in a way this forums are poor at, I figured the best course was to just point him in the direction of how I'd try to use state machines effectively.  Personally, I love that toolkit.

Message 5 of 7
(106 Views)

Hey Joshua,

 

Thanks for that! I was not aware. Let me look into some more content and read through some info and try it out for a bit to see if I can get things going.

 

If you know of any better way of tackling this setup or if I'm missing anything else, please do share.

 

Appreciate the tip!

0 Kudos
Message 6 of 7
(54 Views)
Solution
Accepted by PDBSteenhuisen

Hey again,

 

Realized that for my case, parallel processing works best at the moment but I will be using that toolkit in the future regardless.

 

Thank you again. Cheers!

 

PDB

0 Kudos
Message 7 of 7
(27 Views)