06-07-2010 04:59 PM
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.
06-08-2010 10:19 AM
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
06-08-2010 12:26 PM
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.
06-09-2010 02:23 PM
Hi tbob,
Here is the error that shows up when I try combining channels into a single thread. Please check attachments.
Thanks! 🙂
V
06-09-2010 03:09 PM
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.
06-09-2010 04:18 PM
06-14-2010 10:43 AM
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:)
06-14-2010 12:19 PM
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?
06-14-2010 01:26 PM
Thanks! tbob... Is there something you don't know? 🙂 jk...
tbob---> keeping it simple.
V
06-14-2010 01:58 PM
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. Take your choice.