Shop OBEX P1 Docs P2 Docs Learn Events
Activity Board Servo on P16 — Parallax Forums

Activity Board Servo on P16

kevorkakevorka Posts: 2
edited 2013-12-25 20:26 in Propeller 1
Servo is Tower Pro SG-5010

Using SimpleIDE with Examples\Devices\Motors\StandardServoPosition.side
It looks like I can set any pin to output servo PWM pulses so I'm using P16 from the example. When I run this code below with the servo connected it freezes after printing servo_set: 16 for the first time.
#include "simpletools.h"                      // Include simpletools header
#include "servo.h"                            // Include servo header


int main()                                    // main function
{
  int retval;
  retval = servo_start();
print("servo_start: %d\n", retval);  


  while(1)
{


retval = servo_set(16, 1400);                         // P16 servo to 0 degrees
print("servo_set: %d\n", retval);  
  pause(3000);                                // ...for 3 seconds
retval = servo_set(16, 1600);                         // P16 servo to 0 degrees
print("servo_set: %d\n", retval);  
  pause(3000);                                // ...for 3 seconds
retval = servo_set(16, 1800);                         // P16 servo to 0 degrees
print("servo_set: %d\n", retval);  
  pause(3000);                                // ...for 3 seconds
}


  servo_stop();                               // Stop servo process
}



If I run it with either the servo disconnected or with the PWR switch to "1", the program runs (as expected) and returns the following:
servo_start: 3
servo_set: 16
servo_set: 1
servo_set: 1
servo_set: 1
servo_set: 1

It also works with the PWR = "2" and the servo connected to P17. The only time it DOESN'T work is when attempting to drive the connected servo.
I assume then that this is a problem of too much current draw from the on board 5V. I'm just running off of USB power. Do I need to use 5 or 6V DC IN to supply the servo. I've already tested the servo with another supply and a pulse gen and it works.
I haven't tried supplying 6VDC IN yet.

Thanks.

Comments

  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-12-24 17:41
    Do I need to use 5 or 6V DC IN to supply the servo
    Yes. I would power with at least 6-9 volt. Servos will draw more than the 5V from a USB port.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-12-24 19:01
    Servos draw too much current to run off the USB.

    Servos will work fine on 5V (even 4.8V) but they need a power source that can handle the current requirements of the servos. When servos start to move, they pull a low of current. If you don't have a good power supply, this spike in current will cause the voltage to drop. The voltage drop will cause the Propeller to reset.

    You can set the jumpers to Vin if you're powering the board with no more the 6V but if you're powering the board with more than 6V you need to set the jumper to 5V. I'm pretty sure the ActivityBot servos can't take voltages higher than 6V. There are some "high voltage" servos around that can use high voltages but the ActivityBot doesn't use the high voltage type.
  • kevorkakevorka Posts: 2
    edited 2013-12-25 20:01
    Thanks for the tips. I plugged in a 6VDC in and retested and the servos worked. I knew I needed a decent supply for the servos.

    I did move the jumper from 5V to VIN. Duane, from your comment, it sounds like I can use regulated 5V from the 6VDC In. I'm just being "lazy" I need to just go RTM and look at the schematic.

    The board I'm using is the Propeller Activity Board
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-12-25 20:26
    kevorka wrote: »
    Duane, from your comment, it sounds like I can use regulated 5V from the 6VDC In.

    Yes, and there's an advantage to using the regulated 5V power on the servos. The Vin will drop as the batteries drain, while the 5V line will stay constant.

    One test many of like to do with our new robots is to get them to drive in a figure 8. When I attempted a figure 8 with my cheap bot, I couldn't get consistent shapes when using raw battery power. It wasn't until I switched to regulated 5V was I able to get my robot to complete a decent looking figure 8.

    I don't have an Activity Board myself but I'm pretty sure the 5V regulator can handle the current the servo would draw.
Sign In or Register to comment.