Ardumower / Sunray

Ardumower Sunray
71 stars 54 forks source link

Odometry: RPM estimation improvements #146

Open ShadedSelf opened 10 months ago

ShadedSelf commented 10 months ago

The problem: RPM is calculated sampling ticks in a given amount of time, 50 ms in this case. This gives aliased data and, in some cases, no data at all, for my 150 ticks per revolution motor at 0.1m/s the ticks per sampling time oscilate between 1 and 0, that can give the PID controller an oscillation of 100% speed to work with, even at higher RPMs the difference can still be 25% between measured and actual speed. This makes the wheels very jittery at low speeds.

Soution: Instead of using ticks per time, use time per tick and take its reciprocal, we have an accurate reprentation of time per tick recording the time that happens between each interrupt. For low tick count motors like mine this makes a world of a difference and the wheels turn A LOT smoother.

I cant test Alfred but the changes to the firmware should basically be the same, I could add that If you want to merge this.