01-09-2018 03:06 AM
Which part of SercoSteves answer is unclear?
01-09-2018 03:10 AM
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.
01-09-2018 03:24 AM
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
01-09-2018 03:41 AM - edited 01-09-2018 03:42 AM
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
01-09-2018 03:47 AM
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
01-09-2018 04:18 AM - edited 01-09-2018 04:27 AM
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.
Steve