From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

close or open 16 solenoid valves in certain order

Hello

I use this block diagram to close or open valve in our system.

For different process, controled by state machine,

valves have different state, My system has 16 valves, so for each case, I have use this 1-D Boolean array to change each element value. Is there any other simple way to change 16 values which is written into data termial of DAQ write?

 

Thanks

22.png

0 Kudos
Message 1 of 4
(5,128 Views)

You can use 16-bit integers rather than the 16-element boolean arrays.  Just choose a different polymorphic version of the Digital Write.

 

If the values are all known and fixed (unchanging with time), you could create an array outside the state machine and just use Index Array inside to select the appropriate value.  This has the advantage that if the values ever need to be changed, there is only one place to change. This reduces the chances of missing some changes.

 

Lynn

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

If I use U8 or U16

It means 0 is true. 1 is false, right?

 

0 Kudos
Message 3 of 4
(5,107 Views)

@dragon-long wrote:

If I use U8 or U16

It means 0 is true. 1 is false, right?

 


Each bit of the U8 (or U16) will correspond to a digital line (bit 0 -> P?.0, etc.).  A 1 in the bit will correspond to a TRUE for that digital line.

For instance, writing a 36 (0b00100100) will turn on lines 2 and 5 while turning the others off.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 4
(5,103 Views)