![]() |
Consistent encoder rate
Hi,
Our team is having trouble getting a consistent rate value from one of the optical encoders. The Rate value jumps around a lot, even when we use 1x decoding and choose to average 127 samples. When we made our own rate code based on the encoder's Distance, the variance persisted. It really messes with our PID loop when it tries to keep the speed of the motor consistent. (Note: the jumpiness occurs when the PID loop is not controlling the speed of the motor, so the problem is not caused by the PID controller.) Any idea what the problem could be and how to fix it? Thanks for any advice. |
Re: Consistent encoder rate
Quote:
If you rotate it slowly by hand and read the encoder counts, do you get consistent results for each rev of the shaft? Check to make sure the optical disk is properly mounted to the shaft. |
Re: Consistent encoder rate
We use this. Tomorrow I will make sure the optical disk is properly mounted to the shaft and I will rotate the shaft slowly by hand and read the encoder counts and I'll let you know if I get consistent results for each revolution of the shaft.
|
Re: Consistent encoder rate
Quote:
http://www.youtube.com/watch?v=4hJfzhxZwKw |
Re: Consistent encoder rate
Since I forgot my team is not meeting until next Tuesday, I will check it then.
Averaging the rate further with a moving average gives us a mostly constant speed (+-2%), but the problem is that when the PID loop adjusts the motor speed, it will oscillate the motors because the "moving-averaged" process variable that the PID uses does not accurately reflect the present rate of the motor. Would applying any of the filters described in this thread give us a smoothed rate that more accurately reflects the present speed of the motor? |
Re: Consistent encoder rate
No luck. We have decided to look into testing the magnetic encoder from the KOP on a test motor.
|
Re: Consistent encoder rate
Quote:
|
Re: Consistent encoder rate
Quote:
Quote:
|
Re: Consistent encoder rate
Quote:
|
Re: Consistent encoder rate
I tightened the encoder discs on the axle as shown in the video, and I made sure there wasn't any slipping. When I rotated the encoders by hand, the Distance count was kind of consistent: I'd say about +-10 counts.
I tested an IIR filter of the encoder speed and compared it to a moving average. You can see an example of my results in this video. The problem with the PID loop adjusting the speed is still present. I'm still not sure if there is a good filter or not. |
Re: Consistent encoder rate
Quote:
I don't know about you, but we ran into issues with scratched encoder wheels and damaged encoder wires (there was no visible damage; I assume it was internal from abusive zip-tying, but swapping out the wire resolved the issue). A bit of advice I've been given by my mentor (although I've never personally experienced this problem) is to always separate signal runs from power runs so that the power runs don't induce noise in the signal; if they have to cross, run them at right angles. Ether would be able to elaborate more on this. |
Re: Consistent encoder rate
Quote:
With the optical encoder I use the DSC. Yes, I made sure the encoder wheels were not scratched - I scratched a lot of them when we first started using them last year. :) We did twist the encoder wires with a hand drill to make the wiring look good - maybe that's a problem? Thanks for the ideas. I'll try to use a new, different encoder cable and separate the power and data wires and see if the rate I get is any less noisy. |
Re: Consistent encoder rate
Here are a couple other things to consider:
Quote:
Quote:
Quote:
- 1x or 4x? - Counter class or Encoder class or something else? - sample time? how controlled? measured or assumed? - did your code look like this: read count, subtract previous count, divide by measured elapsed time since previous sample? |
Re: Consistent encoder rate
Quote:
To clarify, I don't mean separating the power and data lines coming from the encoder; I meant separating all 4 encoder lines (+5, A, B, GND) from the power lines going to the motor. Ether, could you comment on how recognizable this effect would be? |
Re: Consistent encoder rate
Quote:
|
Re: Consistent encoder rate
Quote:
1count / (current time - time of last count) the way we helped limit this noise is using the sum of the counts encoder counts / (current time - time of last loop) then reset the encoder. this will give you a much steadier reading. Just try to limit the function to being called one time per loop. For example, only our PID calculates speed, where everything else reads from a variable it stores the speed in after the calculation. Thus ensuring that is only called once every PID loop. |
Re: Consistent encoder rate
Quote:
Quote:
Quote:
1x. Encoder class. I placed code that is like "read count, subtract previous count, divide by measured elapsed time since previous sample" in the 100ms loop in the Periodic Tasks VI, so it's assumed. Indeed, during my work with the magnetic encoder, I found that the actual time does vary. I could try to use a Timed Loop to make the time more consistent. Quote:
|
Re: Consistent encoder rate
Make sure that the shaft is well centered relative to the encoder sensor. We had an encoder problem where the distance was reading correctly, but the rate was varying. The problem turned out to be that the shaft and disk were eccentric relative to the sensor. You could see the disk move up/down/side to side relative to the sensor. After correcting the centering, our readings improved dramatically.
|
Re: Consistent encoder rate
Quote:
|
Re: Consistent encoder rate
Quote:
http://team358.org/files/programming...Everything.PDF |
Re: Consistent encoder rate
Quote:
Quote:
Quote:
|
Re: Consistent encoder rate
Quote:
.Light braiding will work for wire management (you don't want to braid stuff very tightly either), because all you're doing is flexing the wire. In the link you gave, though, there's a lot of tension on that wire - an absolute no-no in a moving application subject to vibration, especially on signal wires. |
Re: Consistent encoder rate
Quote:
|
Re: Consistent encoder rate
Quote:
In simple terms, the advantage to twisting the wires is that voltages induced in the conductors by external, changing magnetic fields (a type of EMI) in accordance with Faraday's Law are made self-cancelling due to the twist. The ideal twist pitch is a function of the characteristics of the shape of the magnetic field. In most instrumentation cable you'll encounter pitches between 1 and 8 twists per inch. In FRC, the major source of changing magnetic fields is the brushed DC motors we use. |
Re: Consistent encoder rate
Quote:
Alex, I am aware that twisting wire is a common practice in industry for the very reason you mention; my position is that the undue stress placed on the wire by twisting it with a hand drill, especially to the extent of the link, is likely to do more damage than good, especially in this particular example. That being said, don't focus too much on the physical aspect; wire twisting could be the issue, but it won't necessarily be the issue. If you can, get some testing done; prepare a bench test (or a test setup on another bot) to see if you can troubleshoot your encoder problem. Use a similar wire setup (twisted wires and all) and see what you can do to isolate your problem. Although conditions won't be exactly the same, you probably will find issues that you didn't even originally notice, and then find a solution before competition. |
Re: Consistent encoder rate
It turns out that inconsistent elapsed time between loops was the main culprit. I fixed the variation in our speed readings with a Timed Loop.
Thanks again for the help. |
| All times are GMT -5. The time now is 20:12. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi