Hello community,
i have a common problem to solve and i'm stuck with it.
Problem:
I have a analog voltage signal which i want to sample synchronized to a rotary encoder. I have these signals:
A _|---|__|---|__|---|__|---|__|---|__ .... _|---|__|---|__|---|__|---|__|---|__ ....10240 pulses
B |__|---|__|---|__|---|__|---|__|---|__ .... |__|---|__|---|__|---|__|---|__|---|__ 10240 pulses
Z ___________|---|_____________....___________|---|______________ zero index
Analog Signal ............
The rotary Encoder gives me 20480 pulses for one rotation.
When i start my measurement, i want to wait till the zero-index comes. Then i want to aquire for example 20500 samples (voltage and angle), which is a little bit more than one rotation. I also need the number of pulses counted from the first occurence of the zero-index-pulse (Z) to the next. If the counter counts correctly 20480 pulses should be counted. Otherwise there would be dirt on the encoder and i can't use the data.
What i achived so far:
Sample the analog signal with 20500 samples and use the zero-index as start-trigger. Therefore i "xor"ed the signal A and B, to have my 20480 pulses.
DAQmxCreateTask ("", &taskHandle);
DAQmxCreateAIVoltageChan (taskHandle, "/Dev1/ai0", "", DAQmx_Val_RSE, -1.0, 1.0, DAQmx_Val_Volts, NULL);
DAQmxRegisterDoneEvent (taskHandle, 0, DoneAquisition, NULL);
DAQmxCfgSampClkTiming (taskHandle, "/Dev1/pfi0", 5000, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, 20500); // pulse train
DAQmxCfgDigEdgeStartTrig (taskHandle, "/Dev1/pfi1", DAQmx_Val_Rising); // zero-index
DAQmxStartTask (taskHandle);
In the "DoneAquisition" Callback i save my sampled data and clean up the task.
This works so far, but now i'm stuck.
Question:
How can i sample 20500 samples with voltage and the corresponding angle and how can i check if 20480 pulses are counted for one rotation?
Thanks Christian