11-18-2016 02:48 PM
I have been successfully using a counter to read out a quadrature encoder syncronously with an external clock. Now I would like to try syncing this to a series of regular start triggers so that I only acquire data when the position sensor is actually being actuated. The goal is to have a trigger start reading out the encoder using the clock, acquire a fixed number of measurements, and then ignore clock edges until the next trigger occurs, at which point the sync should begin again. If I understand correctly, the way to do this is to:
1) Setup the counters using the clock and encoder pins via CreateAngularEncoderChannel and ConfigureSampleClock.
2) Use ArmStartTrigger to set the trigger to arm the acquisition
3) Call a function like ReadMultiSampleDouble or use a callback to read the samples at the end of the acquisition.
Unfortunately, if I set ConfigureSampleClock to FiniteSamples, the counter is reset between calls, when actually I need it to preserve the encoder position between calls, just ignore clock edges. If I set to ContinuousSamples, the counter (if I understand correctly) remains armed and will generate samples independent of subsequent triggers which is not what I want. Is there a way to do a finite acquisition of X samples on each trigger, but continue counting until the next trigger?
11-21-2016 02:56 PM
saratoga
Do you want the counter to continue counting in between the arming triggers, but not display the count until the next trigger?
Applications Engineer
National Instruments
11-22-2016 06:05 PM
I would like it to keep counting, but to ignore any triggers until it is rearmed.
11-23-2016 06:37 AM
I'd use a 2nd counter whose job is to act as an intermittent sample clock for the 1st counter. Your 1st counter can be set for continuous sampling and the task can be left running all the time. Just configure it to use the 2nd counter's output as its sample clock. You can then control when the 2nd counter generates those sample clock pulses through software Start/Stop calls, pause triggering, maybe finite generation (depending on which DAQ board you have).
-Kevin P