LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Updating one boolean array element conditionally

Solved!
Go to solution

Hi, I have a 16 bit array of boolean values, and I want to be able to change one bit, and only one, when the appropriate input to the VI changes.

 

As background, I have a 16 bit port expander (I2C) and I need to change just one bit, ie set one of the outputs on or off, without affecting the others. To do this, I read back the 16 bits so I know what the current states of the outputs are, then I need to change one bit, and write the 16 bits back in.

 

I looked at the Replace Array Subset block, which seems to be related, but since I only need to change one of the bits at a time, I dont see how I can connect up controls to all the 16 bits and modify only the one I need to change.

 

Is there an elegant way of doing this? For example can I have a combo box with the names of the ports in it, so the user can select the port they need to change, and then they set the state of a toggle switch or boolean value to set the bit, and only that bit? Thanks for any advice.

0 Kudos
Message 1 of 7
(3,329 Views)
Solution
Accepted by TripleAntigen

Is this the sort of thing you had in mind?

 

Snip01.JPG

 

Snip02.JPG

Message 2 of 7
(3,325 Views)

Brilliant! Exactly what I needed, thanks. I think my understanding of the Replace Array Subset block was flawed.

Much appreciated.

0 Kudos
Message 3 of 7
(3,320 Views)

Could you please advise how to change square type boolean array to be round type programatically? Thanks for answer

0 Kudos
Message 4 of 7
(3,149 Views)

Hi arifi,

 

can you tell us why you want to do that "programatically"?

 

(Answer: You need to use LV scripting to change VIs programatically…)

Best regards,
GerdW


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

actually I want to replace the round type boolean array other size or shape. Is it possible to copy and paste during runtime?

0 Kudos
Message 6 of 7
(3,090 Views)

Hi arifi,

 

at runtime you cannot edit a running VI: so the answer to your question is "NO"!

 

But there are surely options to reach your goal: you might use picture rings or the 2D picture indicator instead of boolean arrays…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 7
(3,067 Views)