Question

I have been scratching my head trying to find a code that allows the change from on->off to cause something to happen while a change from off-->on not to work.

For example, I have a sensor as an input. At first it senses an object that passes by and rests for a few seconds, so its recording a off (so 0). When it records a off it causes a light to turn on. After the few seconds, the object goes to the end (leaving the sensor) and then comes back and passes through the sensor again. But, I don't want the light to turn on this time.

If the system had a memory that its previous state was off and now its going to sense on, then I wouldn't let a off-->on to work, but a on-->off to work. Is such a code possible on LabVIEW? Are there any other alternatives to this?

Was it helpful?

Solution 2

You can use a local variable and a feedback node to accomplish this.

Assuming this is in a while loop my solution is to create a local variable hasLit and a feedback node on the sensor input. When the feedback node output is true and the sensor input is false (the object just passed out of the sensor view) we change hasLit to true. The state of the light will then be true if the sensor is true and not hasLit.

Image form

OTHER TIPS

I believe this will do it and it's very simple, correct me if I'm wrong because I don't know that I fully understand the logic desired.

enter image description here

The key here is the use of a shift register, it's more straight forward than the local variable option, I'm certain the right solution is there or some small tweak to this.

The shift register is initialized as false and whatever state appears on the output of the loop will reappear on that input on the next loop.

Another interesting solution would be with an event structure to trigger on a value change of "Sensor". This solution can also be slightly more responsive, see below:

enter image description hereenter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top