Dynamic Signal Acquisition

cancel
Showing results for 
Search instead for 
Did you mean: 

Multi channel acquisition problem - NI 4474

Hi all, i'm developing an appliction that use Accelerometer, i already used this card and Daqmx software to create an application (C) but always single channel , now when i 
 
a) create a speific task to read from a specific channel, i read normally
 
b) if i allocate another task for read another channel, i read an abnormal data, the readings are not standard
 
c) if the second reading is execuetd with 2 different tasks and afetr 500000 sampling, the reading is normal
 
here is the part of the code to allocate and execute a task:
 
                if(errCk(DAQmxCreateTask("",&m_taskHandle), call)){
m_mutex->unlock();
return false;
}
///Configura la Scheda
if(errCk(DAQmxCreateAIAccelChan(m_taskHandle,ch,"",DAQmx_Val_PseudoDiff,m_ni->dwl,m_ni->upl,DAQmx_Val_AccelUnit_g,m_ni->sen,DAQmx_Val_mVoltsPerG,DAQmx_Val_Internal,m_ni->curr,NULL), call)){
return false;
}
///Configura il campionamento
if(errCk(DAQmxCfgSampClkTiming(m_taskHandle,"",m_ni->fs/*10000.0*/,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,nsamp), call)){
return false;
}
///Registra l'evento func di callback
if(errCk(DAQmxRegisterEveryNSamplesEvent(m_taskHandle,DAQmx_Val_Acquired_Into_Buffer,nsamp,0,EveryNCallback,this), call)){
return false;
}
if((m_state = errCk(DAQmxStartTask(m_taskHandle), call) ? 1 : 0 )){
return false;
}
 
the reading is executed in this callback function:
 
static int  tRead=0;
int32       read=0;
int32       overloadDetectionEnabled=1;
bool32      overloaded=0;
///Quando e' true indica che i dati sono stati trasfereti al rec da data[]
bool  dc = false;
///In caso di errore non deve essere eseguito nessuno dei passi successivi
bool err = false;
float64     *data = (float64*)calloc(cbi->nsamp, sizeof(float64));
char        *overloadedChannels = (char*)malloc(sizeof(char)*cbi->nsamp);
 
///blocca la sessione critica
m_mutex->lock();
if(errCk(DAQmxReadAnalogF64(cbi->tk,cbi->nsamp,0.0,DAQmx_Val_GroupByScanNumber,data,cbi->nsamp,&read,NULL), call, false, true)){
return;
}
....overload control...returns data
 
any asuggestion? thanks
 
0 Kudos
Message 1 of 2
(5,860 Views)

add additional channels to the same DAQmx task. DAQmx supports multiple channels on a single task (even if those channels have different measurement types). DAQmx does not support parallel tasks that try to reserve/use the same subsystem.

Doug
NI Sound and Vibration
0 Kudos
Message 2 of 2
(5,857 Views)