05-12-2008 10:58 AM
05-13-2008 02:59 AM
Dear Losvil,
you can synchronize encoder input and Analog input but the way you describe it seems a bit more tough than the simplest way.
I mean you can provide the same clock to both AI end EncIn, usually you feed the analog input clock as an external clock to the encoder task.
This way you are done, but you'll have one encoder reading for each analog input thus you're going to loose the 1/7 ratio you are looking for.
Otherwise you can use another counter to divide one clock down by a factor of seven. It should work.
You should be able to find an example that explain how to realize the basic kind of synchronization, basically the trick is having a slave task, i.e. the one that recive the clock, that starts before the master task, i.e. the one that feeds the clock, this way the two tasks are HW synchronized.
Best Regards
05-16-2008 09:55 AM
Dear Jon_Snow
I started to modify a sample ContAI-ReadDigChan.c to acquire A/D channel and encoder in the same time.
The code is like
DAQmxErrChk (DAQmxCreateTask("",&AItaskHandle));
DAQmxErrChk (DAQmxCreateAIVoltageChan(AItaskHandle,"Dev1/ai5","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(AItaskHandle,"",1000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,1000));
DAQmxErrChk (GetTerminalNameWithDevPrefix(AItaskHandle,"ai/SampleClock",trigName));
DAQmxErrChk (DAQmxCreateTask("",&DItaskHandle));
DAQmxErrChk (DAQmxCreateCILinEncoderChan( DItaskHandle, "Dev1/ctr1", "", DAQmx_Val_X1, FALSE, 0, DAQmx_Val_AHighBHigh, DAQmx_Val_Ticks, 1, 0, NULL ));
DAQmxErrChk (DAQmxCfgSampClkTiming(DItaskHandle,trigName,1000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,1000));
DAQmxErrChk (DAQmxStartTask(DItaskHandle));
DAQmxErrChk (DAQmxStartTask(AItaskHandle));
but when I read the values with
DAQmxErrChk (DAQmxReadAnalogF64(AItaskHandle,1000,10.0,DAQmx_Val_GroupByChannel,AIdata,1000,&readAI,NULL));
DAQmxErrChk (DAQmxReadCounterU32(DItaskHandle,1000,10.0, DIdata,1000,&readDI,NULL));
the AIdata contains constant value and DIdata contains all 0.
Thanks
losvil
03-27-2013 03:44 AM
Hello,
I'm having the same problem right now.
I tried to synchronize the Encoder with the Analog Input Clock.
But i receive the same result: the AIdata contains measured values, but the DIdata contains all 0.
The last post is almost 5 years ago.
Did you find any solution?