Bozzel
Posts: 3
Joined: Wed Sep 19, 2012 8:19 pm

Controlling multiple motors

Fri Nov 09, 2012 9:54 pm

Hello people,

For my current project im looking for a solution to be able to independently control multiple motors. This inculdes speed and direction. I cant seem to find a fitting solution that fits to my needs.

I was wondering if someone could tell me what i need in combination with the RPi to control 5 motors serparatly. Things that needs to be controlled are speed and direction.

Hopefully someone can tell me how to solve this.

Regards,
Chris.

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

Re: Controlling multiple motors

Fri Nov 09, 2012 10:35 pm

Three of these will drive 6 DC motors.

http://www.ebay.co.uk/itm/Dual-H-Bridge ... 0743762410

You will need two gpios per motor (so 10 in all) to control speed and direction.

Bozzel
Posts: 3
Joined: Wed Sep 19, 2012 8:19 pm

Re: Controlling multiple motors

Fri Nov 09, 2012 10:45 pm

joan wrote:Three of these will drive 6 DC motors.

http://www.ebay.co.uk/itm/Dual-H-Bridge ... 0743762410

You will need two gpios per motor (so 10 in all) to control speed and direction.
Does this also work with just 'normal' DC motors 0-12V?

Speed needs to be adjustable from 0 to 100% where 0 is off and 100% is max speed @ 12V
The point is that i want to control it with some software where i can set the motorspeed with sliders on my screen (the whole thing will be touch screen controlled)

And how to manage the speed from the motors with 2 GPIO's wich have a set output voltage of 3.3V?

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

Re: Controlling multiple motors

Sat Nov 10, 2012 9:51 am

The units I mentioned each drive one stepper motor (as they require four inputs) or two DC motors (as they require two inputs). The motor supply range is nominally 5-35V.

The logic supply is 5V. I guess 5V logic 0 and 3V3 logic 0 are similar, as are 5V logic 1 and 3V3 logic 1.

I have 3 of the units and only use them with 3V3 logic (Raspberry Pi, TI Launchpads). I have not had any problems.

ToddFerrante
Posts: 19
Joined: Sun Sep 30, 2012 8:00 pm

Re: Controlling multiple motors

Sun Nov 11, 2012 12:45 pm

Chris,
To give a good answer, we need to know what type and size of motor you are talking about.
-steppers
-brushed DC
-brushless

Also, how much current will the motors draw? Are we talking tiny little motors for a desktop robot, or something that will power the spindle on a machine tool?
Todd F.

popeyesfx
Posts: 14
Joined: Sun Sep 30, 2012 5:53 pm
Location: Notts

Re: Controlling multiple motors

Mon Nov 11, 2013 8:29 pm

Hi Guys
I am looking for a similar solution. I have 8 RS 336-315 geared dc motors that I want to control. They need to run independent of each other or at a push two at a time. The motors power miniature fairground rides my brother-in-law makes. Motors are 12v 2.2w each.
I have successfully powered a single unit using the PCM of the pi to control direction and speed via software. I am stuck with how to expand the hardware to allow control of all eight rides. Any help would be appreciated.

I used an LD293 chip to control the single motor.

cheers

gordon77
Posts: 4237
Joined: Sun Aug 05, 2012 3:12 pm

Re: Controlling multiple motors

Mon Nov 11, 2013 8:40 pm

popeyesfx wrote:Hi Guys
I am looking for a similar solution. I have 8 RS 336-315 geared dc motors that I want to control. They need to run independent of each other or at a push two at a time. The motors power miniature fairground rides my brother-in-law makes. Motors are 12v 2.2w each.
I have successfully powered a single unit using the PCM of the pi to control direction and speed via software. I am stuck with how to expand the hardware to allow control of all eight rides. Any help would be appreciated.

I used an LD293 chip to control the single motor.

cheers
The L293 will drive 2 motors, so 4 needed for 8 motors, you'll then need 16 gpio outputs to control them, 2 per motor.

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

Re: Controlling multiple motors

Mon Nov 11, 2013 8:41 pm

The units I originally mentioned (a year ago) will drive 2 motors each. So you'd need 4 of those. At a pinch you could get away with 2 gpios per motor to control speed (via PWM) and direction . Therefore 16 gpios (the latest Pi's have 21 available gpios). There are a variety of ways of getting PWM on every gpio.

You can probably find motor driver boards which make more efficient use of gpios.

popeyesfx
Posts: 14
Joined: Sun Sep 30, 2012 5:53 pm
Location: Notts

Re: Controlling multiple motors

Mon Nov 11, 2013 8:52 pm

Thanks for the reply.
Im a software engineer, so writing the code was fairly easy, but when it comes to hardware Im a beginner.
The problem requires each ride to start up, run at full speed for 3 mins or so and then slow down and stop, like a real ride. The motors are powered from a mains power supply via the control chip. I understand that once the motor reaches full speed I no longer need to PCM it, it can just run steady. Its how I multiplex the PC signal to the other motors as I was under the impression the Pi only has 1 PCM signal pin. if could you be a bit more specific on how to get PCM of the pins it would be helpful, or point me in the direction of something to read that would help.

cheers


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

Re: Controlling multiple motors

Mon Nov 11, 2013 9:12 pm

To control a motor you need 2 gpios, A and B. You change the gpio levels to determine the motor state. E.g. A=B=0 stop, A=1 B=0 forward, A=0 B=1 backward, A=B=1 brake. You can change the speed by applying PWM to the gpio set to 1, i.e. you'd vary the forward speed by generating PWM on gpio A and the backward speed by generating PWM on gpio B.

The Pi has only one accessible dedicated PWM gpio.

However PWM is just rapidly switching a gpio on and off. The ratio of on to off determines the duty cycle. Always on is 100%, always off is 0%, half on/off is 50%. The more often you switch on and off the better (within limits). Arduinos (commonly used for this sort of application) use a switching rate of circa 500Hz.

You can use Linux to schedule the gpios on and off. This will suffer from jitter but is probably good enough for motor speed control.

A better method is to use one of the modules/libraries which use DMA to switch the gpios on and off. These allow jitter free and high Hz generation of PWM.

There are modules for Python and C.

I use my own C library, pigpio. See https://www.youtube.com/watch?v=2vq0Q4dD6KE
Last edited by joan on Fri Dec 20, 2013 9:22 am, edited 1 time in total.

popeyesfx
Posts: 14
Joined: Sun Sep 30, 2012 5:53 pm
Location: Notts

Re: Controlling multiple motors

Tue Nov 12, 2013 7:15 pm

Thanks for the reply. I think I was over thinking the issue. Never thought to do it in software. I will be investigating this more.
cheers

Return to “Automation, sensing and robotics”