This post is about how I solved a problem with servos browning out my power supply.

This post has been sitting in my queue for over a year. I have not had time to work on the hexapod in a while, but I moved my site to a different host and decided I should take the opportunity to clean up this pending item while I can still remember what it is about.

When I was developing and testing the hexapod servo code, when the robot would start up or start moving, sometimes the controller board would reset. It was especially noticeable when the servos were under load (when the robot is walking on a floor and not just sitting on my bench). I guessed pretty quick that I had a power supply problem but was not sure why. I designed the power supply to deliver 5A which I thought should be plenty for these servos.

I started looking at the power supply with respect to the servo operation and what I found is that the power supply was dropping coincident with the control pulse to the servos.

Scope photo
Power Supply Brownout

In the scope photo above, the top trace is the 5V supply from the regulator. You can see that it dips significantly every 20 ms, and occassionally goes below 4.4V which triggers the microcontroller brownout reset.

I am using a hardware timer for each servo. I started all the servos at the same time, and so the control pulse occurs at the same time for each servo. The supply load of each servo is obviously not even, it apparently has a large load right after the end of the control pulse. I'm sure others who are used to using servos are aware of this, but it was a learning experience for me.

To attempt to solve this problem I decided to try and space out the servo pulses. I thought that if they were spread out during the 20 ms period and not occurring all at once, I would probably not have the power brownout.

The solution was pretty easy. I initialize the hardware timers from a loop in the main init code. I simply added a delay between calls to init the servos:

for(int servo = 0; servo < NUM_SERVOS; servo++)
{
    hServo[servo] = Servo_Config(servoInfo[servo].timer, servoInfo[servo].half);
    if(hServo[servo] == 0)
    {
        UARTprintf("error config servo %d\n", servo);
        return 0;
    }
    Servo_SetMotionParameters(hServo[servo], 180);
    SysCtlDelay(22000); // <----- ********
}

The call to Servo_Config()(click for API) causes the hardware timers to be initialized, and the time they are initialized determines where the "zero" point is for the timer PWM period. The reason you see a magic number is because I just experimented adjusting the delay until the pulses were spaced out the way I wanted. (Servo_Config() is from this library)

The photo below shows the end result. It shows 3 servo control signals and you can see how they are now spaced out during the 20 ms control period.

Scope photo
Servo pulses spread in time

The scope photo shows 3 pulses but you can see that there is enough time in the 20 ms period that all 12 can be evenly distributed. As the pulse widths get longer then the pulses could overlap some but there will never be more that two at a time. I should have taken a scope shot showing the power supply as well to see if the voltage dips are gone or just reduced. I'm not sure why I didn't but I dont have any scope photo to show that.

Once I made this change, I no longer had the problem with the board resetting so hopefully that is a permanent fix.


Comments

Permalink

kroesche

Posted on Sun 19 October 2014

I am experimenting with static comments. Since this site is static generated site, the commenting options are limited. I don't want to use a third party option like disqus for several reasons. Since the comments are emailed to me, I may end up getting too much email spam in which case I will have to turn them off.

Add a comment
You can use markdown in your comment. No personal information is collected or retained. Your email address will not be posted. This site uses static comments via email. That means there is no third party tracking you. I will get an email from you and I will see whatever email address you sent it from, which I don't care about. The email contents will then be converted to a static comment and appear here.