02-16-2007 07:45 AM
error = DAQmxRegisterEveryNSamplesEvent(m_taskHandle,DAQmx_Val_Acquired_Into_Buffer,NSAMPLES,0,cb,callbackData);
error = DAQmxCfgSampClkTiming(m_taskHandle,
"",10, DAQmx_Val_Rising, DAQmx_Val_ContSamps, NSAMPLES);error = DAQmxRegisterDoneEvent(m_taskHandle,0,DAQDoneCallBack,NULL);
error = DAQmxStartTask(m_taskHandle);
......................
}
I32 WINAPIV cb(TaskHandle taskHandle, I32 everyNsamplesEventType, U32 nSamples,
void *callbackData){
.......................
error = DAQReadAnalogF64(m_taskHandle, -1 , 10, DAQmx_Val_GroupByChannel, data, dataLen, nSamples, NULL);
........................... return 0;}
02-16-2007 08:52 AM
I have encounted new detailes about the problem: If I call DAQCreateAIVoltageChan(...) , everything works fine, if I call DAQAddGlobalChansToTask, call back is called too often.
error = DAQmxCreateTask("ADataAquision",&m_taskHandle);
// I create a global virtual name channel in MAX
DAQAddGlobalChansToTask(m_taskHandle,name); // Call back is called too often
DAQCreateAIVoltageChan(m_taskHandle,"cDAQ1Mod8/ai0","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL); // works just fine
error = DAQmxRegisterEveryNSamplesEvent(m_taskHandle,DAQmx_Val_Acquired_Into_Buffer,NSAMPLES,0,cb,callbackData);
error = DAQmxCfgSampClkTiming(m_taskHandle,
"",10, DAQmx_Val_Rising, DAQmx_Val_ContSamps, NSAMPLES);error = DAQmxRegisterDoneEvent(m_taskHandle,0,DAQDoneCallBack,NULL);
error = DAQmxStartTask(m_taskHandle);
02-20-2007 12:15 AM
Hi Oksana,
Thank you for posting to the NI forums. I haven’t found any documentation on this type of behavior, and I haven’t been able to reproduce it either. Would you mind posting back with an attachment of your code? Also, are you using Visual Studio, and if so, which version?
I’ll continue looking into this problem and post back with my results.
Ed W.
Applications Engineer
National Instruments
02-20-2007 08:07 AM
Hi Edd,
Thank you for looking into my problem. I develop under VS 2005. I don't think the version is a matter. I created a simple win 32 application which reproduces the problem. What I found so far is that the problem exist with the voltage with excitation channel. If I created a normal voltage global virtual channel in MAX (for NI9211 e.g.), everything works as expected.
// PressChWithExcitProblem.cpp : Defines the entry point for the console application.
//
#include
"stdafx.h"#include
"NIDAQmx.h"#include
"windows.h"#define
NSAMPLES 50
int32
_cdecl cb(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData){
int32 read=0, error;
float64 data[1000], sum = 0;
error = DAQmxReadAnalogF64(taskHandle, -1
/*read all*/, 10, DAQmx_Val_GroupByChannel, data, sizeof(data), &read, NULL);printf(
"Tic: %d/t Read:%d\n", GetTickCount(), read); return 0;}
int32
_cdecl DAQDoneCallBack(TaskHandle taskHandle, int32 status, void *callbackData){
DAQmxClearTask(taskHandle);
return 0;}
int
_tmain(int argc, _TCHAR* argv[]){
int error;TaskHandle tHandle;
error = DAQmxCreateTask(
"myTask", &tHandle);// CTL16_PresInlet is a votage with excitation global virtual channel created via MAX
// If you create a simple voltage channel in MAX, and add it instead, everything works as expected
error = DAQmxAddGlobalChansToTask(tHandle,
"CTL16_PresInlet");error = DAQmxRegisterEveryNSamplesEvent(tHandle,DAQmx_Val_Acquired_Into_Buffer,NSAMPLES,0,cb,NULL);
// 10 Hz aqcuisiotion frequency, 50 samples => the call back fnctn shell be called every 5 sec
// but it is called sometimes every tic.
error = DAQmxCfgSampClkTiming(tHandle,
"",10, DAQmx_Val_Rising, DAQmx_Val_ContSamps, NSAMPLES);error = DAQmxRegisterDoneEvent(tHandle,0,DAQDoneCallBack,NULL);
error = DAQmxStartTask(tHandle);
printf(
"Acquiring samples continuously. Press Enter to interrupt\n");getchar();
return 0;}
02-22-2007 08:25 AM
Hi Oksana,
I’ve been able to reproduce this issue in C++ and in LabVIEW, but I’m still trying to find the exact the cause of this behavior. I’ll post back when I have more information.
Also, I noticed that some of the comments in your code indicate that the callbacks worked with a simple voltage channel. Did you mean a strain channel - the 9172 does not support voltage tasks. When I try running the code with a voltage task and the 9172, I don't receive any data back.
Ed W.
Applications Engineer
National Instruments
02-22-2007 09:43 AM
02-23-2007 10:14 AM
Greetings Edd and Kyle,
Thank you for your help. It fully explains the software behavior, which means I shell revise my architecture a bit. To answer the question about the simple voltage channel, I have a copmpact daq with a zoo of chassis, on which I was planning to collect data in a single task.
Thanks again for your time.
Oksana