-
Out of time(rs)
02/28/2016 at 21:15 • 0 commentsThe 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.
- 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.
- Rearrange the motor wiring so that pin 9 is used for reversing, as a little veer there isn't really that bad.
- 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.
-
Rubber band to the rescue
12/06/2015 at 17:09 • 0 commentsAs I didn't want to keep the servo powered when the tilt bracket isn't used I ran into a small problem. I would detach the servo after tilting the phone but sometimes the mechanical friction of the gears wasn't enough to hold the phone and the bracket in place and they would dip to the lowest position.
This can be helped a bit by waiting for a while before detaching the servo after rotating it, so that the gears aren't in motion anymore when the servo loses control.
But as the medium servo isn't really that powerful even this wasn't enough sometimes. The bracket would still dip. I thought about adding a counterweight on the other side as now all the weight was on the side of the phone. But I didn't really have anything with enough weight in a small package.
So another low-tech solution to this was to pull a rubber band from the top of the tilt bracket down to the robot chassis. It nicely balances the weight of the phone and the servo no longer rotates uncontrollably to the low position.
-
A simple solution to the start-up brownout
12/06/2015 at 17:00 • 0 commentsSince there are a couple of capacitors on the circuit's power rail there's always a bit of residue charge when the battery is disconnected. I noticed that this can be used to alleviate the voltage dip. So the simplest solution to the problem without adding anything extra is: power up, power down, then immediately power up again. And the bluetooth starts without hiccups.
Slightly ugly, but good enough for now.
-
UBEC, why u no power
12/05/2015 at 20:05 • 0 commentsThe UBEC seems to be the culprit for the start-up voltage dip. If the battery is first connected to the UBEC and only after that it itself is connected to the rest of the circuit, everything works ok. So it seems the UBEC needs settle for a moment before it can properly supply the whole circuit. Unfortunately the servo doesn't care for such tardiness and resets immediately.
-
Servo and Bluetooth blues
11/28/2015 at 22:41 • 0 commentsFor some reason when the Arduino is started and the servo resets to its default position the HC-06 fails to start up properly. If the servo is connected after the start-up everything works fine. I guess there's some kind of an interference or drop in power due to the servo and the HC-06 starting up at the same time, even when neither of them are powered from the Arduino. A capacitor between VCC and GND doesn't seem to help.
Switching the servo power on separately with a switch or a transistor should fix the issue if nothing else works.