Close

Out of time(rs)

A project log for Kaukomieli - a telepresence bot

A telepresence robot on the cheap

Harri Ohra-ahoHarri Ohra-aho 02/28/2016 at 21:150 Comments

The robot is always veering a bit to the left, probably due to the motors being a bit unbalanced and/or crooked wheels. The logical way to remedy this would be to lower the PWM value on the right side motors so they'll run a bit slower.

But if I reduced the PWM value below 255 the motors stopped running altogether. The reason for this is found in the PWM pins used and the amount of available timers on the Pro Micro. The board has PWM capability on five pins; 3, 5, 6, 9 and 10. Timers are needed for PWM and timer number one is used by the servo library. Pin 9 currently used for controlling the forward rotation of the right side motors. Looking at the timer / pin definitions for the Pro Micro reveals this:

TIMER0B,/* 3 */

TIMER3A,/* 5 */

TIMER4D,/* 6 */

TIMER1A,/* 9 */

TIMER1B,/* 10 */

Left side motors run ok with full PWM control in both directions since they're controlled by pins 3 and 5 with no timer conflicts. Right side backward rotation on pin 6 is also ok since it has no timer problems either. But pin number 9 needs the same timer 1 as the servo library.

This causes all PWM values below 255 to effectively mean zero in pin 9. Moving to the last PWM pin number 10 wouldn't help either as it's also dependent on timer 1.

There's a couple of possible solutions.

  1. Switch from the servo library to the old PWM servo library. It should eliminate the need for the timer. The servo needs to be connected to pin 9 or 10 though.
  2. Rearrange the motor wiring so that pin 9 is used for reversing, as a little veer there isn't really that bad.
  3. But the best option should be to apply a bit of PWM on the reverse pin of the right side when moving forward. That should lower the power output suitably.

Discussions