10-10-2008 11:50 AM
I'm new to NI-DAQ, so hopefully I didn't bring up a common topic.
Using a NI-DAQ 6143 S card I'm sampling 8 voltages simultaneously from a C++ application working with the ANSI C DAQmx drivers. The sampling clock is an external digtial speed encoder pulse train. Thus, it's frequency varies and I'm primarily interested in the voltage at known encoder positions. After 4096 clock edges the task is done. So far no problem.
While the relationship between encoder position and voltages is the top most important thing I have to measure, I also need to know the speed of the motor accurately since it may not be stable during one revolution. What I was able to do is to use ctr0 to measure the half period time of the encoder signal giving me an accurate speed information. So far so good.
Now... I cannot figure out how to synchronize the to measurements. What I would like to do is this:
The Start Trigger starts the acquisition of 4100x8 analog voltages AND also stores the current value of ctr0 (running off the internal 20 MHz clock) in the acquisition buffer on every falling sample clock edge.
Is there a way to add such a "counter read" to my analog input task rather than creating a second tasks I cannot synchronize? It would be fine just to get a "raw"counter value with eachconversion of the analog voltages even without scaling.
The point is that the application software is too slow to read the external Start Trigger signal and then kick off the analog and the counter task. The external trigger must start both measurements else I can't relate the measured values to the exact position of the motor.
Any suggestions are welcome.
10-13-2008 04:23 AM
Dear Slartibartfass,
first, you cannot add such a "counter read" to an analog input task. These have to be two different tasks. Second, as you use two different sample clocks (variable sample clock for AI and internal sample clock for speed information) it is not possible to synchronize these two tasks. You can only start both tasks simultaneously.
Best regards,
Torben
10-30-2008 04:01 PM
TorbenP,
I have a similiar issue and found this thread via a search.
I have a positioning system that I can "read" the position from. Usually via serial coms.
Can you expand on how to start both tasks simultaneously? I hope your answer also helps my problem.
Thank you.
Paul
TorbenP wrote:..."You can only start both tasks simultaneously""
10-31-2008 01:17 AM
Paul W,
what I'm doing now is to start both tasks using external sample clock (and no start trigger on the analog input channels). Then I use a digital output line to "enable" the external sample clock signal. The start of the two tasks is not really synchronous but since they both use the same sample clock input I can synchronize them by waiting for the two tasks to run and then setting a digital output line to send the clock signal to the actual sample clock input pin. The drawback is that this requires some extra external hardware.
10-31-2008 02:50 AM
Hi Paul,
please look at the LabVIEW examples, if you want to know how to synchronize different tasks/functions. These are located at:
NI example finder --> browse tab --> Hardware Input and Output --> DAQmx --> Synchronization --> Multi-Function
Best regards,
Torben