bojangles25
Posts: 14
Joined: Mon Jun 30, 2014 7:45 am

9v DC Motors and Pi powered by mains

Mon Jun 30, 2014 7:54 am

I'm not sure if this is in the correct forum.

I know little about electronics, but what I want to do is use a mains power adaptor to power two 9v DC motors, all the guff that makes them work (motor controller) and the Raspberry Pi.

I know I must need regulators somewhere, but where do I begin to understand what power adaptor I need and how to wire it all up?

Do I need to take the sum of all the voltages (9v x 2 + 5v = 23v) and get an adaptor that provides that sum? How do I do it?

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

Re: 9v DC Motors and Pi powered by mains

Mon Jun 30, 2014 9:10 am

you will need a separate adapter for each voltage.

1st adapter: 9v DC (feeds 2 motors via motor controller)

2nd adapter: 5v DC (feeds pi)

you could have the 2nd adapter have an input voltage of 9v but you would be better off not having the pi linked to the noisy motors.
(electrically noisy, there can be issues with running electronics from the same supply that is feeding motors).

The Pi will need to have its Gnd linked to the Gnd of the motor controller.

The motor controller may generate its own 5v supply (don't use this to supply the pi) or need a 5v supply (can be fed from the pi).
Doug.
Building Management Systems Engineer.

bojangles25
Posts: 14
Joined: Mon Jun 30, 2014 7:45 am

Re: 9v DC Motors and Pi powered by mains

Mon Jun 30, 2014 9:23 am

Thanks. I currently have a circuit that controls 2 motors: The L293D motor controller takes the 5v it needs from the Pi's GPIO header which is fine, but the motors are currently powered by a PP3 battery.

The problem I'm trying to solve is that it seems the battery is being drained even when the motors are not turning. Perhaps I should be turning the 'enable' pins on and off on the motor controller as required, rather than just wiring them straight up to the same constant 5v supply (I couldn't find a clear explanation as to why the enable pin is needed).

Is there no way I can provide both the Pi and motors with the power they need from a single mains socket?

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

Re: 9v DC Motors and Pi powered by mains

Mon Jun 30, 2014 9:51 am

bojangles25 wrote:Is there no way I can provide both the Pi and motors with the power they need from a single mains socket?
Certainly can! If you get a power supply that produces roughly what your motors and motor driver need, then you can also use a 5V voltage regulator circuit to drive your raspi and perhaps other electronics.

There are many types - cheap and inefficient, more expensive and nicer, etc. (7805 style regulators are the simple option but waste a bit of heat so they need to be bolted to a heatsink or to a metallic case. Try googling for some schematics and the data sheet, there's bound to be lots.)

As for your motor controller, it has a couple of supply connections, one for the motors and the other for its simple logic circuits - that logic supply can be run off the 5V too to save a little power, though not much. (I think we've discussed it on the forum somewhere, these drivers are very popular.)

The Enable inputs are there for various reasons, but for a simple on/off motor you can just connect them to 5V. They don't waste much power in themselves.

bojangles25
Posts: 14
Joined: Mon Jun 30, 2014 7:45 am

Re: 9v DC Motors and Pi powered by mains

Mon Jun 30, 2014 9:56 am

Certainly can! If you get a power supply that produces roughly what your motors and motor driver need, then you can also use a 5V voltage regulator circuit to drive your raspi and perhaps other electronics.
Sounds promising but can you go into a little more detail or point me at a guide? Sorry but without being told exactly what to connect to what I'm pretty hopeless. :?

Are you saying that if I got a 9V power supply (to power the motors etc) then I could wire up a 5v regulator in parallel or something?

Appreciated

mikerr
Posts: 2827
Joined: Thu Jan 12, 2012 12:46 pm
Location: UK
Contact: Website

Re: 9v DC Motors and Pi powered by mains

Mon Jun 30, 2014 9:57 am

bojangles25 wrote: Perhaps I should be turning the 'enable' pins on and off on the motor controller as required, rather than just wiring them straight up to the same constant 5v supply
(I couldn't find a clear explanation as to why the enable pin is needed).
Keeping enable high will mean you get "instant stop" of motors when you pull the motor pin low (electrical braking)
you get more gradual slowdown "coasting" if you pull enable and motor control low at the same time.
Android app - Raspi Card Imager - download and image SD cards - No PC required !

drgeoff
Posts: 10832
Joined: Wed Jan 25, 2012 6:39 pm

Re: 9v DC Motors and Pi powered by mains

Mon Jun 30, 2014 10:12 am

You won't get much running time trying to power motors from a PP3 battery. It does depend on the size of the motors and what they are driving but PP3s, even alkaline versions, aren't really intended for that sort of use.
Quis custodiet ipsos custodes?

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

Re: 9v DC Motors and Pi powered by mains

Mon Jun 30, 2014 10:15 am

Here's something I found about the 7805 (and many other regulators in general):
http://raspberrypi.stackexchange.com/qu ... i-from-12v
The regulator probably only costs around a quid or so, though you'll need a heatsink. It's probably best to search around a bit yourself, someone out there is sure to have posted photos of what they've built to give you an idea.

You could instead use the "BEC" someone mentioned in the same link. It's just a ready-made 5V or 6V regulator, used for driving model servos etc. It's usually a bit more efficient than the 7805 - it doesn't get as hot. If getting one make absolutely sure it's 5V though. I know lots of people on the forum have used them.

If you're not using battery, then the inefficient old 7805 style regulator is probably the simplest. Remember a little heatsink though (otherwise it gets very hot and shuts down, switching off your raspi!)

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

Re: 9v DC Motors and Pi powered by mains

Mon Jun 30, 2014 10:20 am

bojangles25 wrote:Thanks. I currently have a circuit that controls 2 motors: The L293D motor controller takes the 5v it needs from the Pi's GPIO header which is fine, but the motors are currently powered by a PP3 battery.

The problem I'm trying to solve is that it seems the battery is being drained even when the motors are not turning. Perhaps I should be turning the 'enable' pins on and off on the motor controller as required, rather than just wiring them straight up to the same constant 5v supply (I couldn't find a clear explanation as to why the enable pin is needed).

Is there no way I can provide both the Pi and motors with the power they need from a single mains socket?
Hmm, the L293 is probably still consuming power even when it isn't turning the motors, switching the enable might well reduce that as you suggest.

I used a UBEC, it cost £1.90

As you will be able to see, I've been doing something similar on my Dalek, I'll have to sketch out a circuit diagram for you.
Image
edit: image not really viewable, check the blog. I have a L298N driver board, a UBEC and a 12v power supply cable (while I sort out the battery).

edit again: here is how I wired up my UBEC
mdb-b.gif
mdb-b.gif (35.41 KiB) Viewed 3207 times
Last edited by BMS Doug on Mon Jun 30, 2014 10:36 am, edited 1 time in total.
Doug.
Building Management Systems Engineer.

bojangles25
Posts: 14
Joined: Mon Jun 30, 2014 7:45 am

Re: 9v DC Motors and Pi powered by mains

Mon Jun 30, 2014 10:33 am

Thanks Doug, that's an interesting project. What's the power input to your dalek? just UK mains?

The UBEC thing whatever it is appears to do what I want, i.e. put one voltage in and get another out without too much seemingly unnecessary hassle of heat (heat, really?) or extra components

What's a 16 channel PWM board?

edit: I found out.. pulse width modulation, for controlling motor speed right? I'm not really bothered about speed...

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

Re: 9v DC Motors and Pi powered by mains

Mon Jun 30, 2014 2:55 pm

bojangles25 wrote:Thanks Doug, that's an interesting project. What's the power input to your dalek? just UK mains?

The UBEC thing whatever it is appears to do what I want, i.e. put one voltage in and get another out without too much seemingly unnecessary hassle of heat (heat, really?) or extra components

What's a 16 channel PWM board?

edit: I found out.. pulse width modulation, for controlling motor speed right? I'm not really bothered about speed...
I'm trying to find a good battery, during the video the power was 12v dc supplied by a multivoltage dc adapter.

I didn't mention the PWM as it isn't essential and I didn't want to cloud the issue.

I actually have more details on the Dalek here, I just use the blog to keep pictures on.
Doug.
Building Management Systems Engineer.

Return to “Beginners”