LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

State Machine

Solved!
Go to solution

 Hi all

 

How do you make a single state to process code only  on the second time that particular state is called. For example in the code attached how would you make the "log state" execute after double the log time. 

0 Kudos
Message 1 of 22
(2,871 Views)

So you're logging every 125 ms on the timeout event? And you want to continue logging every timeout event, but bypass the first timeout event?

 

If that's what you're tring to do you could use the First Call? function to ignore the first time that event is called.

 

Eric

0 Kudos
Message 2 of 22
(2,869 Views)

Hi Charles,

 

so you want a StateMachine that doesn't work like a StateMachine???

 

When you don't want to execute a state then don't call it! Only go to "Log" state when all conditions are met...

Best regards,
GerdW


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

Oh, you're actually acquiring every 125 ms and logging every 15 s. I still think you can use First Call? for this.

0 Kudos
Message 4 of 22
(2,861 Views)

Thanks guys

 

Egraham , your latter presumption is actually correct. I will try your solution first.

0 Kudos
Message 5 of 22
(2,857 Views)

Maybe  I should state the root of my problem. I have one state that executes after double the time of another so I'd like to use the same timer for both states. I am thinking this is much simpler than trying to use multiple timers which i really don't know  how to do.

0 Kudos
Message 6 of 22
(2,856 Views)

Hi Charles,

 

you don't need two or more timers. You simply have to make two checks before calling the log state ("time over" & "not the first run")...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 22
(2,852 Views)

Hmm... I guess GerdW understands what you're trying to do. I'm still not understanding. The same timer used for multiple states could be pulled out of the case structure and fed in. If one requires double the time, just multiply the output by 2.

0 Kudos
Message 8 of 22
(2,852 Views)
Solution
Accepted by topic author Charles.m

Correction... you would have to set the timer to the maximum state time and execute the case requiring half the time on increments of half of what the timer was set for.

Message 9 of 22
(2,850 Views)

Why not remove the actual code from the timeout event and use user defined events. Create an event for each of your states and then the timeout event will simply compare the time to see which events should be fired. You can use the current time or tick count to track time. A shift register with a cluster of your various start times for tracking the individual times themselves would work. This would work much more like a true state machine. Also, your Stop event can handle the cleanup and there is no reason to post another state.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 10 of 22
(2,836 Views)