First L293D Motor Driver Project

agroom

New Member
I'm working on a project where I want to drive 2 DC motors, both programatically and with a with a pot, inputting to an 14M2 A/D. I've been doing some research on here and sounds like the L293D driver would work great. I'm still pretty new and I've never used an L293 before, so I'd like to know if I'm doing this right.

14M2 Circuit_schem.jpg

The pins on the programmer input might not be 100% correct since I didn't know which one was which based on the pic, but I use the breadboard adapter anyway. I'm also using a 14M2 even though the circuit says 14M. I couldn't find an M2 part.
 
Last edited:

Technical

Technical Support
Staff member
If we stand on our head it looks ok, but it is very confusing to others to put 0V rail at the top and V+ rail at the bottom!
You want some more decoupling capacitors in there as well, particularly if a noisy motor.
 

agroom

New Member
If we stand on our head it looks ok, but it is very confusing to others to put 0V rail at the top and V+ rail at the bottom!
lol, sorry. I've seen people put rails in their schematics but I've never had any training so I don't know the standard etiquette. It's been bad enough just trying to find a schematic program I can use.

You want some more decoupling capacitors in there as well, particularly if a noisy motor.
Where would I put them? I have very little experience with this kind of stuff.

But otherwise it looks pretty good?
 

SAborn

Senior Member
If its your first ever schematic, than well done.
On an average the V+ is drawn to the top of the diagram and the V0 to the bottom of the diagram, but there is no real hard rule other than having the lines drawn in, it would also help if you labelled the V+ and V0 lines.

You show the enable (EN) pins of the L293 connected to V+, this is ok, but it would be better if you used a picaxe pin (or 2) to control the enable pins, this then allows for the motors to be turned off with the picaxe or even PWM used via the enable pin to control motor speed.
 

BeanieBots

Moderator
I agree with SAborn about the use of enable but I'm not so sure about his comment about diagram rules.
A circuit diagram is like a language and just like any language there are rules which include good grammer.
Without good grammer, you might still be understood but it can lead to confusion and other perceptions!
Whenever possible, your diagram should be drawn with (conventional) current flowing from top to bottom and signals flowing from left to right. (inputs on the left, outputs on the right).
 

SAborn

Senior Member
BB, i do fully agree with schematic lay out rules, but was implying in this case a schematic of any type is worth credit,(from what i gather to be a first attempt) and its really up to the artist of how they perceive the layout.

I have done schematics where the client has requested it to mirror the circuit board (pain in the ass) where a simple layout is less confusing to the eye using a more open layout of left to right and top to bottom of a standard design.

I still say 10 points for trying and 4 points for ability, ability will only get better once someone attempts to try.

At the end of it, if its labelled to clealy indicate what goes where it dont matter, but the lack of labels causes confusion when we assume a standard schematic format.

I still remember my first computer constructed schematic, and i was very impressed with my development, looking back it was crud, but we all start somewhere and develop skills along the way.
 

agroom

New Member
If its your first ever schematic, than well done.
Well, I mean it's not my first ever. In class we obviously have to draw them quite often, but usually just simple ones with a source and only a few basic components meant to explain something rather than to be used to build an actual circuit. To-date though, this might be the most "complicated" I've done. I've seen lots of examples while researching online, etc. so I get the gist of it. But like I said, I've never really been taught any of the "etiquette".

On an average the V+ is drawn to the top of the diagram and the V0 to the bottom of the diagram, but there is no real hard rule other than having the lines drawn in, it would also help if you labelled the V+ and V0 lines.
You know, I originally had it drawn up with a single cell DC battery source so the +/- lines were well defined, but then I realized I was going to be supplying power using a terminal hook-up so made a last minute change and didn't realize I left out the labels.

You show the enable (EN) pins of the L293 connected to V+, this is ok, but it would be better if you used a picaxe pin (or 2) to control the enable pins, this then allows for the motors to be turned off with the picaxe or even PWM used via the enable pin to control motor speed.
I have the datasheet for the L293, but it didn't really explain what the enable pins were. I Googled "L293 Circuits" and based much of my circuit off examples I found where the V+ and Enable pins were all tied to the same line. I guess I did assume that the enable pin basically meant "to enable" that motor, but didn't know if it was simply done off a boolean 1/0 or what. That does make sense though and I think I'll definitely amend the circuit so the pixaxe controls this. I could probably do it with 1 pin since I can't think of a situation off hand where I'll only be using 1 motor and the other would not need to be enabled.
 

agroom

New Member
I agree with SAborn about the use of enable but I'm not so sure about his comment about diagram rules.
A circuit diagram is like a language and just like any language there are rules which include good grammer.
Without good grammer, you might still be understood but it can lead to confusion and other perceptions!
Whenever possible, your diagram should be drawn with (conventional) current flowing from top to bottom and signals flowing from left to right. (inputs on the left, outputs on the right).
I completely agree with you on this. I might be a beginner on this, but I have other advanced skills where I would argue this point to someone in my situation. I'm actually a little disapointed, while making this circuit I realized that even after 2 years of tech school training we've yet to have any formal training in circuit design. I emailed one of my profs and they even said there's no class in the program that does this, but most students by the end of the 4 years are typically pretty good with this anyway.

I've been using a program called Fritzing, which seems to work well enough without any training, but has some severe limitations. I've installed and tried using Eagle's Layout Editor, but I can tell that it's going to require me spending some time going through their tutorials and getting started guides. At this point, I just can't find the time to do it yet :(
 

agroom

New Member
Oh, Technical also mentioned using more decoupling capacitors. Could someone expand on this for me a bit? I understand the concept of decoupling, but I don't know how to apply it (or more specifically, how it applies) to this application.

Thanks again for everyone that's responded!
 

boriz

Senior Member
100n across chip power pins, physically close. Both chips. Reduces high frequency noise getting into the chips and causing problems.

10n across motor pins. Physically close. Both motors. Reduces EMF spikes and RF noise from motors.
 

agroom

New Member
10n across motor pins. Physically close. Both motors. Reduces EMF spikes and RF noise from motors.
I'm not exactly sure what you mean by "across motor pins." Do you mean between pins 3-6 and 11-14? I did some more looking around this morning and found this posted in Arduino's forum. The first picture shows a decoupling circuit from a motor run directly from supply/gnd. The 2nd shows it applied to an L293 chip and added to the chip's power and ground lines. The guy posting it seems like he's in a similar situation as me, not knowing for sure what should be done, and unfortunately there was no resolution to his question. But I think it provides good examples to go on.

Motor Decoupling.png

L293D Decoupling.png

I'm not sure what size motors he's using and I'm not sure if this is more than what I needed for my application, but since parts are cheap I don't mind adding all this to my circuit. I just need to know where :)

Physically close.
The motors are not mounted on the PCB. I haven't decided on the size layout of the project box yet, but I think it's possible the motors could be up to 20cm from the L293 chip. So if the caps need to be added to the lines running from the chip to the motors, do you mean close to the motors or the chip?

Thanks again everyone for your responses! I really appreciate the help, this is a project I'd really like to get done and I'd like to make something that will last.
 

JimPerry

Senior Member
I'm not exactly sure what you mean by "across motor pins." .
10n (or 100n) physically on the motor tags - not the Picaxe board end - the 100n chip caps are across the chip power pins on the board

Big 1000uF between the whole project power leads
 

agroom

New Member
Okay, let's see how close I have it now. I made some changes to the schematic too:
  • Cleaned up the design a little and straightened the traces.
  • Added capacitors across the PICAXE Vin and motor pins.
  • Added a battery instead of the terminal block for clarity and put the rails in the correct places.
  • Ran enable pins off PICAXE.
  • Added an LCD screen to display motor speeds. I have the AXE-133 module which only requires power, ground and serial in (used the R/W pin), so ignore the other pins.
  • Broke out the motors since they'll be separate from the main circuit and added connection terminals.
I didn't know which kind of caps to use for each application. There's an electrolytic across the PICAXE Vin and ceramic for the rest, but I have no idea if that's right or wrong.

14M2 Circuit v1.1.png
 

JimPerry

Senior Member
Much better - still need 100n ceramic (or mylar) across the 1/14 Picaxe and 8/5 on the driver -- both physically close to the chips.
 

agroom

New Member
Much better - still need 100n ceramic (or mylar) across the 1/14 Picaxe and 8/5 on the driver -- both physically close to the chips.
Thanks :)

Do you mean add a 2nd 100n across the 1/14 picaxe? I have an electrolytic already on the schematic, or should I change that to a ceramic? On the driver, I should probably add one across 16/13 then too? (Vcc1 and Vcc2)
 

JimPerry

Senior Member
The Electrolytic and mylar do different jobs - 100uF acts as a type of resevoir for large/slow changes in voltage and the 100nF soaks up high frequency noise
 

agroom

New Member
Sorry, I've been busy the last few days but I thought I'd post a final drawing with the caps added.

Project Schematic v1.1.jpg

I went back to terminals for Vin, but I forgot to label them. + is still along the top and - on the bottom.
 

JimPerry

Senior Member
Getting better - you probably have 2 too many 100uF Electrolytice - on a small circuit one would be enough (or a single larger one) and it would normally be shown on the left of your circuit from +v to -v.

The smaller 100nF do get spread around the circuit physically as they do a very different job where distance matters to their effectiveness.
 

SAborn

Senior Member
My view of the caps were some are labled wrong and should have been 1 x 0.1uf and 1 x 100uf and not 2 x 100uf.
 

agroom

New Member
Getting better - you probably have 2 too many 100uF Electrolytice - on a small circuit one would be enough (or a single larger one) and it would normally be shown on the left of your circuit from +v to -v.
Oh that's right, you mentioned it above and I forgot to change it. Thanks for the catch ;)

The purpose of the caps is for decoupling, but let me just make sure I'm 100% sure what that means. It essentially helps flatten out any voltage spikes/drops to keep voltage constant correct?

The smaller 100nF do get spread around the circuit physically as they do a very different job where distance matters to their effectiveness.
Building on that, the values of the caps are somewhat arbitrary. By that I mean there's values that can be too big or too small, but it's not as if there's a calculated range that it needs to be in right? What happens if the values are too big or too small? Why the two different types, is it because a larger capacitance need across V+/- and ceramic just don't get that big?

As a side test, I wired up a pot and used it to cycle through colors on an RGB LED. When initially hooking it up, I put a 100nF cap across the center pin to ground and it worked pretty good. I then took out the cap and noticed a HUGE difference. Without touching the pot, the LED would constantly flicker just a little bit. I realize it's just simple concept, but pretty cool to see in action none-the-less.

Sorry for the 20Q's and I truly appreciate all the help and feedback from everyone! For everything they've taught us in school, we've never covered what the different types of capacitors are used for. RadioShack has a decent description page, but it's still kind of vague. I'd welcome any links on good descriptions!
 

agroom

New Member
My view of the caps were some are labled wrong and should have been 1 x 0.1uf and 1 x 100uf and not 2 x 100uf.
Opps! Yep, absolutely correct. The smaller ceramic should be 100nf and I'm replacing all the polarized caps with a single 1000uF cap across V+/-. Should have the updated schematic up soon.
 

westaust55

Moderator
Opps! Yep, absolutely correct. The smaller ceramic should be 100nf and I'm replacing all the polarized caps with a single 1000uF cap across V+/-. Should have the updated schematic up soon.
Beware also the possible problems with using too large an electrolytic across the supply.
If the electro is quite large then it takes a finite time to charge up to the supply voltage.
This can slow down the rise time for the Vcc to the PICAXE and the LCD.
With LCD's in particular, if the supply voltage does not rise in sufficient time they may not initialise properly.
 

jedynakiewicz

Senior Member
Beware also the possible problems with using too large an electrolytic across the supply.
If the electro is quite large then it takes a finite time to charge up to the supply voltage.
This can slow down the rise time for the Vcc to the PICAXE and the LCD.
With LCD's in particular, if the supply voltage does not rise in sufficient time they may not initialise properly.
Most interesting... How large is TOO large? I guess it depends upon the current available from the power supply. But I was drawn to this comment in the light of Hippy's approach to power supplies in this thread:
http://www.picaxeforum.co.uk/showthread.php?21010-Power-supply&p=218297
where he state "I usually throw a 22000uF or 47000uF on the input of a 7805 along with 100nF on input and output close to the regulator and have never noticed any problems. ". These seem pretty big in comparison to the accepted norm but clearly he has no issues with capacitors of this size. @WestAust55 - what size do you consider too large and in relation to what available current in the power supply? What size have you had an initialisation failure with?
 

westaust55

Moderator
@WestAust55 - what size do you consider too large and in relation to what available current in the power supply? What size have you had an initialisation failure with? .
My comment was as a result of schematics showing several 100 uF caps and post 13 where JimPerry had stated:
Big 1000uF between the whole project power leads
Later JimPerry and SAborn have recommended 100 uF as sufficient.

The link to hippys post related to very large electro caps on the input side of a voltage regulator (eg 7805).
Hippy also recommends smaller electros for the load side.

The required size needs to consider any large brief current draws to hold the voltage up and prevent the PICAXE or other devices resetting.

Specific to LCS's based upon the Hitachi HD44780 controller chip, for the internal reset circuit to work and initialise the chip when working on a 5V supply, the voltage must reach 4.5 Vdc in 0.1 ms (min) to 10 ms (max).

Capacitors such as 1,000 uF electolytics on the load side of a 7805 can result in the LCD internal reset not occuring properly and needing to perform a software initialisation.
Note this initialisation is different to the subsequent mode set-up to define 4 or 8 bit interface and other cursor/scrolling features.
 

agroom

New Member
So I've made some updates/changes, removing the 3 smaller electro caps and replacing them with a single 1mF across the power supply. Based on the discussion about what's "too big," as long as having one that's too big isn't going to cause any damage, I figured I'd start out with this one and reduce the size if I notice any issues.

 

jedynakiewicz

Senior Member
@Westaust55 - Thank you for that clarification - lucid and succinct as always.
@agroom - I note that C7 & C8 are 100nF; Picaxe Manual 3 (page 12) recommends for motor supression "Use a 220nF polyester (non-polarise) capacitor" . I have always followed this guideline and for the motors that I use it seems to work really well. I have connected up an oscilloscope to have a look and it quite remarkable how effective these are in supressing the noise. 100nF or 220nF? @Westaust55 - do you think it would make much difference?

Also, please note what Westaust55 recommended; the large capacitor in the power leads needs to be on the other side of the voltage regulator (wherever you have that).

Finally, if your motors are really noisy then I think that you may find that separate power supplies to the PICAXE and to the motors may be needed.
 
Top