I use an encoder to maintain the speed of the motor, I measure the speed in (mm / sec), and when adjusting the pid controller, I noticed that the speed of my motor jumps sharply with some periodicity, I think this is noise, to get rid of it you need to change the filter, but I don’t I know which one will be better and how to set it up
Step one: see what the period -is-. If your encoder is of center that will modulate the output signal with a once per rev sine wave. If its way out you may loose the signal entirely.
I, um, have to ask… are you using a PWM output encoder?
What do you mean? “output PWM encoder”
The question is: What is your encoder outputting – is it a quadrature encoder with an ‘A’ channel, a ‘B’ channel and (maybe) an Index channel? Is it analog? Or does it spit out a Pulse Width Modulated (i.e. PWM) signal?
The suggestion is good: if you are getting periodic ‘noise,’ then that suggests a mechanical reason for the noise that you might fix. Commonly, for example, you might get noise at a certain place on the shaft’s rotation.
But also, note that oscillation can be a sign that your P value going into your controller is too high.
Lampreys and SPX encoders can both generate a PWM signal related to 1 revolution.
My encoder is quadrature (has channel A and B), the number per tick is 1464
There are peaks on the graph that are directed downwards, they occur with the same frequency, you can hear from the engine how in a different place it accelerates a little and then stabilizes, my controller is not over-adjusted, so there can be no waves
I use Studica Maverick
The encoder speed appears to have significant quantization and only changes rarely. That doesn’t seem like a very good candidate for filtering.
Is the graph being updated at the same rate as the encoder speed is measured? Can you post the same graph with your motor output on it? Can you post the same type of graph when you bypass your PID code and run the motor at 100%?
Do have a scope or other way to look directly at the A and B signals?
It does look quantized! Are you near either the min or max range of your variable?
The quantization is likely because these data are transmitted over NT at 10hz…
For the OP, add NetworkTableInstance.getDefault().flush()
to teleopPeriodic() to fix this.
I am very upset, I lost a lot of time to solve this problem, the fact is that whoever developed this library for the TitanQuad controller made a very not funny bug that took a lot of my nerves)), they made a method, Encoder.getSpeed, which returns double, but then when I decided to check it with SmartDashboard, I noticed that it outputs the int data type, so my chart looks like this
I use this, it works great
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.