[Dprglist] My PID problem solved

David Anderson davida at smu.edu
Thu Jan 28 14:43:39 PST 2021


Murray,

A quick-and-dirty test to see if the encoders are behaving properly.  I 
do this when first set up, and then whenever any changes are made.

1.  Keep a running total number of encoder counts on each wheel (as 
opposed to the velocity) and print those totals in realtime to your 
nifty onboard display.  You should probably have this as a function you 
can run anytime needed.

2.  Set those totals to zero and set the robot up on blocks so that you 
can rotate the wheel by hand, exactly one revolution.  Note the total 
number of counts.  Now rotate the opposite direction by hand exactly one 
revolution and be sure the counts return to 0.

3.  Do this a couple of times for each wheel to be sure you are getting 
the same numbers repeatably.

I've found this simple test can uncover a lot of potential problems.


cheers!
David



On 1/28/21 4:25 PM, Murray Altheim via DPRGlist wrote:
>
> Hi,
>
> 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
> hadn't.
>
> 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
>
> ........................................................................... 
>
> 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
>
> _______________________________________________
> DPRGlist mailing list
> DPRGlist at lists.dprg.org
> http://lists.dprg.org/listinfo.cgi/dprglist-dprg.org
>



More information about the DPRGlist mailing list