Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

sincronization encoder a/d

Hello,
 
I'm newer with NI products
I'm evaluating NI PCI 6220
Is it possible to synchronize the A/D channels reading with the encoder pulse (i.e. 1 A/D channel reading every 7 encoder pulses)
I'm using VC 6 and VB 6 .
 
Thanks.
losvil
0 Kudos
Message 1 of 4
(4,274 Views)

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

 

FiloP
It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong.
Richard P. Feynman
0 Kudos
Message 2 of 4
(4,268 Views)

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

0 Kudos
Message 3 of 4
(4,239 Views)

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?

0 Kudos
Message 4 of 4
(3,431 Views)