LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parallel loops

Vee Jay, you don't have to create separate threads for each DAQmx channel.  I answered this in one of your other threads.  Use one thread and use the Mulitple Channels Single (or Multiple) Samples function for the Read.  The output will be an array of data.  If single sample, the first element in the array is the data for the first channel.  2nd element is data for the second channel.  If using Multiple Samples, the output will be a 2D array.  The first row will be data for first channel, next row will be for 2nd channel, and so on.  See the picture and notice the data output for ai0 and ai1.  Data for every channel with just one thread.

 

DAQ_MultipleChannels.png

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 31 of 50
(1,398 Views)

Awesome! Thanks! My confusion was with respect to using these channels independently irrespective of them being on the same thread. But I see that they can be easily used from the way you showed. The will also be applicable for Write as well right?

 

V

I may not be perfect, but I'm all I got!
0 Kudos
Message 32 of 50
(1,380 Views)

Yes, you use one thread only when reading or writing.  Just set up the write data in an array with element 1 (or row 1) being for the first channel, and so on.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 33 of 50
(1,361 Views)

Hi tbob,

 

Here is the error that shows up when I try combining channels into a single thread. Please check attachments.

 

Thanks! 🙂

 

V

I may not be perfect, but I'm all I got!
Download All
0 Kudos
Message 34 of 50
(1,341 Views)

I'm sorry, I made a mistake and didn't catch it.  You don't need to create a task at all.  Delete the Create Task fuction.  Wire the channel list string directly into the DAQmx Create Channel vi.  But beware.  Wire to the "physical channel" input, not the "name to assign" input which is just below.

 

DAQ_MultipleChannels.png

- tbob

Inventor of the WORM Global
0 Kudos
Message 35 of 50
(1,324 Views)
Haha, I just caught it and changed it! 🙂 and then I get your message. Thanks bob!
I may not be perfect, but I'm all I got!
0 Kudos
Message 36 of 50
(1,315 Views)

Hi again. I am stuck with this now. 😞 How do I write into daqmx when multiple channels are in the same thread? Would build array work? If not how do I create an n-row, unlimited column array to write into n-channels at the same time? Please refer to attachment.

 

THanks!

 

V:)

I may not be perfect, but I'm all I got!
0 Kudos
Message 37 of 50
(1,278 Views)

You will need a 2D array.  You can create a 1D array for each channel's data, then use Build Array to combine all data into a 2D array.  I don't have a DAQ setup so I can't play with it.  But I think you may have to use Transpose Array after you build the 2D Array.  Here is why.  The write funtion will take the first row and write the first column to the first DAQ channel, the second column to the second channel, and so on.  But as you build the 2D array, the first row will be all the data for the first channel.  Your output will be wrong.  You need each channel's data to be in columns, not rows.  So use Transpose Array, then the channel data will be in columns instead of rows.  Now the write will send data from each column of the first row to each channel.  The next write will use row 2, then row 3, and so on.

 

Your array will not have unlimited columns.  You have a finite number of channels.  The number of columns after transposing will be equal to the number of channels.  One column per channel.  The number of rows after transposing will be the number of elements to write to each channel.

 

Look at this example:

 

Channel 1 data:  101 - make into a 1D array

Channel 2 data:  010 - make into a 1D array

 

Use Build Array to produce a 2D array:

101

010

 

Transpose:

10

01

10

 

On first write, channel 0 will get the first row first column data, 1.  Channel 1 will get the first row second column, 0

On the next write channel 0 will get second row first column,    0.  Channel 1 will get second row second column,  1

On the next write channel 0 will get third row first column,        1.  Channel 1 will get third row second column,      0

 

So channel 0 gets 101 and channel 1 gets 010.  Is this clear now?

 

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 38 of 50
(1,264 Views)

Thanks! tbob... Is there something you don't know? 🙂 jk...

 

tbob---> keeping it simple.

 

V

I may not be perfect, but I'm all I got!
0 Kudos
Message 39 of 50
(1,255 Views)

VeeJay wrote:

Thanks! tbob... Is there something you don't know? 🙂 jk...

 

tbob---> keeping it simple.

 

V


 

Believe it or not, I am not the most knowledgable person in Labview here on this forum.  There are others here that excel in that dept.  But I think I have a knack for keeping things simple.  That's because either I have a simple mind, or I'm to lazy to be complicated.  Smiley Very Happy  Take your choice.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 40 of 50
(1,247 Views)