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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using a Counter to error-check External Sample Clock

Hi all,

I am newish to labview and am working on a data acquisition project. I've managed to get the basics under control, but here's my situation and question...

-- I am using the S-6123 card to capture and record data on two or more AI channels.  I am using a rotary encoder to generate a pulsetrain that I am using via PFI0 as the sample clock for recording the AI data.
-- This rotary encoder gives 720 pulses per revolution and an index pulse once per revolution.
-- In my data acquisition, I am pulling 1440 samples at a time with the DAQmx "read" function.

I have been experimenting with counters and can get the RPM out of the pulse trains well enough, however I was wondering...

Is there some way to use the 2 counters on the card (and signal routing of the two pulse trains) to double-check that the 1440 samples I take correspond to two exact revolutions, and that I'm not getting ahead of or behind the rotation of the encoder due to missing clock pulses or reading false pulses. I have a couple of ideas on how to attempt to do it, but to me they don't seem very reliable or efficient, so I thought I'd put it to the experts to point out of there is a more obvious way of doing it.

I have attached a pdf of the specifications of the encoder family, the pulses that will be output are on the right hand side of page 2.

With many thanks in advance,
Peter


Message Edited by mumech on 07-22-2008 01:05 AM
0 Kudos
Message 1 of 4
(2,152 Views)
Hi mumech,
 
I'm not sure if I understand your question, but I believe that you can use a single counter to verify the position of the your rotary encoder by creating an angular position task. Then by comparing the number of samples you acquired with the angular position of your encoder, you should be able to figure out if you are getting ahead or falling behind the rotation of the encoder. To create this task, you can view one of our many DAQmx shipping examples in LabVIEW. You can view these in your Example Finder by accessing it under Help  Find Examples.... The example we are particularly interested in would be under Hardware Input and Output  DAQmx » Counter Measurements » Position » Measure Angular Position.vi.
 
I hope this answers our question. Please do not hesitate to post again if I was unclear or you have more questions.
S_Hong
National Instruments
Applications Engineer
0 Kudos
Message 2 of 4
(2,125 Views)
Thanks very much for your reply. I had come across the use of counters with angular encoders but hadn't quite thought of the concept in this way.

I will have to experiment a bit over the next day or to see what this is capable of, the examples seem quite comprehensive, however I'm not sure if I will run into issues due to the fact that I am using the rotary encoder as the sample clock for my analogue data.

Would I indeed be able to compare these values (ideally check the position of the encoder after each set of data acquisition) without a "third party" sample clock common to both? (which isn't appropriate for this application)

If I was only running at low speeds, I might be able to implement this by simply checking the position of the encoder after each read of the data. However, at higher speeds there might be synchronization issues due to the buffering of the analogue data. So when getting the measurement from the encoder counter chances are the analogue data was acquired at an earlier time.

I know I haven't worded this very well, but how might I synchronise this error checking method?
0 Kudos
Message 3 of 4
(2,121 Views)

Hi mumech,

I believe that the best method for keeping track of your angular position while acquiring data is to periodically compare the number of acquired data points with your measured angular position. You can do this by running both tasks in parallel and having both Reads in the same while loop. In order to implement this, you will have to accumulate your data in an array and make sure that you empty the buffer at every read by setting the number of samples to read to -1. It's always possible that you might get into a race condition depending on how fast your encoder is working. So the safest method would be to simply make this comparison once the task has finished.

S_Hong
National Instruments
Applications Engineer
0 Kudos
Message 4 of 4
(2,097 Views)