Pages: [1]   Go Down
Author Topic: Help with 19 servos and Mega  (Read 1195 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 18
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley
Logged

Ohio
Offline Offline
Full Member
***
Karma: 0
Posts: 227
Arduino Hexapod
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
  for (uint8_t i=0;i<18;i++)
    ServoArray[i].attach(22+i, 700, 2300);
Logged

Ohio
Offline Offline
Full Member
***
Karma: 0
Posts: 227
Arduino Hexapod
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 18
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Thanks again
Logged

Belgium
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged


0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9470
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: August 02, 2011, 07:30:21 pm by zoomkat » Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Belgium
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged


London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6250
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Belgium
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged


London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6250
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Chris,

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

Pages: [1]   Go Up
Jump to: