LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Single numeric controlled by 8 Booleans


wrote:

I will look at my case structure.

 

I'm controlling 8 relays with a serial relay board.

To toggle a relay, I send a serial command.

 

0....7 turns off a respective relay

8....15 turns on a respective relay

I want 8 radio buttons which control the relays, they can be hit in any combination. When one gets toggled up or down, I want the .vi to output the corresponding number to turn ONLY the corresponding relay on or off. 

 


Are you sure your command structure is correct? Am I missing something? It doesn't make sense.

For example, if I want to turn relay 01 OFF (0) and relay 02 ON (9) the sum would be 9.

 

Case 1.PNG 

 

 

I'm assuming other relays would be sequentially numbered. So now I want to turn relay 05 OFF (4) and relay 06 OFF (5) the sum would be 9. That's the same numeric as before. You can't have the same numeric command do two different functions!! I think you need to read the manual again.

 

Case 2.PNG

0 Kudos
Message 21 of 26
(657 Views)

Not sure where you got that from, but I don't believe that's my code. Mine has selects upstream so that it set each individual numeric back to zero as soon as nothing is being commanded. Since the trigger boolean never goes high while the zero is in place, it doesn't command relay 1 off. Mine works, I don't see how that one would.


wrote:

wrote:

I will look at my case structure.

 

I'm controlling 8 relays with a serial relay board.

To toggle a relay, I send a serial command.

 

0....7 turns off a respective relay

8....15 turns on a respective relay

I want 8 radio buttons which control the relays, they can be hit in any combination. When one gets toggled up or down, I want the .vi to output the corresponding number to turn ONLY the corresponding relay on or off. 

 


Are you sure your command structure is correct? Am I missing something? It doesn't make sense.

For example, if I want to turn relay 01 OFF (0) and relay 02 ON (9) the sum would be 9.

 

Case 1.PNG 

 

 

I'm assuming other relays would be sequentially numbered. So now I want to turn relay 05 OFF (4) and relay 06 OFF (5) the sum would be 9. That's the same numeric as before. You can't have the same numeric command do two different functions!! I think you need to read the manual again.

 

Case 2.PNG


 

0 Kudos
Message 22 of 26
(650 Views)

If you can guarantee that on the first call exactly one of the booleans is TRUE, this will work. (If not, you need to decide on the FN initialization based in the known initial state of the system, so modify as needed).

 

Switcher.png

 

 

0 Kudos
Message 23 of 26
(649 Views)

If you assume only ONE (1) comand can be sent at a time (thus avoiding the confusion when summing numerics together) here is another way to generate the numerics using a boolean array and an event structure. It is simpler and can easily scale up as needed.

 

bo_to_num012 rev1.png

0 Kudos
Message 24 of 26
(647 Views)

wrote:

If you assume only ONE (1) comand can be sent at a time (thus avoiding the confusion when summing numerics together) here is another way to generate the numerics using a boolean array and an event structure. It is simpler and can easily scale up as needed.

 

 


  • You XOR is the same as a "not equal", just more obscure 😄
  • Your small FOR loop is the same as "Search array" except that it does not work right if nothing has changed. e.g. if the events gets triggered by a val(sgl) and the existing value. (i.e. "no change" is detected as "last element changed"). Not quite rigorous. At least "search" returns a -1 that can be used for exception handling if desired.
0 Kudos
Message 25 of 26
(641 Views)

wrote:

If you assume only ONE (1) comand can be sent at a time (thus avoiding the confusion when summing numerics together) here is another way to generate the numerics using a boolean array and an event structure. It is simpler and can easily scale up as needed.

 

bo_to_num012 rev1.png


Can't use event structures in VI's going to veristand.

0 Kudos
Message 26 of 26
(627 Views)