Go Down

Topic: hexapod (Read 1 time) previous topic - next topic

Rowan_Alawi

Hello everyone,
I'm build hexapod robot with 12 servos (rob 10333 medium) from spearkfun, arduino and pololu driver
i connected the driver to two servo and then to the arduino
the driver started to give me error (red led turn on)
so i tried this code:

#include <SoftwareSerial.h>

const int DEFAULT_BAUD = 9600;
const int SERVO_CONTROLLER_RX_PIN = 11; // The SERVO CONTROLLER'S RX PIN.
const int SERVO_CONTROLLER_TX_PIN = 12; // The SERVO CONTROLLER'S TX PIN.

SoftwareSerial ServoController = SoftwareSerial(SERVO_CONTROLLER_RX_PIN, SERVO_CONTROLLER_TX_PIN);

void setup()
{
   ServoController.begin(DEFAULT_BAUD);
   delay(500);
}

void moveServo(int ServoChannel, int target)
{
   //656ms PWM pulse represents a servo angle of 0 degrees.
   //2000ms PWM pulse represents a servo angele of 180 degrees.
   //These values could vary based on the servo you use, check your servo's
   //spec documentation and verify what PWM pulses are needed to move it.

   byte serialBytes[4]; //Create the byte array object that will hold the communication packet.

   target = (map(target, 0, 180, 656, 2000) * 4); //Map the target angle to the corresponding PWM pulse.

   serialBytes[0] = 0x84; // Command byte: Set Target.
   serialBytes[1] = ServoChannel; // First byte holds channel number.
   serialBytes[2] = target & 0x7F; // Second byte holds the lower 7 bits of target.
   serialBytes[3] = (target >> 7) & 0x7F; // Third byte holds the bits 7-13 of target.

   ServoController.write(serialBytes, sizeof(serialBytes)); //Write the byte array to the serial port.
}

void loop()
{
   moveServo(0, 0); //Move the servo on channel 0 to an angle of 0 degrees
 
   delay(2000); //Wait 2000ms
   
    moveServo(0,45);//Move the servo on channel 0 to an angle of 45 degrees

    delay(2000);
   
   moveServo(0,0); //Move the servo on channel 0 to an angle of 0 degrees
 
   delay(2000); //Wait 2000ms
}
still the one servo doesn't move proper, knowing that i powered the driver to power the servo from the arduino 5V
what should i do ??? 

johnwasser


still the one servo doesn't move proper, knowing that i powered the driver to power the servo from the arduino 5V
what should i do ??? 


The Arduino 5V pin can't supply enough power to run a servo.  If you use USB power you can only draw about 400 mA from the +5V pin before the fuse opens.  If you use an external power supply you can only draw about 900 mA before the regulator overheats.  A servo typically takes 1000 mA at 6V.

You should provide an external 6V supply just for the servos.  If your robot is running off a 7.2V battery pack you can try connecting the servos directly to that.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp
See who has no social life: https://forum.arduino.cc/index.php?action=stats :)

TomGeorge

Hi, can  you read the link below please.
It will show  you how to post your sketch using code tags, hich makes it easier to read in your post.s

http://forum.arduino.cc/index.php/topic,148850.0.html

Thanks

Tom..... :)
Everything runs on smoke, let the smoke out, it stops running....

Go Up