3NiGMa
Posts: 10
Joined: Tue Jul 10, 2018 8:47 am

Two 6V motors through RPi3B

Tue Jul 10, 2018 9:04 am

Hey guys,
I need to power two 6V motors, ideally at 0.65A, through my Raspberry Pi 3 B. I have bought the L239d motor chip and a single 4xAA battery pack. A lot of forums say four AA alkaline batteries will not be enough, and I was wondering what I could do to make this work, I am using this website as a tutorial:
https://business.tutsplus.com/tutorials ... -cms-20051
Thanks in advance.

User avatar
Z80 Refugee
Posts: 358
Joined: Sun Feb 09, 2014 1:53 pm

Re: Two 6V motors through RPi3B

Tue Jul 10, 2018 11:43 am

3NiGMa wrote:
Tue Jul 10, 2018 9:04 am
A lot of forums say four AA alkaline batteries will not be enough
Not enough for what? Running the motors and the RPi from the same supply? No. Run the RPi from a different supply, or you will have a lot of trouble.
Military and Automotive Electronics Design Engineer (retired)

For the best service: make your thread title properly descriptive, and put all relevant details in the first post (including links - don't make us search)!

pcmanbob
Posts: 4255
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Two 6V motors through RPi3B

Tue Jul 10, 2018 1:48 pm

The web site tutorial you are following is just showing you how to use the L293 to drive motors using a pi , for the example ordinary AA batteries are find because the load on the motors is minimal, once you start using the motors to actually move a rover about the load will go up which is when you might find AA batteries start to run down very quickly.

you could just replace them with AA rechargeable batteries which will supply more current and can be recharged when needed.
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

3NiGMa
Posts: 10
Joined: Tue Jul 10, 2018 8:47 am

Re: Two 6V motors through RPi3B

Tue Jul 10, 2018 9:56 pm

Thanks Z80,
What would be a good power supply for the RPi? Would LiPOs be just fine?

IanS
Posts: 190
Joined: Wed Jun 20, 2012 2:51 pm
Location: Southampton, England

Re: Two 6V motors through RPi3B

Wed Jul 11, 2018 6:55 am

There are plenty of people powering the Pi in a mobile project from a LiPO power pack, but these are normally available in multiples of 3.6V, so you will need a 7.2V LiPO and then a voltage regulator to bring it down to 5V. Many 5V regulators work best if the input voltage is at least 7V, so trying to power the Pi from 4x1.5V AA batteries could be problematic.

If you start using rechargeable batteries rather than disposables for the motors you will find that they can supply a much higher current (especially NiMHs), but the peak voltage is only about 1.2V instead of 1.5V. Hence to run a 6V motor at full speed you will need a 5x battery holder instead of a 4x. These are strangely difficult to get hold of.

3NiGMa
Posts: 10
Joined: Tue Jul 10, 2018 8:47 am

Re: Two 6V motors through RPi3B

Wed Jul 11, 2018 8:14 am

Yeah, IanS, they only seem to come in 1, 2, 4, 6 and 8 battery holder. So ideally, I would have 5xAA going in to this circuit;

Image

As well as a LiPO going directly to the pi?
Sorry I am new to electronics in general :shock:

pcmanbob
Posts: 4255
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Two 6V motors through RPi3B

Wed Jul 11, 2018 10:30 am

If you are going to use rechargeable batteries for your motor supply use 6 x 1.2v which will give you 7.2v.

you will have a slight voltage drop across the L293D any way and most 6V motors will operate over a voltage range of 4- 8V without any problems.
Last edited by pcmanbob on Wed Jul 11, 2018 11:05 am, edited 1 time in total.
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

User avatar
Gavinmc42
Posts: 2094
Joined: Wed Aug 28, 2013 3:31 am

Re: Two 6V motors through RPi3B

Wed Jul 11, 2018 10:34 am

A USB battery bank if it can output 2+ Amps should be able power the Pi.
DO NOT power the Pi directly from 7.2V.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

pootle
Posts: 261
Joined: Wed Sep 04, 2013 10:20 am
Location: Staffordshire
Contact: Website

Re: Two 6V motors through RPi3B

Wed Jul 11, 2018 12:55 pm

I've run a pi3B from a cheap powerbank with no problems. Although the powerbank is only rated 1A (as are most), it quite happily runs the pi for a couple of hours. Got it from argos for about £8 last year. Rated at 2Ah.

And yes, use separate power for the motors is a good plan, although I've run lower power motors (micrometal motors) from the same powerbank with a pi zero and suitable decoupling.

3NiGMa
Posts: 10
Joined: Tue Jul 10, 2018 8:47 am

Re: Two 6V motors through RPi3B

Wed Jul 11, 2018 10:28 pm

Thanks for the help 👍 :D

User avatar
Imperf3kt
Posts: 1196
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: Two 6V motors through RPi3B

Wed Jul 11, 2018 11:35 pm

IanS wrote:
Wed Jul 11, 2018 6:55 am
There are plenty of people powering the Pi in a mobile project from a LiPO power pack, but these are normally available in multiples of 3.6V, so you will need a 7.2V LiPO and then a voltage regulator to bring it down to 5V
Except new LiPos are 3.7v nominal and can be as high as 4.35v when fully charged. Two in series == 8.7v

Not mentioned is the fact you can run a Pi off a single Lithium Ion cell with a boost circuit.
This, in my opinion, is far safer.
By using one cell, you can recharge it without having to remove it from your project or fiddle with complex balancing electronics.
Additionally, if the boost module fails, your Pi will see 2.9-4.2v, which may be enough to run it until you can shut it down. Worst case scenario, your Pi crashes and potentially corrupts the SD card.
If, however, you use 7.4v and buck it down, and that buck fails, your Pi plus everything connected to it, will see 7.4v, frying it all instantly.
Last edited by Imperf3kt on Thu Jul 12, 2018 9:55 am, edited 1 time in total.
User experiencing technical difficulties.

3NiGMa
Posts: 10
Joined: Tue Jul 10, 2018 8:47 am

Re: Two 6V motors through RPi3B

Thu Jul 12, 2018 8:34 am

Will this work?? or is the power from the AA’s also going in to the pi?
Image attatched
Attachments
35CF56D8-E859-459D-9405-21EAF12B9F6B.png
35CF56D8-E859-459D-9405-21EAF12B9F6B.png (221.58 KiB) Viewed 500 times

User avatar
Z80 Refugee
Posts: 358
Joined: Sun Feb 09, 2014 1:53 pm

Re: Two 6V motors through RPi3B

Thu Jul 12, 2018 9:18 am

Can we use circuit diagrams please?

AFF8B906-7B02-4121-B7CF-3DFF36582AF7.jpeg
AFF8B906-7B02-4121-B7CF-3DFF36582AF7.jpeg (162.08 KiB) Viewed 487 times

Here is the L293D datasheet: http://www.ti.com/lit/ds/symlink/l293d.pdf (there is an obvious error in section 6.3: for "Low-level output voltage" read "Low-level input voltage").

The chip uses a 5V supply for the logic, but fortunately the logic input voltages (section 6.3) are within the output voltage range of the RPi. However, you must not connect the chip's logic inputs to a GPIO pin that is not programmed as an output, because if the GPIO pin was in a high impedance state the leakage current from the L293D's inputs would cause the GPIO to exceed its safe voltage. That said, only engineers worry about this - hobbyists do it anyway and seem to get away with it (mostly).

The main thing I need to draw attention to is Supply Voltage, where section 6.3 says Vcc2 must be greater than or equal to Vcc1. That means you should not let your battery voltage go lower than 5V. I don't know what will happen if you do, but it is not guaranteed to work correctly (again, you may get away with it, but an engineer wouldn't try).

An obvious omission: where are your back-EMF protection diodes? See the diagrams in section 9.3.2, Figure 10 describes your particular usage. Without the diodes, you could destroy the L293D. [Edit: This is only correct for L293. L293D has built-in protection diodes.]
Last edited by Z80 Refugee on Thu Jul 12, 2018 5:19 pm, edited 1 time in total.
Military and Automotive Electronics Design Engineer (retired)

For the best service: make your thread title properly descriptive, and put all relevant details in the first post (including links - don't make us search)!

User avatar
Imperf3kt
Posts: 1196
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: Two 6V motors through RPi3B

Thu Jul 12, 2018 9:59 am

3NiGMa wrote:
Thu Jul 12, 2018 8:34 am
Will this work?? or is the power from the AA’s also going in to the pi?
Image attatched
That picture is so hard for me to understand xD

But to answer your question, yes, the batteries are directly connected to the Pis 5v via the breadboard (or so they seem to be), and is not a good idea to do this

Note: I haven't used a breadboard in 20 years, so may be incorrect
User experiencing technical difficulties.

User avatar
Burngate
Posts: 5403
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK
Contact: Website

Re: Two 6V motors through RPi3B

Thu Jul 12, 2018 10:34 am

Z80 Refugee wrote:
Thu Jul 12, 2018 9:18 am
An obvious omission: where are your back-EMF protection diodes? See the diagrams in section 9.3.2, Figure 10 describes your particular usage. Without the diodes, you could destroy the L293D.
The device in the picture is L293D which has the diodes in-built.
No guarantee that the OP is using that rather than plain L293 without the diodes, particularly as he's not using a Pi with only 26 pins, despite what the picture shows!
Imperf3kt wrote:
Thu Jul 12, 2018 9:59 am
... the batteries are directly connected to the Pis 5v via the breadboard (or so they seem to be) ...

Note: I haven't used a breadboard in 20 years, so may be incorrect
My reading of the picture is that the 5v (red-white dotted) is only connected to the L293D pin 16, nowhere else.

IanS
Posts: 190
Joined: Wed Jun 20, 2012 2:51 pm
Location: Southampton, England

Re: Two 6V motors through RPi3B

Thu Jul 12, 2018 3:46 pm

You can get 5 (and 10) battery holders, but I have only ever seem them as ebay items shipped from China.
e.g. https://www.ebay.co.uk/itm/1-2-3-4-5-6- ... 2888566749
I have a couple, purely for 6V motors, but I might measure the voltage drop across the controller (a L298N in my case, because I have a few around) and maybe go to 6x.

User avatar
Z80 Refugee
Posts: 358
Joined: Sun Feb 09, 2014 1:53 pm

Re: Two 6V motors through RPi3B

Thu Jul 12, 2018 5:16 pm

Burngate wrote:
Thu Jul 12, 2018 10:34 am
The device in the picture is L293D which has the diodes in-built.
Oh yes, so they are. Thanks.
Military and Automotive Electronics Design Engineer (retired)

For the best service: make your thread title properly descriptive, and put all relevant details in the first post (including links - don't make us search)!

3NiGMa
Posts: 10
Joined: Tue Jul 10, 2018 8:47 am

Re: Two 6V motors through RPi3B

Fri Jul 13, 2018 2:34 am

Wow okay this is starting to seem more complex than I originally thought...
WILL THIS PINOUT OVERLOAD MY PI?
Battery+ > Breadboard+
Battery- > Breadboard-
Breadboard- > RPi Ground
Breadboard- > L293d pins 12 & 13 & 4 & 5
Breadboard+ > L293d pin 8
L293d pin 11 & 14 > Motor 1 pins
L293d pin 3 & 6 > Motor 2 pins
L293d pin 2 > RPi pin 24
L293d pin 7 > RPi pin 23
L293d pin 1 > RPi pin 25
L293d pin 9 > RPi SCLK pin
L293d pin 10 > RPi MISO pin
L293d pin 15 > RPi MOSI pin
L293d pin 16 > RPi 5V #<<< this be problem if I am using a LiPO (boosted to 5V) directly to the pi?!

User avatar
Z80 Refugee
Posts: 358
Joined: Sun Feb 09, 2014 1:53 pm

Re: Two 6V motors through RPi3B

Fri Jul 13, 2018 6:24 am

3NiGMa wrote:
Fri Jul 13, 2018 2:34 am
WILL THIS PINOUT OVERLOAD MY PI?
No.
3NiGMa wrote:
Fri Jul 13, 2018 2:34 am
this be problem if I am using a LiPO (boosted to 5V) directly to the pi?!
No.

The problems you might encounter are if the battery voltage drops below 5V, or if the motor currents are too high for the breadboard (or the contact between the wires and the breadboard).
3NiGMa wrote:
Fri Jul 13, 2018 2:34 am
Wow okay this is starting to seem more complex than I originally thought...
No, this is as simple as it gets. One IC, two motors, and a power source! Nobody should ever be designing in an IC (or even a transistor) without being familiar with its data sheet and checking it is capable of doing what you want and what requirements have to be met. That's the basics of electronics design.

Diagrams are much easier for us (and will be for you) to understand than wiring lists or pictorial representations, and what you've listed is what I drew above (apart from adding GPIO allocations - and it would be better to use GPIO numbers rather than pin numbers or function names ("MOSI" is irrelevant to your usage). Including diagrams isn't hard - I sketch on my iPad, but a sketch on paper then photographed would be just as good.
Military and Automotive Electronics Design Engineer (retired)

For the best service: make your thread title properly descriptive, and put all relevant details in the first post (including links - don't make us search)!

User avatar
Z80 Refugee
Posts: 358
Joined: Sun Feb 09, 2014 1:53 pm

Re: Two 6V motors through RPi3B

Fri Jul 13, 2018 9:39 pm

Incidentally, you don't actually need to connect pins 1 and 9 to GPIO outputs, they could just go to 5V. The same effect (cutting the current through the motor) can be achieved (in your configuration) by making the inputs both high or both low.
Military and Automotive Electronics Design Engineer (retired)

For the best service: make your thread title properly descriptive, and put all relevant details in the first post (including links - don't make us search)!

Return to “Automation, sensing and robotics”

Who is online

Users browsing this forum: No registered users and 9 guests