06-03-2009 07:28 AM
Hi friends
I am trying to acquire angular position and velocity from three encoders on a Real-Time Desktop PC system.Specifically I need to measure position from one and velocity from the other two. The one encoder position is 1000 pulses per cycle (this is the one I need to measure position on). The other two encoders are emulated encoders with a precision of 16384 pulses per cycle (ridiculous right?). After searching on NI.com I decided to use the example Measure Angular Position (buffered) of Three Encoders as a starting point. I was planning on acquiring at least 100 samples at a high frequency and then applying the dx/dt vi on the two measurements where I need velocity.
I have already figured out that I need to set the Data Transfer Mechanism to Interrupts because the 6601 only has 1 highspeed DMA. I can get the application to run (somewhat stablely) only with the following timing settings 10000Hz, 10 Samples. Because the two encoders that I need to measure velocity from have such a high precision I need to sample at a higher rate and be able to acquire more samples. However when I change the rate or number of samples I get one of two errors. Error (-200279) that says previous samples are no longer available, or the error (-200284) requested number of samples are not ready. I decided to use a property node to inspect the input buffer size and surpringly it stays at a value of 10,000 no matter what I change the sampling frequency to.
I have reviewed the manual for the 660x devices and on page 2-8 there is a table specifying the buffer size for different sampling frequencies. I am not getting any change in input buffer size when I try the values in the table. What am I overlooking here?
My second problem is noise. When my system is fully turned on there is enough noise on the encoder signal lines to cause false counting. I have read the forum post on debouncing filters and quickly tried implementing but it didn't seem to make a difference. Anybody else have experience using thise feature with measuring angular position.
Any feedback is appreciated. I am just shooting in the into the wind at this point.
Any opinions/suggestions on trying to meet the measurement requirements with a different approach is welcomed also.
06-03-2009 07:38 AM
Okay let me add a couple more numbers to my previous post.
The emulated encoders are 16384 pulses/cycle (A).
My maximum motor speed is 8765 rpm (or approximately 146 revs per second (B) )
Multiplying A and B together the pulses per second at maximum motor speed is 2392064.
With my understanding, I would need to sample at least this rate correct?
Is this even possible with the pci-6601?
06-04-2009 01:08 PM
Hi spsuamin,
The counter actually has an on-board, 32-bit count register that is updated based off of the signal you are measuring. This would occur regardless of the rate that you are sampling. When performing a buffered counter measurement, you are sampling this count register based off of the sample clock. The goal is to get the a plot of the count value as it changes with time, you will not necessary sample every single time the count register updates.
Counting the 2.39 MHz signal should not be a problem, but you definitely would not be able to sample the count register at this rate. Page 2-8 in the manual which you mentioned earlier lists the maximum transfer rates achievable.
A bit of an explanation of the errors you are receiving:
It sounds like the issues that are coming up may be related to the timing of the Acquisition Loop in relation to the hardware. Typically for buffered acquisitions you do not need timing in your loop since DAQmx Read will regulate the loop rate for you. If you need any further help troubleshooting, I would post your code if possible so we can take a look.
For the noise problem, you should be able to use the onboard filters like you mentioned. Chapter 3 of the 660x manual describes the filters and how they are implemented, so I would read through this to get an understanding of how the filters work and how they might be useful in your application. Since you are reading up to a 2.39 MHz square wave, you would probably have to go with the 100 ns filter setting to make sure the signal itself is passed through. This might not be adequate to filter out noise when the encoder is generating lower frequency signals. I would measure the encoder outputs on a scope if possible to help characterize the signal characteristics and better understand what might be necessary to fix the noise problem.
-John