25 servos, will it work?

Hi:

I need to control 25 servos, each with its push button/switch (button pressed, servo to one side, button released, servo to the other side). Of course I will use a Mega that comes with 50+digital pins.

I know I must power the servos with an external 5V power source. But will the Mega handle this?

It will have to send the (PCM) code for each servo, and at the same time have 25 pins as INPUT_PULLUP.

Some guys warn about noise with so many servos.

I need to make sure it will work before investing money and time in the project.

Thanks.

Yes, it will work. Go spend that time and money.

Some guys warn about noise with so many servos.

Ear defenders will sort that out.

Thanks guys!

Those servos will control switches and mecanical uncouplers in a HO model railroad layout.

Regards, R.

INTP:
Yes, it will work. Go spend that time and money.

Whoa, wait a sec.

It’s possible, but not that simple. You need to PWM a signal to EACH servo. Last time I checked, the Mega doesn’t have 25 PWM pins. You will have to buy a PWM shield or use software PWM on several digital pins to make up the difference in available PWM pins.

Arduino servo class works just fine on non-PWM pins

INTP: Arduino servo class works just fine on non-PWM pins

Really? So the servo class will PWM on regular digital pins?

Power_Broker:
Really? So the servo class will PWM on regular digital pins?

yes.
Check the documentation.

Nah, don't bother reading the documentation. Just trust me. :)

Those servos will control switches and mecanical uncouplers in a HO model railroad layout.

A servo might not be the best solution... Have you researched how it's normally done? Or... Have you got one working before you try to build 25?

A servo is an "angle motor", so you can command it to go to 90 degrees, or you could command it to go to half-way between track-A and track-B and hold there, but obviously you don't want that...

And, servos are generally continuously powered and sent a continuous control signal if you want it to hold it's position. I assume you don't want to continuously power the servos, even when they are not moving. (With any kind of motor or solenoid, you probably want some sort of holding/latching mechanism and maybe that's already built-into whatever you're starting with.)

Have you researched how it's normally done?

I understand many railway modellers use servos, because they allow more realistic slow movements, unlike the more normal solenoids.

Power_Broker: Really? So the servo class will PWM on regular digital pins?

Well the PWM you get on a PWM pin is useless for driving a servo. The repetition rate is too fast and there is too little control on the pulse width and hence fine positioning of the angle.

Maybe two PCA9685 servo breakout boards from Adafruit (or ebay). https://www.adafruit.com/product/815 http://www.ebay.com/itm/PCA9685-16-Channel-12-bit-PWM-Servo-motor-Driver-I2C-Module-For-Arduino-Robot-WC-/201402794566?hash=item2ee48ac246:g:r6cAAOSw6WdXiJSJ Up to 16 servos per board, and expandable to ~60 boards. Servos plug straight onto the board, and the board has a servo-power connector. All boards can be driven from one Arduino Uno or Nano. 25 buttons could be matrixed. Leo..

Guys, PWM has nothing to with what a servo is expecting at its signal terminal: it needs PCM, Pulse Code Modulation, the RC standard.

Servo library makes things easier so you only have to pass the angle to the write() function.

From the Servo library reference:

"The Servo library supports up to 12 motors on most Arduino boards and 48 on the Arduino Mega. On boards other than the Mega, use of the library disables analogWrite() (PWM) functionality on pins 9 and 10, whether or not there is a Servo on those pins. On the Mega, up to 12 servos can be used without interfering with PWM functionality; use of 12 to 23 motors will disable PWM on pins 11 and 12. "

"...use of 12 to 23 motors will disable PWM on pins 11 and 12."

Regardless of what pins I attach to a servo?

…use of 12 to 23 motors will disable PWM on pins 11 and 12."

Regardless of what pins I attach to a servo?

Yes regardless. This is because the PWM libiary is using a timer, the same timer that if configured in an other mode would generate PWM on pins 11 & 12.

I couldn't see anyone in the comments asking but what kind of servos? 25 servos is hell of a lot of servos that will require a lot of power, let's say that each servo use 1A on slat mode (under force) that will be 5v * 25A = 125Watts or using them under normal conditions 5v * 7.5A (0.3A each) = ~38Watts

Then I'm doomed because I'm using a Mega running DCC++, an implementation of Digital Command Control for model trains for Arduino, and it uses interrupts to alter the timers for some pins, 12 among them.

Looks like I'll need a second Mega...

I'm talking about micro servos. I don't think they draw 100mA+ each under load.

rva1945: I'm talking about micro servos. I don't think they draw 100mA+ each under load.

You mean one like this?

rva1945: Looks like I'll need a second Mega...

Read post#12 again. That breakout board also works autonomously. Only one command to the board sets the servo position. Then the Arduino (code) is not needed anymore. Up to 960 servos if you wish. With two wires, 5volt and ground. Leo..