04-03-2008 07:13 AM
04-03-2008 07:17 AM
04-03-2008 07:56 AM
Hi GerdW,
Thanks...Any chance of a quick picture
to help.
Much appreciated.
Labtech5555
04-03-2008 08:08 AM
Here is a sample file for you. The main thing to note is that you need to make sure your values are read inside the while loop... not set as inputs. What I mean by this is you cannot wire your values into the while loop from the outside, they would have to be local variables and such, or read from the terminal inside, like I did here. I also put a reset into this sample so that you could mess with it and see how it works.
It is saved in LV 8.0 format so you can read it.
Good Luck,
04-03-2008 08:14 AM - edited 04-03-2008 08:14 AM
04-03-2008 01:03 PM
Here is another version. It just uses a functional global.
04-04-2008 04:39 AM
Hi Guys,
Thanks for your help so far.
What i've got nearly works ..The output must stay low at the start when all inputs are low then go high only
when the inputs all go high.If any of the inputs then fall low the output must latch and stay low.This is not quite working
on what i have so far.Still trying to fix ?
Labtech5555
04-04-2008 07:04 AM
04-04-2008 07:44 AM - edited 04-04-2008 07:50 AM
I agree with the state machine idea. Attached is an example for you. Please read the notes I have included and play with it a bit to make sure it does what you want it to, then modify for your code.
The way this works, as the while loop spins, the case statement is evaluated every time with a value passed in from the previous iteration of the loop. This allows you to evaluate the "state" of the program and decide what code you want to execute in the next iteration of the loop. In other words, every time you go through the while loop, the case thats run decides which case will run next time.
In the first time I seed the shift register for the case statement with 0. This is the initial case. The condition for going from state 0 to state 1 is that all inputs are high. After this, in state 1, if any input goes low, you are placed into state 2, the reset state. The only way out of this state is to hit the reset button... and so on. Note that you have a choice on where the loop goes after a reset... do you want it to immediately fail if all inputs are not high, or do you want it to start like it did, waiting first for all inputs to go high. This will decide where you want the reset state to send you, either to state 0 or state 1. See the notes on the diagram for further info.
One word of caution to those reading this interested in the state machine idea... if you use it... KEEP IT SIMPLE. This type of code can be very frustrating to debug. If your app will use complex reasoning to decide which state to go to, or you think there would be many many states, try to think of a way to simplify. If you dont, you will be stuck trying to figure out which state it is in and why for hours sometimes, before you can even start on the problem. Strip it down to what you need for a state decision as much as absolutely possible. Trust me on this one... I have been there.
Attached VI saved in LV 8.0 format.
Good luck,
04-04-2008 10:02 AM