I'm working to develop a piece of hardware that allows me to control 1000 outputs (servos) from a single output pin.

I'm using pigpio on a Raspberry Pi B3 with python. I'm also using an array of 74HC4051 multiplexers. I've created a board that contains 9 multiplexers and allows me to use the multiplexers to control up to 64 outputs.

I'm noticing an issue when testing real-time refresh rates for the servos.

When executing a program that randomly selects a value and sets all servos to that value before executing the next iteration of the loop, I'm unable to get reliable servo positions without adding a 0.05 second delay between each output selection.

Simple math tells me updating 1000 objects would take 50 seconds. If I decrease the amount of time that passes between driving each servo, this results in inconsistent positions, or some servos failing to be updated at all.

The datasheet for the multiplexer doesn't seem to indicate that it's incapable of switching fast enough, which leads me to believe that it could have something to do with the PWM/pigpio and things that are happening in that library with regard to how much time the servo needs to accurately update. The servo speed is specified as .1 second. I think that value is the speed it takes to reach the specified position once receiving a signal.

Where can I begin testing for constraints in this system so that I can speed up that horrible refresh rate? With a 0.05 second delay I'm able to update 1100 servos in 55 seconds. Is my only option better hardware? Open to any ideas.

Thanks in advance.

  • For those interested, here's an updated link to the schematic / board layout that I'm using for this project. Master Multiplexer is in the bottom left corner. See here Apr 15, 2019 at 12:51

1 Answer 1


I'm working to develop a piece of hardware that allows me to control 1000 outputs (servos) from a single output pin.

Do you accept 2 pins? If yes, you can consider PCA9685 - 992 servos with only two pins!

PCA9685 can drive servos and LEDs. I am using it to drive DC motors.

dual PCA9685

I have been trying to use 8 MCP23017 to drive 16 x 8 = 128 devices. But I2c is intermittently unstable, even I use short wiring, less than 30cm, and I2C buffers and extenders. My lesson learnt is that it is better to use distributed processing, using more Rpis working in parallel.

octal mcp23017

BTW - I see you are using HC4051 to demux 8 analog channels. That is a weird method to drive servos! Can you show me a link how to do it?

Adafruit 16-Channel 12-bit PWM/Servo Driver - I2C interface - PCA9685 $15

AdaFruit PCA9865 Tutorial

Driving servo motors with the Arduino Servo library is pretty easy, but each 
one consumes a precious pin - not to mention some Arduino processing power.  
The Adafruit 16-Channel 12-bit PWM/Servo Driver will drive up to 16 servos over 
I2C with only 2 pins.  The on-board PWM controller will drive all 16 channels
simultaneously with no additional Arduino processing overhead.  What's more, 
you can chain up to 62 of them to control up to 992 servos - all with the same 2 

The Adafruit PWM/Servo Driver is the perfect solution for any project that 
requires a lot of servos.
  • @tifong01, there isn't really a tutorial to follow for using the HC4051. It can multiplex/demultiplex, so I'm really using them in a configuration that's a giant shift register. Each board has 9 HC4051's. The main uses the inhibit pin, and three selection pins s0,s1,s2. The inhibit pin allows me to control which main board is active (of 18), and the primary selection pins s0,s1 and s2 on the main multiplexer control where the signal is routed from the main to the slave HC4051's. A second set of selection pins is used to control the output of the slave multiplexers. Apr 14, 2019 at 19:17
  • @tifong01, here's a link to the schematic / board that I built. A,B,C are the main selection pins for the multiplexer in the bottom left corner. a1,b,1,c1 are the secondary selection pins that control which output is active on one of the 8 slave multiplexers. I've labeled them so you can see how this works. Apr 14, 2019 at 19:20
  • @tifong01, servos being jumpy is why I resorted to using pigpio. Also, don't continually set your servo position to the same amount, check if it has changed first and needs to be set again. I've already figured out how to stream video from the pi across the network using ports, so I suppose I could get multiple raspberry pi's to process pieces of the feed. 64 servos would take 3 seconds to update in this regard. I think I might be able to introduce some capacitors and resistors to the existing schematic in order to allow me to set the servo position and move onto another one quicker. Apr 14, 2019 at 19:26
  • Ah, I have not played with servo for more than 5 years, so I forgot many things. Now I remember that you need to send a pulse to specify the position, and need to come back in some time to refresh, forgot if 20mS, sort of PWM. But if you don't use PWM, you can input an analog signal to the point or pot where originally was set by the mpu. So now I realize why you use analog demux. Many thanks for refreshing my memory of servos. And good luck to your project.
    – tlfong01
    Apr 15, 2019 at 7:35
  • @tifong01 Are your servos / motors under significant load? Are you powering the servos from the board, or using the separate Servo / Motor power supply (Green Terminal Block). From What I have read, the ground signal can get funny which screws up timing. I found some boards for 1.5 online. I think your approach will work. I'll update once I can test it out. Apr 21, 2019 at 19:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.