KCam
Posts: 9
Joined: Thu Feb 19, 2015 10:59 am

How do I control 16 motors independently?

Thu Feb 19, 2015 12:28 pm

Hi everyone,

I've been a software developer for over 11 years but building circuits has always scared me.

I had a good idea recently for an automation system which I'm looking to setup, but need a little guidance on the type of hardware I need in order to setup a complete circuit which will allow me to begin writing some python and getting the whole thing working to my requirements.

I plan to 3D print all my own enclosures and possibly create my very own peristaltic pumps for the final prototype.

Here is a rough idea of what I need to achieve for my initial prototype:

1. I need to somehow power up to 16 x 6V DC Motors / Peristaltic Pumps (Current: 30mA)
2. I need to be able to talk to each motor independently via the rpi.
3. I need to control the speed of each individual motor via the rpi.
4. I need the ability to easily add and remove the motors without breaking the circuit.
5. I need all motors to run clockwise at all times.

I'm guessing each motor will need its very own processor of some sort (Does this mean I need a rpi for each motor?).

Then I'll need to build something off of the rpi which can communicate with all the motors.
I think the term is shield or plate? Like a router does with computers on a network.

Any guidance on what kind of hardware, power, etc I should look at for building my first prototype would be really appreciated.

Thanks,
KC

texy
Forum Moderator
Forum Moderator
Posts: 5160
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: How do I control 16 motors independently?

Thu Feb 19, 2015 1:16 pm

Hi,
it should be possible to control all 16 motors with a single Pi B+ or Pi 2 and a couple of ULN2003 driver chips, plus a suitable PSU for the pumps.
You'll need to research PWM in order to control the speed - see pigpio for example.
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

KCam
Posts: 9
Joined: Thu Feb 19, 2015 10:59 am

Re: How do I control 16 motors independently?

Thu Feb 19, 2015 1:23 pm

Thanks Texy - that's good information for me to get me started.
I'll look at getting some parts together and see how I get on.

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: Korea

Re: How do I control 16 motors independently?

Fri Feb 20, 2015 12:25 am

First, get one motor working...

KCam
Posts: 9
Joined: Thu Feb 19, 2015 10:59 am

Re: How do I control 16 motors independently?

Fri Feb 20, 2015 9:35 am

ame wrote:First, get one motor working...
Yep thats probably the best idea! :)

I'll post a picture here when I've got the one one motor working.

I plan to setup something using what Texy advised for starters:
1 x Rasberry Pi 2
1 x ULN2003 driver chip
1 x PSU for externally powering the single motor/pump.
1 x PWM to control motor speed

Then start working on the code and see if I need to use alternative motors or different sized inner tubes.

texy
Forum Moderator
Forum Moderator
Posts: 5160
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: How do I control 16 motors independently?

Fri Feb 20, 2015 12:01 pm

Designing a pcb 'shield' for this would be easy enough and I would be willing to help you with this, if that's definitely the way you want to go.
If you intend to change motor types, beware of the current draw and the ULN chip's limitations. I haven't got the spec handy, but I'm sure you have.....
What are the pumps going to be used for?
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

KCam
Posts: 9
Joined: Thu Feb 19, 2015 10:59 am

Re: How do I control 16 motors independently?

Fri Feb 20, 2015 1:18 pm

Thanks Texy, I'll get a small prototype working so I can get a feel for it!

Designing a PCB shield :shock: I'd be way out of my depth. I've seen some of examples of people designing their own, but I would not know where to begin in all honesty. I'd appreciate any guidance you can give on the subject though. Perhaps I should look into reading schematics, so I can understand how others develop their circuits. Though building a bespoke PCB sounds awesome!

The 16 pumps will each dispense various e-liquid ingredients to allow small solutions to be made from 3ml to 100ml.
If you've ever seen how eliquids are prepared, you will understand why this would be such a great thing to automate.

The programming side of it will be an absolute doddle!
The circuitry will be the part that will slow this down, but I'm in no rush - I'll just work at it gradually and see how I get on.

I'll keep referring back to this with progress anyway and you can advise where necessary.

Thanks,
KC

KCam
Posts: 9
Joined: Thu Feb 19, 2015 10:59 am

Re: How do I control 16 motors independently?

Mon Feb 23, 2015 12:43 pm

Just an update...

I have found something which looks absolutely perfect for my needs: Adafruit 16-Channel PWM / Servo HAT

The only problem here is most of the peristaltic pumps I've seen are all DC motors and not these 3 wire servo motors that are required for this motor driver board.
Do you think it would be possible to wire DC motors to that servo HAT, if I did 1 positive and 2 negatives?

After further thoughts on the design of the liquid dispenser - it would be nice to be able to change the direction of the motor, so that the liquid that remains in the tube can be moved back to the reservoir (this is not essential, as I could manually put the liquid back in by disconnecting the tube from the reservoir, running the motor until tube is empty and place the liquid back into the reservoir by hand).

It may be that I convert some cheap servo motors for continuous rotation - which I have seen somewhere recently, then engineer my own peristalic pumps with the 3D printer. Then I could utilise the 16-channel connectors on the servo hat.
Do you think after modify the servo's that I'll still be able to change the rotation?

I'm very likely over engineering a simple task that can be achieved with a small number of parts on a breadboard (e.g. ULN2803: 8 Channel Darlington IC).

Anyway, I think best I continue to do more research into this, as if I can build a 16-channel DC motor driver which allows switching direction, that would be ideal as I wouldn't need to create my own peristaltic pump and mod a servo, etc, etc.

texy
Forum Moderator
Forum Moderator
Posts: 5160
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: How do I control 16 motors independently?

Mon Feb 23, 2015 12:54 pm

Sounds good in theory, but.....driving a servo is not the same as driving a dc motor. A servo is intelligent in that a signal pulse is used to control the position of the arm, with power being supplied via a separate wire. Your pump is dumb in that it is only 'controlled' by applying power via 1 wire (plus ground). I don't think it will 'serve' your purpose, but others may have a better idea.
PS, you have also changed the requirements as originally the motor was to go in one fixed direction only?
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

Ravenous
Posts: 1956
Joined: Fri Feb 24, 2012 1:01 pm
Location: UK

Re: How do I control 16 motors independently?

Mon Feb 23, 2015 1:33 pm

As Texy indicates, reversing the motors needs a more complicated motor driver - an H-bridge. That's needed because reversing the current flow through the motor needs more stuff than just an on/off control.

Also to reverse you will probably need an extra control output per motor. (Unless... the motors are all switched into reverse together. In that case perhaps all of the motors could be reversed with just one extra control output.)

So, running the motors one way only will be far cheaper and need less wiring for your case.

Also the servos are completely different to regular motors. The servo has its own driver (reversible) built in, and position sensing too (unless it's been modified for "continuous rotation".

KCam
Posts: 9
Joined: Thu Feb 19, 2015 10:59 am

Re: How do I control 16 motors independently?

Mon Feb 23, 2015 1:37 pm

Thanks Texy.

Yep, ignore the added ability of rotating in the opposite direction. It was just an idea I had for automatically refilling the reservoir with the contents in the tube.
Just call me 'The Overcomplicator'.

A DC Motor to drive a peristaltic pump sounds like it could be very innaccurate then.
Especially if there is ever power flucuation or degradation of the motor itself.

In order to get repeatable 0.1ml volume accuracy - I'd need to have something monitor the speed of the motor.
I figured I could get very consistent results with speed, time and the flow rate of the inner diameter of tube used, but I think this could turn out to be a fail.

Perhaps, I should look at other dosing methods used for lab work (Stepper motor and syringe pump possibly) and see how they get absolute consistent accuracy.

Thanks for your thoughts on this Texy, you've been very helpful.

KCam
Posts: 9
Joined: Thu Feb 19, 2015 10:59 am

Re: How do I control 16 motors independently?

Mon Feb 23, 2015 1:41 pm

Thank you Ravenous!
I'll keep thinking of the best way to get this setup to work as accurately as I can and as simple as possible too.

User avatar
joan
Posts: 14351
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: How do I control 16 motors independently?

Mon Feb 23, 2015 2:28 pm

Stepper motors are probably better suited to your restated requirements.

Probably best to try to firm up your requirements and then ask if it is feasible and for implementation suggestions.

KCam
Posts: 9
Joined: Thu Feb 19, 2015 10:59 am

Re: How do I control 16 motors independently?

Mon Feb 23, 2015 2:39 pm

Thanks Joan! Apologies for my indecisiveness of the original requirements.
I agree, I think a stepper motor will work out more consistent than the peristaltic pump - so I'll look into this a little more.

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: How do I control 16 motors independently?

Mon Feb 23, 2015 4:22 pm

16 stepper motors to control is going to be a lot of I/O, perhaps consider having a bunch of i2c stepper motor controllers?

This one (£14 each and you'll need one for each stepper motor) is a L298N H-bridge attached to an ATmega8L to give you an I2C connection, it seems to have a 4 bit address switch which would give you 16 potential addresses (but no spare capacity without adding an i2c multiplexer).
Doug.
Building Management Systems Engineer.

KCam
Posts: 9
Joined: Thu Feb 19, 2015 10:59 am

Re: How do I control 16 motors independently?

Tue Feb 24, 2015 11:42 am

Thank you for your reply Doug.

Yea there are a lot of variables to consider which seem to constantly change my requirements.

The stepper/syringe pump will be the most consistent and accurate method I'm sure, but not really suitable for the type of dispenser I'm looking to build as it requires a lot of maintence and setup!

Another method would be a burette type tube with an automated stopcock which could be powered with a simple servo - then the liquid will drop through. If I could open and close the stopcock quick enough to drop a consistent 0.1ml, then I think I'll be close to having something which could work well. This method would need to account for the viscosity of certain liquids - the duration of the stopcock would need to remain open slightly longer for thicker liquids. Or I keep the same delay between opening and closing the valve, but alternate larger bore stopcocks to work around this variation.

I'm going to find a couple of decent servo motors which I can use to build two examples (burette method and peristalic pump using a continuous rotating servo) to test which one will serve the most accurate.

Thanks everyone for your feedback on this - will keep you posted on what the final outcome is after I've ran a load of tests.
KC

Return to “Beginners”