LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to change the elements number in Number To Boolean Array Function VI

Solved!
Go to solution

Hi, I'm working on using the DAQ digital output to control the digital input of a DAC, and I used the Number To Boolean Array Function. VI to convert the number to a Boolean array. The maximum number should be 4096, therefore it should consist of 12 elements.

 

For the description of the VI, it says Boolean array returns an array of 8, 16, 32, or 64 elements, depending on the number of bits in the integer. Therefore, I change the number of the channels in task to 16, but it still doesn't work. Any suggesitions are greatly appreciated.

 

Thanks!

 

Possible reason(s):

Write cannot be performed, because the number of channels in the data does not match the number of channels in the task.

 

When writing, supply data for all channels in the task. Alternatively, modify the task to contain the same number of channels as the data written.

Number of Channels in Task: 12
Number of Channels in Data: 32

Task Name: _unnamedTask<1B>

0 Kudos
Message 1 of 5
(3,036 Views)
Solution
Accepted by simimasa

Once you have the boolean array, you can resize it using array tools. For example you can use "reshape array" with a lenght of 12 to trim the array to 12 booleans elements (you can also use array subset).

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

Hi simimasa,

 

when you create a DO task of 12 channels you need to provide a boolean array of 12 bits (aka elements). Use ArraySubset to get your 12 bits…

Best regards,
GerdW


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

Thank you. 

It works.

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

Of course you COULD wire a U8 directly to the DAQmx Read through a build array and let DAQmx ignore the extra bits for youSmiley Wink

Capture2.PNG

 

Much easier to work with when you realize you need one more digital line

 


"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 5
(3,007 Views)