I have 12 servos connected on mega with no problem. However, when I try to add up to 14 or 16 servos, at least 2 of servos are not working. I am not sure if it only support certain amount of servo or something?
This library uses a 16 bit timer for each group of 12 servos so PWM output with analogWrite() for pins associated with these timers are disabled when the first servo is attached to the timer. For example on a standard Arduino board, Timer1 is used, so once you attach a servo, analogWrite on pins 9 and 10 are disabled.
Here is a table of PWM pin usage on the Mega board:
Servos
analogWrite Pins
Timers used
1 - 12
not pins 44,45,46
Timer 5
13 - 24
not pins 11,12,44,45,46
Timers 1 & 5
24 - 36
not pins 6,7,8,11,12,44,45,46
Timers 1,4 & 5
37 - 48
not pins 2,3,5,6,7,8,11,12,44,45,46
Timers 1,3,4 & 5
seems pretty explicit about not using certain pins depending on how many servos you run. To run 16, it will use timers 1&5 and you can’t use pins 11, 12, 44, 45 or 46. My guess is that you might have servos on 11 and 12 that you need to relocate to other pins when you go past 12 servos.
Hum… Which means when I use up to 16 I can’t use pin 11,12,4,45,46. Yeah I did use 11 & 12. which might cause the problem. Gonna try again tonight! Thanks for point it out~
Oh yeah, what about power? Are you using an external power source for the servos’ 5v (or 6v). I suspect VCC would have dried up well before a dozen servos, but I figured I should ask.
It was acting funny. I have servo1~servo12 connected with pin2~7 and pin14~19; this setting works perfectly. But when I tried to add servo13,14 to pin 20,21; Servo13 works but is 14 not working, also the original Servo7 which connect to pin2 is not working but with the power to remain it’s own position thou. I have no clue why it act like that.
Thanks for your inpot buddy~ I have been search on net whole day and only found one guy has same problem like me with no solution. Some people suggest move to SSC-32 but I don’t wanna give up that early yet.
I would be tempted to move them all into the upper range of pins, like between 24 & 40. You may find additional hardware is needed though. The Arduino has a lot of upside in having so much in the library that takes care of details with the processor, but the way its resources (particularly timers) are allocated makes it easy for conflicts to occur. Going to a Mega sidesteps a lot of them (soft serial on the base models limits you to 2 servos) and often the high pins have the least trouble.
I have give up Arduino Mega for now since it’s not working properly no matter which method I tried and end up using “Renbotics ServoShield” to operate it.