LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Value (signalling) between while loops?

Solved!
Go to solution

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.

code_snip.JPG

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?

 

Download All
0 Kudos
Message 1 of 5
(2,848 Views)

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.

CLA
0 Kudos
Message 2 of 5
(2,841 Views)
Solution
Accepted by topic author akc01

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.

 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 3 of 5
(2,834 Views)

Aha! I used the shift register in conjuction with a case structure (picture below) and it seems to work now.  Thanks for your help! 

0 Kudos
Message 4 of 5
(2,763 Views)

Hi akc,

 

there is the BooleanCrossing function in the Point-By-Point palette…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 5
(2,757 Views)