LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

trying to write booleans with DAQmx

Solved!
Go to solution

I'm trying to cycle through some boolean values in an array one at a time then write these with DAQmx for a beacon control.  I'm getting the error that the number of channels does not match the data (Error 200524):

 

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: 4
Number of Channels in Data: 1

 

Previous to this code, I had set up a DAQmx Digital output task with 4 lines in it

 

I've attached a segment of my block diagram - my thinking is that this would index through the array (previous to this I had an auto indexing tunnel looping through, which gave the same error. 

 

Could anyone give me a pointer on how to overcome this, or a better way of acheiving it?

 

0 Kudos
Message 1 of 5
(2,626 Views)

You don't need the For loop if you're only writing the array constant, what you've shown here is going to set the same 4 boolean inputs 4 times. Try to set it up like this and see if it works (maybe excluding the Flatten Channel if your task has already been initialized):

 

original.jpeg

 

 

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 5
(2,616 Views)

Thanks for that, I'd not come across the channel flatten VI before, though I think that would write all those inputs in parallel?

What I'm trying to do is construct a sequence of:

 

0001

0010

0100

1000

with successive writes

0 Kudos
Message 3 of 5
(2,606 Views)
Solution
Accepted by topic author djroseman

First, get your single Write functionality working.

Once you've got that functioning properly, use your For loop to auto-index through a 2D array of booleans in the order you want. Make sure to right-click the tunnel input to the For loop and turn on auto-indexing. You don't need an input to "N" if auto-indexing is turned on.

 

NewBooleans~2.png

 

 (The above array is backwards ordered from what you want, but you get the idea.)

 

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


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

I got that sorted, thanks for your help

0 Kudos
Message 5 of 5
(2,558 Views)