Monday, July 22, 2019

Improving the Battery Life of RD-3D

A week or two ago I blogged about how Making involves a lot of trial and error. Lots of problems come up, work out a solutions, maybe it works, maybe not, back to the drawing board, keep researching, keep trying, keep feeling forward progress and keep hitting new road blocks.

One of the things that was frustrating was that my robot's 9 v. battery would die after only 4 shows or so. I would turn the robot off after each show, and even disconnected the battery each time. If a switch is left on, then I can understand how a battery would die rather quickly, even if the motors and LEDs are not going, the Arduino is still "thinking" and waiting for new code or new inputs to affect the current code. By completely disconnecting the battery I was ensuring that there was nothing that could drain the battery other than his actual performances, and they were much too short to drain a battery after 4 shows.

CLUE #1: His LEDs are still bright even when he can't move. Not surprising since lighting an LED uses nearly no electricity at all while powering a motor uses LOTS of electricity.

CLUE #2: When he was supposed to move you could hear the motor struggling, just unable to actually make the robot move (this is an important clue because it indicated that the battery still had enough power to affect the motor, just not quite enough, it seemed).

CLUE #3: When he would get to the part of his skit where he was supposed to "shake" he always had enough power to do that (this is the most important clue and what finally made me realize the source of the problem).

So him shaking is actually the motor going full blast forward for 1/10th of a second, then going backwards full blast for 1/10th of a second, over and over 17 times (for the record, I recently changed it to 25 times because it gets a good laugh and I thought he might have quite to quickly since 17 shakes is barely 3 seconds).

When I programmed RD-3D to walk I have him move at a slow pace because if he moves too quickly it is easier for him to fall over. So he would move at about 35% of maximum power.

MY THEORY (don't read this part yet if you want to try to figure out what YOU think the problem might have been, because I can tell you that my theory has been tested and demonstrated to be the source of the problem).

I felt like since the robot motor would drive him at FULL power, but not at 35% power then it might be that the battery was getting weak after 4 shows, but not dead. I decided to rewrite the code to have RD-3D move at a higher speed than 35%. Also, I felt like the laws of inertia might be at work a bit, too. I felt if I could jostle RD-3D into moving (like the start of one of his twitches) then the momentum might make him able to move with a lower powered speed.

In other words, I had him start at 100% for 1/4th of a second, then drop to 85% for 1/4th of a second, then drop to 70% for 1/4th of a second, then drop to 55% for 1/4th of a second, then drop to 40% for the last 1.8 seconds. The initial "blast off" is full power, but it is so short in duration that he doesn't actually jerk and you really can't even notice that he's moving faster for the first part of his trip.

So I rewrote the code, uploaded it to his little Arduino brain, and tested it out. I've been testing it for the past week or two using one of my "dead" batteries and that battery has now powered my little "astromech droid" through no fewer than 19 shows! That's 19 AFTER I thought the battery was too dead to work for the show.

No comments: