Posts: 2
Joined: Sun Jul 09, 2017 12:44 am

Multiple DC motors using discrete components

Sun Jul 09, 2017 1:48 am

Hi everyone,

I'm trying to come up with a way to drive multiple small DC motors, controlling their direction and power on / off independently using a Pi. The motors are rated 1.5-6.5V giving 1700-7300 RPM; I've measured ~12.5mA current draw when running free and ~100mA when fully stalled, both from a 1.5V AA battery as a supply. I need to run 16 of these; I don't need precision speed control, just on / off and direction at the lowest practical RPM. I also need to connect a bunch of other stuff to the Pi, so I can't really use up all my GPIOs on these. I would also very much like to stay low-budget (the motors cost about ~US$0.90 apiece).

My question is twofold:
  1. What to use to drive the motors?
    • L293x is out of the question for budget reasons (it's around US$5 around here and I'd need 8 of them) as well as low RPM requirements (the lowest supply voltage it supports is 4.5V which in and of itself wouldn't give me low RPM and I don't want to have to deal with PWM on account of question 2).
    • The L9110 seems like the best way so far - I can get it about as cheap as the motors themselves, it can go pretty low on the supply voltage (2.5V) which should hopefully result in reasonably low RPM. The issue is that I can't seem to find a lot of info about it.. the datasheet looks like it was translated by a very early non-public beta of google translate, but it seems to be saying that the input pins are each for one motor direction; but there's other information I was able to find about it online that says that there's one "enable" pin (which could even be fed a PWM if I were so inclined) and one "direction" pin; also I can't seem to find any reference as to what the output voltage will be relative to the supply voltage (I think I read somewhere it's around half Vcc). Is there anyone here who could shed some detailed info on this chip and its application?
    • The third option I'm contemplating is going discrete. Basically I'd have a 1.5V supply rail hooked to one side of the motor and I'd use two transistors to connect the other side of the motor to either the ground or a 3V supply rail. It's a very naive solution and even the few problems that I can spot with my absolute lack of education in electronics tell me off of it; but out of a morbid curiosity, is there any way to make a super simple solution like that work at all?
  2. Who driveth the drivers? (cough, cough)
    Given the fewest-possible-GPIOs-used requirement, how do I multiplex control from a pair of GPIOs on the Pi to 16 pairs of control inputs on the drivers? I know the general working principle of multiplexing, but again my actual knowledge in the field is very limited, so I don't really even know where to begin to look for suitable multiplexer ICs (or indeed how to know whether those I find are suitable or not), nor what other circuitry I might need between them and the drivers. So assuming I'll go with the L9110 which seems like the best option at the moment, how would I go about multiplexing control from 2 GPIOs onto 16 L9110s? Would for example a pair of 74HC4067s do the trick? If so, would it make sense to drive them using 6 GPIOs (ie. sharing the 4 channel select lines and having a separate GPIO drive each of the ICs enable pin)? Or is there another IC you'd recommend? And what other circuitry should go between the multiplexer and each motor driver? Should I put a condenser somewhere in there to "smooth out" the pulses received from the multiplexer?
Thanks a lot!

Posts: 15
Joined: Tue Mar 28, 2017 9:58 pm

Re: Multiple DC motors using discrete components

Fri Jul 21, 2017 1:50 am

If I were you I'd use the L9110s. They're cheap and simple, but will be easier to implement than discrete components, especially since you need to control 16 motors (bidirectional).

Sure the datasheet isn't the clearest, but the theory of those thingies goes like this: you have the A and B inputs and outputs. When the A input is high, the A output will be high; when it is low the output will be low. Same with B. The idea is you connect your motor so one wire goes to the A output and the other to the B output. To make the motor spin one direction you set the A input high and the B input low. To make it spin the other direction, set A low and B high. If A and B are both high or both low, the outputs will be at the same voltage so no current will flow. (And for speed control, you'd PWM one of the inputs.)

(BTW, that's basically also how the L293s work, except they have four channels instead of two, additional ENable inputs, and separate power inputs for the logic and the motor drivers.)

So now you need 32 digital outputs to be able to independently control both on/off and direction of 16 motors. To accomplish that, I'd recommend using GPIO expanders. Specifically, the MCP23017 which has 16 GPIOs (so you need two of them) and talk to the Pi via I2C, and they're cheap and are available in a DIP package.

This article: http://www.hertaville.com/interfacing-a ... ing-c.html is a nice tutorial on connecting one of them up. To connect a second one, you connect the SDA and SCL in parallel and give it a different address (e.g., connect the A0 pin high instead of low).

Posts: 2
Joined: Sun Jul 09, 2017 12:44 am

Re: Multiple DC motors using discrete components

Fri Jul 21, 2017 1:10 pm

Thanks, yaheath! That sure is a lot of useful info.

I've been experimenting with the L9110s for a bit as the package already arrived and I found out for myself that they indeed behave as you say, but not without issues - I fried three of them because I only connected one of each of the GND and VCC pins - I assumed that for a simple test on a breadboard it would be enough since I figured the additional pins were there just to provide a better connection and inside the chip they would be connected anyway, but that was not the case! With just the one pair of pins connected the driver would only work one way and start overheating when I pulled the other input pin high even when there was no load connected to the output. Good thing I ordered extras. Once I figured that out they started working as expected.

As for the digital IO, expander chips indeed seem like a great solution. I'd have to figure out a different way to implement the software side since now I'm using python with gpiozero which doesn't support I2C expanders yet, but that wouldn't be too hard I think. A friend of mine additionally recommended using 8-bit shift registers like the 74HC595; I'd need 4 of those instead of just 2, but it's still doable and would work with gpiozero. Don't know yet which I'm gonna pick :-)

Thanks a lot for your time and help!

Return to “Interfacing (DSI, CSI, I2C, etc.)”