Searching \ for 'Driving Motors - Help!' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/io/motors.htm?key=motors
Search entire site for: 'Driving Motors - Help!'.

Truncated match.
PICList Thread
'Driving Motors - Help!'
1996\07\12@113242 by myke predko

flavicon
face
Hi Folks,

Does anybody have any hints on driving motors with the PIC?  I'm still
trying to get my I/R Robot working and my biggest (and hopefully last)
problem is with the motors.

I originally tried to copy the circuit presented in the "Runabout Robot" in
Electronics Now, but I've reached a stumbling block.  The motor driver is an
"H" transistor Driver (a PNP 2N4403 from 3 Volts (battery) to a motor
terminal to an NPN 2N4401 dropping the circuit to Ground).  The Transistor
bases are connected to a PIC driver via a 750 Ohm resistor.

The mechanical pieces I used is from two Tamiya tracked vehicle kits (one
motor and gearbox to drive each set of tracks).  Actually, if you are
interested in building a simple device that runs along the floor and uses
differential motors for steering, Tamiya has the tracked vehicle kit (which
I used two for the motors and gearboxes) and the "wall hugging mouse", which
uses two motors in a similar fasion to the Runabout Robot.

I originally set up the circuit as shown in the article (with an individual
PIC Pin driving a PNP/NPN combination).

Two problems arose from this.

The first was that the PIC was locking up intermittantly when a Motor was
energized.  The second was that the transistor circuit was not driving
enough current for the Motors to run (I measured the motors as requiring
roughly 400 mA - The circuit would only provide 300 mA).

I went after the second problem, thinking that I had a flakey connection
causing the locking up.  I decided to drop the in line resistor value to
increase the current - a 220 Ohm resistor was used.

In doing this, the PIC locked up right from application of power (making the
first problem a lot worse).  Going through the Datasheets (I am using a
'C84), I found that I was exceeding the PIC's Source/Sink currents and this
seemed to be causing the lockup.  I removed some of the load from the PIC
Port (I was using PORTA to drive the Transistors) and the locking up has
gone away.

Now, doing the math, it's pretty obvious that the way I'm going is the wrong
one.  I was going to split out the PNP/NPN pin controls to two PIC Pins from
one, but that will help the Pin Current Requirements, but not the PORT POWER
PROBLEMS (which is what seemed to be causing the PIC to Lock-Up).

I would like to use Darlington Pair Transistors (I've used NPN arrays such
as the ULN2003A in the past to drive relays) to drive the motors.  This
should eliminate the Port Power consumption problems.  Before I jump in and
do this, I have a few questions:

1.  Does anybody have experience with PNP Darlington Pairs?

2.  Can I replace the "top" PNP with a NPN and make the motor terminal drive
like a totem pole output?

3.  What PIC Pin to Transistor Base Resistor Value should I use?  Assuming
an Hfe of 5K for the Darlington NPN Array and current requirements of 600 mA
(for some guardband):

 C-E Current = Hfe x B-E Current ("BEI")
 600mA       = 5K (for example) x BEI
 BEI         = 600mA/5K
             = 0.12 mA

 Resistor    = PIC Output Voltage / BEI
             = 4.8 Volts / 0.12mA
             = 40K

So, from these calculations, a 40K resistor should give me approximately 600
mA through a Darlington Pair NPN Transistor driven by a PIC Pin.  Is this
correct?

4.  Is is possible to do away with the in-line resistor all together?  When
I've used the ULN2003A in the past, I've driven the Darlington pairs
directly from TTL/CMOS.

Ideally, I would like to use four NPN Darlington Pair Transistors driven
directly from the PIC.

Sorry for the long note, I appreciate any answers or ideas you can give me.
And before I start adding parts, I would like to see if what I want to do
has any merit.

Thanx,

Myke

Do you ever feel like an XT Clone caught in the Pentium Pro Zone?

1996\07\12@121908 by Mark K Sullivan

flavicon
face
>Does anybody have any hints on driving motors with the PIC?  I'm still
<snip>
>The motor driver is an "H" transistor Driver (a PNP 2N4403 from 3 Volts
>(battery) to a motor terminal to an NPN 2N4401 dropping the circuit to Ground).
>The Transistor bases are connected to a PIC driver via a 750 Ohm resistor.

Are the collectors tied together (at the motor) and the bases tied together?
This won't work.  I don't understand your circuit.  (I don't have the magazine).
You could drive the bases from four port pins, each with it's own resistor.
Does anybody have any hints on driving motors with the PIC?  I'm still
trying to get my I/R Robot working and my biggest (and hopefully last)
problem is with the motors.

You are talking quite a bit of current for the 4401/4403.  Note that Beta
will be lower than expected.

>I originally set up the circuit as shown in the article (with an individual
>PIC Pin driving a PNP/NPN combination).
<snip>
>The first [problem] was that the PIC was locking up intermittantly when a Motor
>was energized.  The second was that the transistor circuit was not driving
>enough current for the Motors to run (I measured the motors as requiring
>roughly 400 mA - The circuit would only provide 300 mA).

Watch out for brush noise, either on the power supply or getting back into the
PIC I/O pin.  This can easily lock up the PIC.  Try an R/C snubber such as .1uF
in series with, say, 47 ohms across each motor.  Connect this as close as
possible to the motor itself, ideally right across the brushes.

<snip>
>I would like to use Darlington Pair Transistors (I've used NPN arrays such
>as the ULN2003A in the past to drive relays) to drive the motors.  This
>should eliminate the Port Power consumption problems.  Before I jump in and
>do this, I have a few questions:

You're going to lose a lot of power across the voltage drops of two darlingtons
with a 3 volt supply.

>1.  Does anybody have experience with PNP Darlington Pairs?
>
>2.  Can I replace the "top" PNP with a NPN and make the motor terminal drive
>like a totem pole output?

This might work pretty well since the PIC drives to the rail, but your top
transistor becomes an emitter follower and you will have Vce voltage at least
the magnitude of the Vbe drop. Like the darlingtion, this wastes power and
reduces motor voltage.

>4.  Is is possible to do away with the in-line resistor all together?  When
>I've used the ULN2003A in the past, I've driven the Darlington pairs
>directly from TTL/CMOS.

The ULN2003 has a built-in base resistor.  You wouldn't need a base resistor for
the NPN emitter follower (question 2) configuration.

I would use a seperate port pin for each transistor so the emitters can be
connected to the rails.  Use resistors on all four bases calculated to set
the base current pretty high, say 10 mA for 4401/4403.  Design the software
for "dead time" between driving one direction and driving the other direction
to avoid rail-to-rail current when the transistors are switching.

You should look into low-threshold MOSFETs, too.  MOSFETs don't need gate
current (except when switching) and won't need any gate resistors in your
application.

- Mark Sullivan -

1996\07\12@124703 by Martin J. Maney

flavicon
face
On Fri, 12 Jul 1996, myke predko wrote:

> The first was that the PIC was locking up intermittantly when a Motor was
> energized.  The second was that the transistor circuit was not driving
> enough current for the Motors to run (I measured the motors as requiring
> roughly 400 mA - The circuit would only provide 300 mA).

That's a pretty hefty load - perhaps the intermittent lockup is due to
dips in the supply?  I mention this because it seems fairly likely, and
could be a completely separate problem from the other design issues.

> I would like to use Darlington Pair Transistors (I've used NPN arrays such
> as the ULN2003A in the past to drive relays) to drive the motors.  This
> should eliminate the Port Power consumption problems.  Before I jump in and
> do this, I have a few questions:
>
> 1.  Does anybody have experience with PNP Darlington Pairs?

Yeah, in the power range you seem to need they're just like the NPN parts
except for reversed polarity.

> 2.  Can I replace the "top" PNP with a NPN and make the motor terminal drive
> like a totem pole output?

If you can stand to lose 1.5 to 2 volts across the transistor, sure.  For
a battery-operated unit I would expect that you don't want to give up so
much.

> So, from these calculations, a 40K resistor should give me approximately 600
> mA through a Darlington Pair NPN Transistor driven by a PIC Pin.  Is this
> correct?

In this case, one problem is that you want those transistors to be
solidly in saturation to keep voltage drop to a minimum.  In saturation,
you can expect the output device to have a beta perhaps 1/10 (ballpark)
of its linear-mode value; the latter is what the beta of 5000 in he
datasheet is based upon.  Without looking into it in greater detail,
then, I would advise using a resistor at least ten times smaller.  The
only disadvantage in lowering it even further would be loading on the PIC
(and its supply, which really ought to be at least a a bit decoupled from
the raw supply that feeds the motors!) and total current consumption.
The latter seems unlikely to matter when you expect 300 to 400 mA to flow
in the motor windings.  :-)

> 4.  Is is possible to do away with the in-line resistor all together?  When
> I've used the ULN2003A in the past, I've driven the Darlington pairs
> directly from TTL/CMOS.

Bad idea for common-emitter switches.  Even if you do decide to use a
follower for the "high" driver, the series resistor provides soemthing
other than the PIC that can be sacrificed when the output dies, etc.

> Ideally, I would like to use four NPN Darlington Pair Transistors driven
> directly from the PIC.

To keep the switching losses low, I would suggest complementary drivers.
Probably the simplest way to do this would be to use four PIC pins, each
wired to a single transistor through a suitable resistance.  You would
want to turn the currently-conducting devices off, delay a few uSec
(check out the storage time and turn-off specs), and then apply drive to
the pair that you wish to turn on.

1996\07\12@132515 by myke predko

flavicon
face
Hi Mark,

I've got a few answers to your questions:

The Driver Circuit is:

               3 Volts
                  |
                  |
                |<
   o----220-----|       2N4403 PNP Transistor
   |            |\
   |              |
   |              |
PIC-o              o------ To Motor and 0.68 uF Cap in Parallel
   |              |        - Other Terminal of Motor has an
   |              |          Identical Circuit
   |            |/
   o----220-----|       2N4401 NPN Transistor
                |>
                  |
                  |
                  |
                 Gnd

All four Driver Circuits have a 10uF cap across 3Volts and Gnd for surge
protection.  Two of these circuits are used to drive the motor (one on each
motor terminal).

I've looked at the motors running on the PIC and I haven't seen any
significant brush noise (at least not compared to the 3-5 Volt Step Up).  I
will keep that in mind, however.

I was wondering about using N-Channel MOSFETs for this application.  Do you
have any recommendations for circuits?

Thanx for taking the time to read through the post and reply.  It's muchly
appreciated,

Myke

>>Does anybody have any hints on driving motors with the PIC?  I'm still
><snip>
>>The motor driver is an "H" transistor Driver (a PNP 2N4403 from 3 Volts
>>(battery) to a motor terminal to an NPN 2N4401 dropping the circuit to
Ground).
>>The Transistor bases are connected to a PIC driver via a 750 Ohm resistor.
>
>Are the collectors tied together (at the motor) and the bases tied together?
>This won't work.  I don't understand your circuit.  (I don't have the
magazine).
{Quote hidden}

Motor
{Quote hidden}

resistor for
{Quote hidden}

Do you ever feel like an XT Clone caught in the Pentium Pro Zone?

1996\07\12@163817 by Mark K Sullivan
flavicon
face
I missed the fact that the PIC also has a 4.8V supply.  You *could* use this to
drive the base of an NPN high side driver, but I like the complementary version
better.

How about this:


                         3 Volts
                            |
                            |
                          |<
                o---------|       2N4403 PNP Transistor
                |         |\
                |           |
              |<            |
PIC---4.7K----|             o------ To motor, etc
              |\            |
                |           |
                |           |
    GND----78---o           |
                            |
                            |
    3V ----78---o           |
                |           |
              |/            |
PIC---4.7K----|             |
              |>            |
                |         |/
                o---------|       2N4401 NPN Transistor
                          |>
                            |
                            |
                            |
                           Gnd

As I suggested before, use the PIC software to insert appropriate delays (a few
10s of uSec) between turning of the PNP and on the NPN.  If you're short on I/O,
go ahead and tie the PIC ends of the 4.7Ks together like your original circuit.

Adjust drive by changing 78 ohm resistors.  I figured it for 600 mA of output at
Beta of 20.  This may be excessive (but I bet it'll work).  You could cut back
to, say 120 ohms, and conserve power.

I have used Zetex low threshold (aka logic compatible) N channel MOSFETS from
Digi-Key with good results.  I don't know if they have a suitable P channel.
Check also Supertex, Unitrode, Motorola, and IR.

- Mark Sullivan -

1996\07\15@025811 by Prashant Bhandary

flavicon
picon face
At 11:31 AM 12/07/96 EDT, you wrote:
>Does anybody have any hints on driving motors with the PIC?  I'm still
>trying to get my I/R Robot working and my biggest (and hopefully last)
>problem is with the motors.
>
>should eliminate the Port Power consumption problems.  Before I jump in and
>do this, I have a few questions:
>
>1.  Does anybody have experience with PNP Darlington Pairs?
>
>2.  Can I replace the "top" PNP with a NPN and make the motor terminal drive
>like a totem pole output?

How about using an L293 IC? They are a bit expensive but have 2 H bridges and
operate off logic level signals. I've used it successfully  to drive 1 amp
motors
using a PIC 16C84. Speed control is done with PWM which is what I did. They cost
about AU$15 and handle up to 600mA(1A on some versions).

Regards

Prashant
+----------------+  -------------------------------------------------
|                |    Prashant Bhandary
|   +---+        |    Spatial Information Systems Section
|   |   |        |    Roads and Traffic Authority
|   |   |        |    Rosebery NSW 2018, AUSTRALIA
|   |   |        |    Tel:  +61-2-662 5299
|   |   +----+   |    Fax:  +61-2-662 5348
|   |        |   |    Email: spam_OUTprashbTakeThisOuTspamrta.nsw.gov.au
|   +--------+   |
| Still a newbie |    "2b|!2b" - William Shakespeare
+----------------+  -------------------------------------------------

1996\07\15@105932 by Mark K Sullivan

flavicon
face
The L293 is a good part but will not work with 3V supplies.  You might find a
brushless motor driver (three half-bridges) for this power supply but I don't
know of one of the top of my head.

- Mark Sullivan -

1996\07\15@141641 by Reginald Neale

flavicon
face
>At 11:31 AM 12/07/96 EDT, you wrote:
>>Does anybody have any hints on driving motors with the PIC?  I'm still
>>trying to get my I/R Robot working and my biggest (and hopefully last)
>>problem is with the motors.

You might want to look at the Motorola MC33030 chip. Microcontroller
interfacing isn't exactly what it was intended for, but it is designed to
drive small motors and has a lot of support stuff built in. I believe it's
less than US$5.

.....................Reg Neale.....................
"Ignorance is a renewable resource"   P.J. O'Rourke

More... (looser matching)
- Last day of these posts
- In 1996 , 1997 only
- Today
- New search...