Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use DAQmx Read to measure two analog channels

Using:

Visual Studio 2015 

NI-Usb6289

 

I used this channel "Dev1/ai0:1", but I don't know how to set the data in the CVICALLBACK EveryNCallback1 function.

the rule just can put in the one-dimensional array (only temperature or voltage), how can I use this function to read temperature and voltage in the same time?

this my initial contact, thank you for your help

 

A partial code:

int32 CVICALLBACK EveryNCallback1(TaskHandle taskHandleTemperture, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData)
{
int32 error = 0, written, j = 0;
char errBuff[2048] = { '\0' };
static int totalRead = 0, flag = 1, flag1 = 1, flag2 = 1;
int32 read = 0;
float64 data[2][1000], tmp, tmpT, dataVout[4000];
static float k = 0;
static float64 foreverbig;

 

/*********************************************/
// DAQmx Read Code 
/*********************************************/
DAQmxErrChk(DAQmxReadAnalogF64(taskHandleTemperture, 1000, 10.0, DAQmx_Val_GroupByChannel, data, 2000, &read, NULL));

if (read > 0) {
for (int i = 0; i < 999; i++) {
fprintf(fp, "%0.3f %+0.4e %f\n", k, data[0][i], transferVoltage(data[0][i])); //Temperature 1
fprintf(fp1, "%0.3f %+0.4e\n", k, data[1][i]); //Voltage

k = k + 0.001;
}

 

for (int m = 0; m < 998; m++) {
for (int n = 0; n < 998 - m; n++) {
if (data[0][n + 1] > data[0][n]) {
tmpT = data[0][n];
data[0][n] = data[0][n + 1];
data[0][n + 1] = tmpT;
}
}
}

0 Kudos
Message 1 of 1
(1,956 Views)