[Dprglist] My PID problem solved

Murray Altheim murray18 at altheim.com
Thu Jan 28 14:25:05 PST 2021


For anyone who's been following my travails over PID issues, such as
the behaviour of the KR01 where after coming to "rest" the wheels
would continue to jitter, or the bit of shudder when starting back up
clockwise after rotating counter-clockwise, well... I finally figured
it out.

Yes, it was of course in my Python code, as it's all my code. This was
never hardware. Mea culpa, mea culpa semper.

It turns out the problem wasn't in my PID controller proper, it was in
the motor and motor encoder code. I was calculating the motor velocity
based on the pulses coming from the encoders, based on a callback from
the encoder handler class (actually named Decoder since that's what it
does). I.e., every time the Decoder class receives a pulse from the
motor encoders it executes the callback function on the Motor class.
Perhaps the more observant among you can see where this was heading. I

Once the motors have come to a halt, the encoders stop triggering the
callback, so the calculation of motor velocity stops happening, and the
return value for velocity() from the Motor class continues to return
the last value that was set by the callback. This of course seems
perfectly clear in hindsight.

Now that I've found this I can fix it. The mystery is finally over.


Murray Altheim <murray18 at altheim dot com>                       = =  ===
http://www.altheim.com/murray/                                     ===  ===
                                                                    = =  ===
     In the evening
     The rice leaves in the garden
     Rustle in the autumn wind
     That blows through my reed hut.
            -- Minamoto no Tsunenobu

More information about the DPRGlist mailing list