LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

stopping an event sequence


@jastel wrote:

This maybe a stupid question but how do you create a state machine


Far from stupid.

 

On this forum, all well-worded questions seeking knowledge are good.

 

Around here the only stupid/dumb questions are questions looking for someone else to do their work and avoid knowledge.

 

As long as you seek knowlege and play nice, let 'em fly and try to have some fun as you go.

 

Ben 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 11 of 28
(1,340 Views)

Okay....thie state machine is great...I went through and replaced all my stacked sequences with them. I am having a little bit of trouble with lag. It is better then what it was with the stacked sequence. I am running 9 different intrument, 3 of which have to run continuously, the rest are part of different state machines and am collecting data off of 4 of those instruments. one of the state machine moves a motion controller then turns on a power supply for a light, on and off 3 times before the motion controler moves to the next location. when this sequence runs most of the time the light stays on for the set time, but some times the light will just flicker on and off really quick. of course this doesn't happen when the program is by itself only when it is add to the rest. I am running on a old computer and figured it would go away when the new one comes in next week. is there anything that i should look for or ideas on what to check for

Message 12 of 28
(1,311 Views)

Maybe one of your state transition (decision to go to the next step) is going to the wrong step and should be going to another state (may need top be added).  That may resolve the light flicker.

 

Glad to read that you converted it to a state machine.  You probably already see the benefits.

 

0 Kudos
Message 13 of 28
(1,298 Views)

If i attach the Vi....you think you might be able to take a look

0 Kudos
Message 14 of 28
(1,283 Views)

Posting your code is always the best way to get help.

Tim
GHSP
0 Kudos
Message 15 of 28
(1,279 Views)

So Temperature, pressure and current need to be collected continuously, 4 main poer supplies need to be able to be turned on and off and asjusted at anytime, 5th power supply runs a light that normally turns on for 5 seconds and off for about 2 seconds. then another test called the filter test which uses a motion controller to move filters then the light turns on for about 3 second and off 3 times beofre it moves to the next loaction, also has the ability to move the filter wheel at anytime for random checks.....here is the VI

0 Kudos
Message 16 of 28
(1,270 Views)

Have you ever used state machines? Are you familiar with event structures?

Tim
GHSP
0 Kudos
Message 17 of 28
(1,258 Views)

OMG!!!!!Smiley Surprised  There are about a thousand race conditions.  Its no wonder it doesn't work like you want it to.  You have many loop running parallel with no data dependency between them.  You have way too many local variables.  How do you know that a local variable is updated before it is read elsewhere when the reading and writing have no timing associated with them.  You need to learn what data dependency is.  You really need to convert to a different architecture.

 

If you want your code to execute in a particular order, or if the output of one stage affects which code to execute next, then you need a state machine.  If you must have several sections of code executing simultaneously, and you have data being shared between them, you need a producer-consumer architecture with queues to pass the data.  Your parallel loops and local variables is the root cause of your problems.  Think about what you are wanting to do and then re-write your code using an appropriate architecture.  If you have trouble deciding, explain in detail what you want to do.  Use your loops as references as to what it is you want to accomplish.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 18 of 28
(1,256 Views)

Here is a start using your first loop with what I would do to the best of my understanding of what you are trying to accomplish. No wait is necessary when you use the event structure to do the timing. I keep track of elapsed time and turn off the lights after five seconds. This was more to show you the flow of a state amchine and the event structure.

Tim
GHSP
0 Kudos
Message 19 of 28
(1,248 Views)

If it wasn't posted, here's something important:

To learn more about LabVIEW, I suggest you try looking at some of these tutorials.

 

Oh boy...  Parallel Loops and Local Variables.  That's a potent mix..

0 Kudos
Message 20 of 28
(1,233 Views)