From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Arm a counter for a finite number of samples?

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?  

0 Kudos
Message 1 of 4
(3,419 Views)

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

0 Kudos
Message 2 of 4
(3,393 Views)

I would like it to keep counting, but to ignore any triggers until it is rearmed.  

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

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

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 4 of 4
(3,380 Views)