Optical encoder selection for a motor control project.
Optical encoder selection for a motor control project.
(OP)
I have a motor control project. In this project, i need to measure the speed. To measure the speed, i planned to use a 100ppr incremental encoder. With the ucontroller's ability it can count 400 pulses per revolution.(It counts decreasing and increasing edges of phase A and phase B) This means that, in order to measure the speed with 1 rpm resolution, i have to wait at least 150ms. This is a very long time i think, for a speed feedback in a control loop. If we decrease resolution, obtaining the speed takes less time. But resolution isn't enough for those cases. I try to implement a stepped algorithm for obtaining speed. (From low resolution to high resolution) It sometimes gives good results but sometimes the calculated speed deviates from the real speed largely for a very little time (like a spike). I'm hearing that 100ppr suffices for most cases. If so, how should be the way that i follow? Or what kind of technique should i use to obtain the speed? Please, help me.





RE: Optical encoder selection for a motor control project.
If you need position information then that's different and you will need A/B encoders.
You have never said what speed you are trying to measure...
RE: Optical encoder selection for a motor control project.
RE: Optical encoder selection for a motor control project.
If you have a high resolution timer in your system, you can implement reciprocal speed measurement. It counts time between edges instead of counting number of pulses/time unit. Reciprocal speed measurement is what is used in drives that have high precision and fast response. It can be adapted to various needs and can be made "constant precision/constant period" by adjusting number of edges to actual speed. I have written about encoders in general in h
There is also a presentation of the SKF Sensor Bearing (which is an encoder in a ball bearing) on http:
Gunnar Englund
www.gke.org
RE: Optical encoder selection for a motor control project.
High resolution encoders are relatively inexpensive today (see BEI, Heidenhain, EPC, etc.) 1000-2000 line encoders usually cost no more than 100 line encoders in the same Model Number. I routinely use 5000 line uninterpolated encoders and 25,000 line interpolated units.
The best way to do velocity estimation is called "Delta P/Delta T." There are two counters, one to count encoder pulses and the other to count time with a high frequency clock (usually meaning two counter/timer registers in a processor). You start the timmer on an encoder edge and a after a fixed delay (to accumulate pulses in the "Position Register), you wait for the next encoder edge to stop the timer. Then calculate Delta P/Delta T. The Velocity Estimation accuracy is now determined by the timer clock frequency.
RE: Optical encoder selection for a motor control project.
RE: Optical encoder selection for a motor control project.
This simple method will have very little phase lag from delays and very little quantization noise, even with a 100ppr encoder. At 3000 rpm (50 rps, 5000 lines/sec, 20000 edges/sec) a 10 MHz timer would be accurate to one part in 5000 -- less than 1 rpm, with a delay of less than 0.1 msec in the measurement. At lower speeds, the resolution is proportionally better, but the delay is proportionally worse (but still very small for this type of application). If it's a pure velocity-control application, you wouldn't even need a counter, and you might be better off without the "times-4" decoding that generates a count on every edge.
RE: Optical encoder selection for a motor control project.
RE: Optical encoder selection for a motor control project.
Possibly you may want to treat this as a sort of positioning application with proportional plus derivative control. At your control intervals, you latch both your edge-counter value, and your most recent time-between-edges value. You compare your counter value to your command-counter value that you are incrementing by your desired speed (keep lots of fractional resolution in your command counter value to avoid integration errors). Multiply this difference by a proportional-gain term to compute a corrective output term.
Next, take your actual velocity value as derived from your timer and subtract it from your command velocity (which is just your increment to command position). You will need a scaling term to make these two values have the same units. Multiply the difference by a derivative gain term and add the result to the proportional corrective term.
By closing a position loop as well as a velocity loop, you are also guaranteeing zero steady-state error in velocity.
Curt Wilson
RE: Optical encoder selection for a motor control project.
Good to see you here. You are, of course, exactly correct in what you say. In my old age, I like to teach and I believe that Delta P/Delta T velocity estimation is often not mentioned in most control classes. The hardware to do it is implemented in both TI and AD Motion Control DSP products. And as you well know, having a clean position derivative (velocity estimation) is key to feedback control.
On encoder resolution I (roughly) quote you; "My old Professors would be appalled, but sometimes the solution is to throw resolution and speed at the problem."