09-17-2010 11:34 AM
I'm new to the NI product line. I'm using a pcie-6321 card and have Measurement Studio. I have the card working and have been successful in creating the desired analog outputs I need using C#.
I am struggling with how to code a task that captures the total counts over a predefined period of time from 2 linear position encoders (gated measurement). I ultimately need to determine total counts and period to calculate displacement and average frequency of each encoder.
Use of hardware based timing is preferred, but I can make software based timing work using the QueryPerformanceFrequency API in Windows.
I've looked at the supplied samples, but nothing at this point is clear about how to initiate the counts and block until time is up.
Thanks
--Craig
09-20-2010 01:32 PM
Hi Craig,
I will explain the basic architecture behind creating a Counter Input Linear Encoder task that you are looking to do and give you one option to think about when coding the application.
You can initially set up the task to the inital position, distance per pulse, encoding type, and z indexing with the DAQmxCreateCILinEncoderChan task. You will need one task per encoder when you set this up in code. You can set up the timing to be an external clock or another clock generated by a counter on the board. This will create a buffered linear encoder task. When you read off of the board, you will read the position of the encoder based on the pulses detected. Controlling the measurement period will be a function of the sample clock controlling the buffered task. You can use the frequency of the sample clock and the displacement read back to calculate the frequency of the counts if needed.