LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to capture a change of state from a boolean switch

Help. I need to send  3 bytes to a serial port when a boolean switch is set true and  3 different bytes when the switch is set false.

The problem I have is I only want to send the bytes once each time the switch changes state and not constantly.

I've worked out how to send the bytes by using a case statement, but it sends the bytes continuously.

Any suggestions?

0 Kudos
Message 1 of 4
(2,941 Views)

I haven't look at your VI but usually you use an event structure with the value change event for the boolean control to do something like that.

 

Ben64

0 Kudos
Message 2 of 4
(2,939 Views)

Ben64 made a good suggestion.  If you cannot use that method, put the current value of the boolean in a shift register. On each iteration of the loop compare the current value of the boolean with the previous value stored in the shift register (XOR gate). When they are different, send the bytes.

 

Lynn

0 Kudos
Message 3 of 4
(2,919 Views)

Hi NewWorldMan,

 

I think you need nested case structures, one to check if the switch has changed state. If it has not, we don't want to send bytes.

If it has changed we need to decide which to send.

 

I have modified your VI, you will have to check I got the bytes to send the correct way around.

 

Regards,

 

Steve

Stephen C
Applications Engineer
0 Kudos
Message 4 of 4
(2,914 Views)