LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

countinuous synchronized counter read

I am trying to measure voltage and monitor two angular encoders at the same time.  I would like the data stream to consist of my analog voltage and two additional channels that show angular position of the encoders at each sample point.  From this data set I would be able to calculate velocity and acceleration of the two encoders and plot it relative to the measured analog voltage.
 
I am using a USB 6251 M-series card and, as far as I can tell, there is no way to do a 'continuous' read of encoder values.  If I sample analog voltage at 1kHz (and I want to know the position of the encoder for each sample), I have to re-read the counter values in a timed loop with a 1ms period.  This seems like a really inefficient way to do an acquisition and, since the value doesn't come back with any kind of timestamp, I have no way to know if the counter position is really synchronized with the analog input.
 
Thanks in advance!
0 Kudos
Message 1 of 5
(3,355 Views)

Hello Estern,

Thanks for contacting National Instruments. 

It is possible to do a continuous read from an encoder.  This method is similar to buffered event counting.  The shipping example Meas Angular Position-Buffered-Cont-Ext Clk shows how to use an external sample clock to take readings from an angular encoder at regular intervals.  If you are in LabVIEW, you can select Help->Find Examples to navigate to the NI Example Finder.  The example can be found under the path: Hardware Input and Output -> DAQmx -> Counter Measurements -> Position. 

If you modify this example, you can specify an analog input task to run in parallel to the counter task.  You can also specify a start trigger for the encoder task so that the encoder task and the AI task begin at the same time.  The sample clock source for the encoder task can then be specified as analog input sample clock pin.  The following screenshot shows the basics of setting this task up. 

There are numerous support resources for programming with DAQmx.  Getting started with DAQmx and Learn 10 Functions in NI-DAQmx and Handle 80 Percent of Your Data Acquisition Applications are all great places for getting started. 

Please post back if you have any questions or concerns. 

Message Edited by BrowningG on 10-17-2007 07:37 PM

Regards,
Browning G
FlexRIO R&D
0 Kudos
Message 2 of 5
(3,338 Views)
Thank you for the example.  The only problem I had was using the trigger source property node.  I get an error message that says the trigger source property is not available for my device.  I assume this is because I'm using a USB-6251.  Without that node, no problems.
0 Kudos
Message 3 of 5
(3,310 Views)

FYI -- the reason things work for you without the trigger node is that the error in/outs were routed to enforce correct execution sequence via dataflow.  Specifically, dataflow requires your counter task to start before the AI task.  However, because the counter task borrows its sample clock from the AI task, it cannot take any samples until the AI task also starts.  Hooray for dataflow!

Subtle point: during the few odd msec between the two task starts, the counter task will be "armed" and any motion of the encoder will change the hardware count register.  You just won't sample and store anything until the AI task starts generating sample clock signals.  If your first buffered count value is non-zero, this is probably the reason why.

The "Arm Start" trigger illustrated in the screenshot can be used to counteract this.  With an "Arm Start" trigger, the hardware count register won't start updating as soon as you call DAQmx Start.  It will only start after receiving the configured Arm Start trigger signal.

Though I haven't used a USB-based M-series device, I would expect the "arm start" trigger to be supported there.  However, I think you may need to wire at least one additional trigger property, the one that defines the arm start "trigger type" as "digital edge".   Also, the trigger source would need to be changed for your particular example -- the specified AI trigger signal doesn't exist in your untriggered AI task.   Have a look at this screenshot for another example of setting up the Arm Start trigger.

-Kevin P.

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 4 of 5
(3,296 Views)

Hello Estern,

There is a difference between a Start Trigger and an Arm Start Trigger.  An Arm Start Trigger will arm the counter, while a Start Trigger will allow the counter operation to begin.  Without a Start Trigger, an Arm Start Trigger behaves the same as a Start Trigger (it will both arm and start the counter task).  It is important to note that a Start Trigger is only supported in single pulse, finite pulse train, and continuous pulse train generation counter tasks.  In all other counter tasks (such as a count edges task) you can only use an Arm Start Trigger. 

Regards,
Browning G
FlexRIO R&D
0 Kudos
Message 5 of 5
(3,272 Views)