Go Down

Topic: Help with 19 servos and Mega (Read 1 time) previous topic - next topic

westony

Can anybody tell me how i am supposed to control 19 servos with Arduino Mega, when i have only 11 PWMs ?
I am planing to make hexapod with 19 servors

thanks in advanced :)

vinceherman

I run 18 servos on my Hexapod

You don't use PWM output.  That is for driving DC motors and LEDs.
Just grab the digital pins and attach the servos.

Code: [Select]
  for (uint8_t i=0;i<18;i++)
    ServoArray[i].attach(22+i, 700, 2300);

vinceherman

Oh, common issues.  Don't try to power them from the Arduino.  Use an external power source.  Connect the grounds.

Here are some links to my previous posts on the subject.
http://arduino.cc/forum/index.php/topic,7961.0.html
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1265626147/6#6

westony

So, do i read clear that PWMs are for DC motors ? and because mine are AC i use digital pins ?


Thanks again

ElectricalStorm

Don't want to hijack the topic, but just curious. Why is it better to use the digital outputs instead of the PWM?

Can you perhaps show me some more code to use the digital outputs for servo's using a button for an input?

Thanks,
Chris
U2 Rules

http://www.r2belgium.tk

zoomkat

#5
Aug 03, 2011, 02:26 am Last Edit: Aug 03, 2011, 02:30 am by zoomkat Reason: 1
Usually a servo library is used that provides for the PPM control signals that standard hobby servos use.

edit: a simple write up on hobby servos.

http://www.lynxmotion.com/images/html/servo01.htm
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

ElectricalStorm

Quote
Usually a servo library is used that provides for the PPM control signals that standard hobby servos use.


I agree, i understand PWM and servo's. But I was wondering why vinceherman doesn't use the PWM but the digital out for driving his servos.

Quote
You don't use PWM output.  That is for driving DC motors and LEDs.
Just grab the digital pins and attach the servos.


It would be nice to see some more code to achieve that.

Chris
U2 Rules

http://www.r2belgium.tk

mem


Quote
Usually a servo library is used that provides for the PPM control signals that standard hobby servos use.


I agree, i understand PWM and servo's. But I was wondering why vinceherman doesn't use the PWM but the digital out for driving his servos.

Quote
You don't use PWM output.  That is for driving DC motors and LEDs.
Just grab the digital pins and attach the servos.


It would be nice to see some more code to achieve that.

Chris


The Arduino servo library uses hardware timers to control servo pulses to enable many more servos to be controlled than if the hardware PWM capability was used. The source code for the Servo library is in the Libraries > Servo directory of the arduino distribution.

ElectricalStorm

Thanks mem,

I completely misinterpreted the PWM/Servo part in Arduino.

I thought the servo commands (Servo myservo, myservo.attach(2), myservo.write (170)) could only be used on the PWM outputs (2 to 13 on the Mega). Now I see they can be used on any digial output (22 to 53).

My mistake,
Chris
U2 Rules

http://www.r2belgium.tk

mem

Chris,

You can use any of the outputs, including any of the unused PWM or analog input pins.

Go Up