LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

state machie

Which part of SercoSteves answer is unclear?

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 11 of 16
(725 Views)

Hi Hatem

Are you able to post what you have done so far so that we can advise on the best next steps?  The NI Community love to solve problems I suspect you will get plenty of advise. 

Steve

 

NOTE: Please save any attachments as LV2014 or earlier or post screen shots. 

0 Kudos
Message 12 of 16
(723 Views)

that is what I have done until now, I have pump 1 and pump 2 each one of them works for 5 seconds for example then they swap and so on, but when we get a signal from the sensor pump 1 must stop immediately and the code jumps to pump 2 on

Note: the sensor could be HIGH only during the pumping from pump 1 so it has nothing to do with pump 2

0 Kudos
Message 13 of 16
(717 Views)

Hi Hatemaboud,

 

when we get a signal from the sensor pump 1 must stop immediately and the code jumps to pump 2 on

So you have a clear state transistion condition.

All you need to do is to program it: "IF sensor==TRUE THEN step2".

 

- The problem seems to be in step2 you go back to state1 immediately.

- Another problem I see is your loop spinning as fast as it can. Usually you should wait some small amount of time to allow sensor values to change! (In your VI: you detect a signal of your level sensor, jump to step2, jump back to step1 nearly instantly giving the sensor no time to even change it's output…)

- you should use a typdefined enum for your states

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 14 of 16
(713 Views)

ok but the sensor also could stay false, so it will jump to pump 2 when the 5 seconds are finished so the normal is: the two pumps work 5 by 5 and the sensor is emergency

0 Kudos
Message 15 of 16
(710 Views)

Hi Hatem

Nice one, It looks to me like you are really close.  GerdW is correct it looks like if you implement the same timing logic in the case for step 2 as you have is step 1 (with the Sensor detect OR removed) you will see your 5 by 5 timing.

 

Additional:  Have a look at the FALSE Case of the Case Structure within step1.  In there you need to stay in the state you are in so you need to wire the through the time you entered state rather than getting a new time and also wire through the state.

 

Case Structure.png

Steve

0 Kudos
Message 16 of 16
(705 Views)