05-19-2016 07:30 AM
Does anyone have an example in ANSI C of collecting data from 2 different transducers at the same time? The examples I have seen are for one AI only. I need to gather the data as two separate streams. The data from AI0 should not be mixed with the data from AI1. Do I start two separate tasks? If so, is there an example available?
Solved! Go to Solution.
05-20-2016 06:00 PM
Are you going to be collecting data on two channels of the same device or are you going to be collecting data from two seperate devices? Also, if you are using one device, are you familiar with channel expansion?
05-23-2016 06:24 AM
I want to use two channels on one device. Using two devices may be a later option. Right now, I can easily access one channel with:
DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"Dev5/ai0","AnalogInput0",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
As soon as I change this to:
DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"Dev5/ai0:1","AnalogInput0",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
I get a channel definition error. I need to record the data from two channels at once as part of a regulator pressure response test.
Thanks!
Tim
05-24-2016 04:30 AM
Tim,
you tell us the DAQmxCreateAIVoltageChan is creating an error with that parameters?
Which device are you using as Dev5?
Norbert
05-24-2016 06:29 AM
USB-6008. All works fine with a single channel, but trying to use two has me stumped. Unfortunately, all of the examples just show using one channel and not multiples or multiple devices.
My frustration level has hit the ceiling!
05-24-2016 09:31 AM - edited 05-24-2016 09:31 AM
If you run a MAX testpanel, is using that channel string working?
You didn't answer if the create channel is generating the error. I somehow assume that it is more something like e.g. timing which could create an issue.....
Norbert
EDIT: It would be useful if you post a screenshot of the error and some code snippet.
05-24-2016 10:29 AM
Yes, the channels are working. It never gets to the point where timing is an issue.
I have used a single channel to gather data and display it on a graph while logging to a TDMS file and that works great. However, trying to expand to a second channel has not worked at all. Just changing the following line make the program choke:
DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"Dev5/ai0","AnalogInput0",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
to: DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"Dev5/ai0:1","AnalogInput0",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
I need to know how the program should be structured. I assumed that someone at NI at sometime had actually performed this operation and that the solution would be readily available. If I knew the proper functions to call and the proper syntax, then I would be ready to tackle any timing issues that might arise.
Process ID: 0x00000278 Thread ID: 0x00001094
Start Time: 11:42:31.954 Call Duration 00:00:00.422
Status: 0 (0x0)
Process ID: 0x00000278 Thread ID: 0x00001094
Start Time: 11:42:32.376 Call Duration 00:00:00.547
Status: 0 (0x0)
Process ID: 0x00000278 Thread ID: 0x00001094
Start Time: 11:42:32.923 Call Duration 00:00:00.015
Status: 0 (0x0)
Process ID: 0x00000278 Thread ID: 0x00001094
Start Time: 11:42:32.938 Call Duration 00:00:00.000
Status: 0 (0x0)
Process ID: 0x00000278 Thread ID: 0x00001094
Start Time: 11:42:32.938 Call Duration 00:00:00.016
Status: 0 (0x0)
Process ID: 0x00000278 Thread ID: 0x00001094
Start Time: 11:42:32.954 Call Duration 00:00:00.000
Status: 0 (0x0)
Process ID: 0x00000278 Thread ID: 0x00001094
Start Time: 11:42:32.954 Call Duration 00:00:00.000
Status: 0 (0x0)
Process ID: 0x00000278 Thread ID: 0x00001094
Start Time: 11:42:32.954 Call Duration 00:00:00.047
Status: 0 (0x0)
Process ID: 0x00000278 Thread ID: 0x00001094
Start Time: 11:42:33.001 Call Duration 00:00:00.000
Status: 0 (0x0)
Process ID: 0x00000278 Thread ID: 0x00001094
Start Time: 11:42:33.001 Call Duration 00:00:00.265
Status: 0 (0x0)
Process ID: 0x00000278 Thread ID: 0x00001094
Start Time: 11:42:33.266 Call Duration 00:00:00.016
Status: 0 (0x0)
Process ID: 0x00000278 Thread ID: 0x00001094
Start Time: 11:42:33.282 Call Duration 00:00:00.000
Status: 0 (0x0)
Process ID: 0x00000278 Thread ID: 0x00001094
Start Time: 11:42:33.282 Call Duration 00:00:00.016
Status: 0 (0x0)
Process ID: 0x00000278 Thread ID: 0x00001094
Start Time: 11:42:33.298 Call Duration 00:00:00.046
Status: 0 (0x0)
Process ID: 0x00000278 Thread ID: 0x00001094
Start Time: 11:42:33.344 Call Duration 00:00:00.000
Status: 0 (0x0)
Process ID: 0x00000278 Thread ID: 0x00001094
Start Time: 11:42:49.157 Call Duration 00:00:00.000
Status: 0 (0x0)
Process ID: 0x00000278 Thread ID: 0x00001094
Start Time: 11:42:49.157 Call Duration 00:00:00.000
Status: 0 (0x0)
> 18. DAQmxReadAnalogF64 (0x6DE8C768, 1000, 10, "DAQmx_Val_GroupByScanNumber", {0,0,...}, 1000, 0, NULL)
> Process ID: 0x00000278 Thread ID: 0x0000069C
> Start Time: 11:42:51.157 Call Duration 00:00:00.125
> Status: -200229 (0xFFFCF1DB)
Process ID: 0x00000278 Thread ID: 0x0000069C
Start Time: 11:42:51.282 Call Duration 00:00:00.000
Status: 0 (0x0)
Process ID: 0x00000278 Thread ID: 0x0000069C
Start Time: 11:42:51.282 Call Duration 00:00:00.032
Status: 0 (0x0)
Process ID: 0x00000278 Thread ID: 0x0000069C
Start Time: 11:42:51.314 Call Duration 00:00:00.000
Status: 0 (0x0)
Thanks again for your assistance.
05-24-2016 10:35 AM
From your log i see that you run into an error when reading the analog data.
Error -200229 occurred at an unidentified location
Possible reason(s):
Buffer is too small to fit read data.
There is a parameter for the read function to define the size of the buffer (or you pre-allocated it). If you acquire two instead of one channel using the same data rate, the amount of data will be double. So you require a double sized buffer to fetch all data.
Norbert
05-24-2016 10:52 AM
I increased the buffer size to 10000 and the error still occurs.
Thanks,
Tim
05-24-2016 12:34 PM
I solved the problem by using NISpy and changing parameters to see what effect they had on the program. I was trying to read two channels with 1000 data points each. I thought my buffer size was the problem, but it was in the call to:
DAQmxErrChk (DAQmxReadAnalogF64(taskHandle, 1000, 10.0,DAQmx_Val_GroupByChannel,data, 2000, &read,NULL));
I did not realize the significance of the parameter arraySizeInSamps and had left it at 1000 when I added the additional channel.