01-25-2017 04:13 PM
Hello,
I'm stuggling to get two parallel while loops to talk to each other. I'm writing a VI to control the motion of a thorlabs rotation stage while simultaneously reading in an analog input on a LabJack. I want to trigger an event when the analog input drops below or rises above a threshold voltage. The top loop contains the event structure; the bottom loop is monitoring the LabJack input.
However, I cannot get the my event structure to notice when the threshold is crossed (a value change in 'move next indicator'). I tried using the value (signalling) property node- but this triggers the event with each iteration of the while loop regardless of whether or not there was actually a state change.
Any suggestions? How do I trigger an event based off of a Boolean value change?
Solved! Go to Solution.
01-25-2017 04:18 PM
As you have discovered, you must only write to the boolean control when it changes state from false to true. Look into using a shift register to keep track of the last state of the boolean. When its current value is true and not equal to the last value, write to the value change boolan property node.
01-25-2017 04:29 PM
I agree with terickson.
The VALUE (signalling) property will trigger an event on anybody who's listening REGARDLESS of whether the value actually changes - that's the defined and expected behavior.
If you want it to happen ONLY when the boolean changes, then put the current value from the comparison into a ShifttReg on every iteration, and compare the current value with the last value (from the ShiftReg).
If the old value was FALSE and the new value is TRUE, then fire the VALUE(Signalling) event.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
01-26-2017 09:43 AM
Aha! I used the shift register in conjuction with a case structure (picture below) and it seems to work now. Thanks for your help!
01-26-2017 09:58 AM - edited 01-26-2017 09:58 AM