control your motors with l293d and arduino.pdf

11
After long research and trial and error, I have came up to a new walkthrough regarding this nice chip, the L293D. Each project is one project and each one has its own unique power configurations, so you must be aware of the best battery choice and how to distribute voltage through your robot. I strongly advice you to read the following articles: Picking Batteries for your Robot (http://letsmakerobots.com/node/3819) Once you've decided on batteries, how do you regulate the voltage (http://letsmakerobots.com/node/3880) ************************************************ L293D gives you the possibility to control two motors in both directions - (http://cdn.instructables.com/FVV/RMZ7/FTY4CX3A/FVVRMZ7FTY4CX3A.LARGE.jpg) About This Instructable License: 222,049 views 313 favorites guibot (/member/guibot/) (/) let's make share what you make > (/editInstructable/) (/) Explore (/tag/type-id/) Create (/about/submit.jsp) Contests (/contest/) Community (/community/) Login (/account/login) | Sign Up (/account/gopro?sourcea=header)

Upload: matatandaanmatanda

Post on 26-Dec-2015

181 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Control your motors with L293D and Arduino.pdf

After long research and trial and error, I have came up to a new walkthroughregarding this nice chip, the L293D.

Each project is one project and each one has its own unique powerconfigurations, so you must be aware of the best battery choice and how todistribute voltage through your robot.

I strongly advice you to read the following articles:

Picking Batteries for your Robot (http://letsmakerobots.com/node/3819)Once you've decided on batteries, how do you regulate the voltage(http://letsmakerobots.com/node/3880)

************************************************

L293D gives you the possibility to control two motors in both directions -

(http://cdn.instructables.com/FVV/RMZ7/FTY4CX3A/FVVRMZ7FTY4CX3A.LARGE.jpg)

About This Instructable

License:222,049 views

313 favorites

guibot(/member/guibot/)

(/)

let's make

share what you make >

(/editInstructable/)(/)

Explore (/tag/type-id/) Create (/about/submit.jsp) Contests (/contest/) Community (/community/)Login (/account/login) | Sign Up (/account/gopro?sourcea=header)

Page 2: Control your motors with L293D and Arduino.pdf

datasheet(http://www.datasheetcatalog.org/datasheet/texasinstruments/l293d.pdf)

Remove these ads by Signing Up (/account/gopro?sourcea=removeads&nxtPgName=Control+your+motors+with+L293D+and+Arduino&nxtPg=/id/Control-your-motors-with-L293D-and-Arduino/)

Step 1: Basic implementation

Related

(http://cdn.instructables.com/F8T/QPXM/FTY4CX3G/F8TQPXMFTY4CX3G.LARGE.jpg)

(/member/guibot/)

Follow

Designer & digital artist

38

Bio:

(/id/HiTec-Servo-Hack)

(/id/Clever-ways-of-attaching-components)

(/id/making-wheels-out-of-plastic-bottles)

More by guibot

l293d (/tag/type-id/category-technology/keyword-

l293d/)

breadboard (/tag/type-id/category-

technology/keyword-breadboard/)

circuit (/tag/type-id/category-technology/keyword-

circuit/)

ic (/tag/type-id/category-technology/keyword-ic/)

arduino (/tag/type-id/category-technology/keyword-

arduino/)

motor (/tag/type-id/category-technology/keyword-

motor/)

dc motor (/tag/type-id/category-technology/keyword-

dc motor/)

microcontroller (/tag/type-id/category-

technology/keyword-microcontroller/)

robot (/tag/type-id/category-technology/keyword-

robot/)

Tags:

GOduino II = Arduino +L293D Variable SpeedMotor Controller(/id/GOduino-II-Arduino-L293D-Variable-Speed-GOduino - The ArduinoUno + Motor Driver clone(/id/GOduino-The-Arduino-Uno-Motor-Driver-clone/)GOduino III - thebreadboard-friendlyArduino-based robotcontroller (/id/GOduino-III-the-breadboard-friendly-Arduino and L293D Robot( Part 1 ) (/id/Arduino-and-L293D-Robot-Part-1-/)by AgentWolf(/member/AgentWolf/)

Page 3: Control your motors with L293D and Arduino.pdf

This is the most basic implementation of the chip.

As you can see, a 5V Voltage Regulator is between the battery and pins 1, 9,16.

Pin 8 gets power before the VReg, if your motor needs for example 6V youshould put 6V directly in this pin, all the other pins should not get more than 5V.

This will work with no problem at all, but if you want to do the rightimplementation take a look at the next example:

Step 2: Advanced implementation

See More (/tag/type-id/?q=)

(http://cdn.instructables.com/FE3/62KS/FTY4CX3L/FE362KSFTY4CX3L.LARGE.jpg)

(http://cdn.instructables.com/FXZ/DQVS/FTY4CX3U/FXZDQVSFTY4CX3U.LARGE.jpg)

Ship controled bybluetooth. (/id/Ship-controled-by-bluetooth/)

Control your motors with L293D and Arduino by guibot (/member/guibot/)

Collection I Made it!

Download (/id/Control-your-motors-with-L293D-and-Arduino/?download=pdf)

(/id/Control-your-motors-with-L293D-and-Arduino/?ALLSTEPS) 3 Steps (/id/Control-your-motors-with-L293D-and-Arduino/step3/Arduino-code/)

Favorite Share

Page 4: Control your motors with L293D and Arduino.pdf

Next » (/id/Control-your-motors-with-L293D-and-Arduino/step3/Arduino-code/)

View All Steps (/id/Control-your-motors-with-L293D-and-Arduino/?ALLSTEPS)

We have a be nice comment policy. Please be positive and constructive.

I Made it! Add Images Make Comment

This is the correct Implementation (with the capacitors), and note that pin 8 isfeeded by unregulated voltage. This means that if your motors need more than5V, you should power this pin with that amount of voltage, and the rest of thecircuit with 5V.

1-40of 70

Next » (http://www.instructables.com/id/Control-your-motors-with-L293D-and-Arduino/?&sort=ACTIVE&limit=40&offset=40#DISCUSS)

(http://cdn.instructables.com/FFA/1KW7/FTY4CX3X/FFA1KW7FTY4CX3X.LARGE.jpg)

(http://cdn.instructables.com/FNM/7QIU/FTY4CX46/FNM7QIUFTY4CX46.LARGE.jpg)

(http://cdn.instructables.com/FI8/JXB5/FTY4CX41/FI8JXB5FTY4CX41.LARGE.jpg)

« Previous

Page 5: Control your motors with L293D and Arduino.pdf

(/member/DanM5/)

1 month ago Reply (CJ8JB3EI0A5AMFK)

(/member/skadd4life/)

7 months ago Reply (C5K7F7FHTH6LYVT)

(/member/skadd4life/)

7 months ago Reply (CMW7RQRHTH6LYW1)

(/member/ccarpio2/)

6 months ago Reply (CU8ULGKHUIHITBX)

(/member/JamesT2/)

2 months ago Reply (CR450IWHZMJ2C6X)

(/member/JamesT2/)

2 months ago Reply (CXHMAXBHZMJ2C1I)

(/member/supershwa/)

1 year ago Reply (CSH2XM4HN4ZV7F6)

DanM5 (/member/DanM5/)

Thanks for the post. I made this circuit and it worked well. The photo was takenbefore I found the error on only hooking the unregulated power to one pin.

(http://cdn.instructables.com/FMY/6DJW/I0A5ALJW/FMY6DJWI0A5ALJW.LARGE.jpg)

skadd4life (/member/skadd4life/)

Hello! I want to use a 5v motor, and use a 5v DC powersource (not battery, wall plug).Do I still need to regulate my voltage? Can my 5V source be used for Vs pin of theL293D and microcontroller Vcc? Or, do I somehow need to isolate the 5v betweenthose inputs? Thanks!

skadd4life (/member/skadd4life/) skadd4life

BTW, I plan to use ATtiny toprovide PWM to L293D.

ccarpio2 (/member/ccarpio2/) skadd4life

How did I go with the Attiny? I wantto try as well

JamesT2 (/member/JamesT2/) ccarpio2

You can see how to use an ATtinyon my blog. It shows how toprogram it and everything.

http://jamestav.com/programming-an-attiny85-with-an-arduino/

JamesT2 (/member/JamesT2/)

I like it! You are very detailed and specific. There is also an Adafruit Shield thatuses 2 of those chips and is very good. They're cheap as well, like 5 or 6 bucks. Ihave a tutorial on how to use them http://jamestav.com/l293d-motor-shield/

supershwa (/member/supershwa/)

Good instructable - to clarify, the [battery] in this example powers the motorsseparate from the Arduino power source: the Arduino controlling this circuit has aseparate power source (an additional 7-12v source plugged into the Arduino.) Youshould be able to use a 9v battery for the motors, and a separate 9v for theArduino (the motors can run faster this way.)

supershwa (/member/supershwa/) supershwa

Page 6: Control your motors with L293D and Arduino.pdf

(/member/supershwa/)

1 year ago Reply (C8QAQX1HN4ZV7FI)

(/member/ktrantham/)

2 months ago Reply (CIO5ZPKHYE60RHF)

(/member/oddWires/)

1 year ago Reply (CY02I6JHNID3J7V)

(/member/Kante+Tech/)

3 months ago Reply (C1KSY9YHXDP4CMO)

(/member/magiccircuit/)

6 months ago Reply (C96V3XOHUCTRPAO)

(/member/pradipta03/)

10 months ago Reply (CIUEVNJHPNAL755)

(/member/guibot/)

10 months ago Reply (CNQ7Q51HPNALA2J)

(/member/pradipta03/)

10 months ago Reply (CCLT5TOHPNALA7A)

By the way - L293D chips aren't at RadioShack...I waited 3 weeks to getthem from China.

ktrantham (/member/ktrantham/) supershwa

Wow that sucks a month. You knowyou can get free samples fromTexas Instruments right??TheCompany who makes them!

oddWires (/member/oddWires/) supershwa

oddWires has lots of L293Ds at the linkbelow in the San Francisco bay areashipping world-wide. Also look forspecial offer of 10% discount inNovember for instructables members.Use SAVE10 as coupon code.Disclaimer: I work for oddWires.

http://www.oddwires.com/l293d-stepper-motor-controller-driver-ic/

Kante Tech (/member/Kante+Tech/)

Do you have a pcb layout to show how you would etch this or a schematicbecause im confused with the wiring for the gnd pins

magiccircuit (/member/magiccircuit/)

Hi thanks for this article, it's very help full for me. Here is my video where i usedL293d driver ic, arduino and mpu6050

https://www.youtube.com/watch?v=D5HY_tjW1lc

pradipta03 (/member/pradipta03/)

Thanks for the great cheap solution. I was trying this using PWM. and for lowerduty cycle it doesn't response very well. Say for example if i use analogWrite(40) itdoesn't response but if I go around 128 or above it responses. What do you thinkabout that?Any one had an issue with it?

guibot (/member/guibot/) (author) pradipta03

That is very normal tohappen, normally DC motorshave a minimum requiredvoltage to operate.

pradipta03 (/member/pradipta03/) guibot

Aha. Thank you.

mgarg5 (/member/mgarg5/)

Page 7: Control your motors with L293D and Arduino.pdf

(/member/mgarg5/)

1 year ago Reply (CSIMMTLHMKLN592)

(/member/EduanSnyman/)

1 year ago Reply (CW3FHJBHKF75GGE)

(/member/EduanSnyman/)

1 year ago Reply (CER843DHKF75GHC)

(/member/guibot/)

1 year ago Reply (C0RH9WNHJKBU39M)

(/member/Eman34/)

1 year ago Reply (CAJJ7MJHIYWO90G)

(/member/TorBoy9/)

2 years ago Reply (CA481QXH267L2XQ)

(/member/guibot/)

1 year ago Reply (C14E7L7HBFFJ2Z1)

(/member/guillempq/)

1 year ago Reply (CYX4NCJHAUNNUVJ)

(/member/ticapix/)

5 years ago Reply (C0CQHF3FTY4C7EV)

Sir just 2 questions, Can i use this setup for a robotic arm. I have 2 L293D chips ineed to inetrface. Is it posible? If yes then how? & also can i use Dc motors withjust power and ground for this setup instead of a motor with a feedback?

EduanSnyman (/member/EduanSnyman/)

Hi! This is a brilliant tutorial :D I do just want to ask something (I apologise if its anoob question); but the DC motor (For Linear actuator) that I will be using has itsown battery unit and will draw a maximum of 3A and will be operated at 12V. Isthis current too much for this setup? If it is, what should I do? Has it got to do withwhat the L293D can handle? Thank you! :D

EduanSnyman (/member/EduanSnyman/) EduanSnyman

Also, I am using an Arduino Uno tocontrol everything; the 3A isnt drawnthrough the Arduino right?

guibot (/member/guibot/) (author) EduanSnyman

Hi! The L293D can handle only600mA per channel, if you need3A, try pololu drivers, you havedrivers to handle 16A or evenmore. Good luck

Eman34 (/member/Eman34/)

Just wondering how you could integrate a joystick controller into this design?Thank you

TorBoy9 (/member/TorBoy9/)

I breadboarded this circuit and use the sketch as is. Both the circuit and the sketchwork without issue. The electrical schematic and the breadboard differ slightly. Iused the breadboard circuit. The Arduino pins 2,3 go to one side of the L293D,pins 7,8 go to the other side of the L293.

Your implementation into a circuit board also differs from the breadboard, such asthe added voltage regulator. If you have time, could you pls update your electricalschematic?

Anyway, thanks for the great 'ible.

guibot (/member/guibot/) (author) TorBoy9

thanks for your notes, this is avery old instructable, it will bedifficult to update ..

guillempq (/member/guillempq/)

Can you control a Brushless motor?

ticapix (/member/ticapix/)

Thanks for the article :) Can you explain or give to link which explain why you put

Page 8: Control your motors with L293D and Arduino.pdf

(/member/Wyle_E/)

5 years ago Reply (CWU0A47FTY4D61M)

(/member/booze.net/)

2 years ago Reply (CNHE6RYGXL5UK25)

(/member/ticapix/)

5 years ago Reply (CSWB0TXFTY4C7GW)

(/member/shanakaplus/)

3 years ago Reply (CPNQNRMGM7E7DSF)

(/member/moose4987/)

4 years ago Reply (CVCJ58WG962KF0S)

capacitors ? (and why this way ?) Diodes aren't good ?

Wyle_E (/member/Wyle_E/) ticapix

The capacitors from the motorleads to ground absorb noisegenerated by the motors.Motors are notorious forgenerating spikes that interferewith nearby logic and sensorcircuits. The big capacitoracross the battery smooths thesupply voltage, keeping theinternal resistance of the batteryfrom dragging the bus voltagedown when the current into thecircuit suddenly increases (likewhen you start a motor). Theparallel pair of capacitors from+5V to ground filter the logic-circuit supply. The bigelectrolytic capacitor soaks uplow-frequency trash, but isn't sogood at handling high-frequency noise, like thatgenerated by fast-switchinglogic. The .1 microfaradcapacitor is a ceramic orpolyester type that handles thehign frequencies.

booze.net (/member/booze.net/) Wyle_E

This post has been a great help tome. I had numerous problemsaffecting my logic as I hadn'timplement the ceramic capacitorsdetailed in your post. I was tearingmy hair out and temporarilyabandoned my project. Thank youvery much.

Paul

ticapix (/member/ticapix/) Wyle_E

thanks Wyle_E :)

shanakaplus (/member/shanakaplus/)

um looking for elevator avr program. Do you have example program ?

moose4987 (/member/moose4987/)

so, say i were to use a motor to turn a solar panel... if i used the voltage from thesolar panels which vary from 6-9 volts to power the arduino, could i also use thatunregulated voltage to power the L293?

chris27 (/member/chris27/)

Page 9: Control your motors with L293D and Arduino.pdf

(/member/chris27/)

4 years ago Reply (CBZHKZLG68GX9AL)

(/member/felixk/)

4 years ago Reply (CA78HWIG4D5WZ61)

(/member/mani.atico/)

5 years ago Reply (C3QMCSFFVO9RPCS)

(/member/icecreamterror/)

5 years ago Reply (CBN6GG2FYIZ4RJ6)

(/member/comodore/)

5 years ago Reply (CBBBQK7FTY4CRO3)

(/member/emmjul/)

5 years ago Reply (CZBY57LFUNOWMZ1)

Hey, sorry to bump an old thread, but I'm thinking of using four PICAXE 08-Mchips as slaves for DC motor control via PWM, routed through a L293D (fourmono-directional motors). The only example I've seen of this kind of setup(http://www.phanderson.com/picaxe/pwm_stamp.html(http://www.phanderson.com/picaxe/pwm_stamp.html)) seems to suggest that inorder to change the duty cycle of the PWM out, you have to pull pin 4 low, thenpulse a certain number of times in 100ms, then pull pin 4 high again. Is that true? If so, it's only possible to change the motor speed a maximum of 10 times persecond - which isn't very useful when making minute adjustments to respond togyro stabilisation. Anyone know of a better way to achieve this?

Cheers

felixk (/member/felixk/)

Great Job! :)

I noticed that in the final breadboard (Page 3 of the downloadable pdf), you haveincluded servo control and a couple of extra capacitors that are not in the systemdiagram. Any chance of a complete schematic of this circuit?

Thanks

mani.atico (/member/mani.atico/)

Hi,I'm new to electronics (follow instructions level) and this instructable helped me alot on bringing two motors to life with my arduino.

I have a basic question: is it better to use the 5V arduino output or a regulatedcurrent from the ext source (as shown on this instructable) for the L293D logicinput?

Thank you

icecreamterror (/member/icecreamterror/) mani.atico

ext source, always better withthe Arduino.

comodore (/member/comodore/)

Hi I like your Instructables very much! Great job! I have a question that I thinkyou may know the answer to. I need a small chip like this one that I canprogram and put it in a circuit so when it activates by a sensor ( in my case Iwant to put a light sensor (LDR))When light hits the light sensor It turns on amotor for a period of time (lets say 5 seconds). Then when the sensor finds itself in the dark it turns on the motor ( again for 5 sec) BUT IN THE oppositeDIRECTION. All in All When there is lite it turns on the motor for 5 sec on oneside (lets say left) when there is no light it turns the motor for 5 sec (on theoposite side, right) Do you know such a chip that will enable me to program itand make it do what I described??? Thank you! Stanislav

emmjul (/member/emmjul/) comodore

You can use the same setup,simply save the states of the ldrand you can check if there waslight before and have thearduino reverse the motor->

Page 10: Control your motors with L293D and Arduino.pdf

(/member/comodore/)

5 years ago Reply (CK6T999FUI0SF24)

(/member/emmjul/)

5 years ago Reply (CUEOZ9PFUI0X5V2)

(/member/comodore/)

5 years ago Reply (CBPX4WFFUVSG95Z)

(/member/dagenius/)

5 years ago Reply (CMSXORHFU54UBR9)

(/member/comodore/)

5 years ago Reply (CNU9DZAFU6LTDLO)

if ( pin 1 = high){turn right5 sec}if (pin 1 = low){turn left5 sec}

else{do nothing}

Hope I could help

comodore (/member/comodore/) emmjul

THANK YOU SO MUCH!!! OK, soI just upload this to the Arduino?On what pins do I connect themotor, LDR, power??? I neededsomeone to write the codebecause I am a complete n00b inprograming... THANK YOU!Could you please now just helpme, to say, put it together, like onwhat pins do I connect the motor,LDR, power... Can I remove theATMega chip and use it with outthe Arduino board, connecting thecomponents directly to the chip?Thank you!

emmjul (/member/emmjul/) comodore

no you can't, it's just pseudocodeso you can get an idea what youhave to programm, sadly I don'town an arduino so I can't write itfor you. sry

comodore (/member/comodore/) emmjul

Well... Thanks any way...Thanks, you helped me! :D

dagenius (/member/dagenius/) comodore

If that is all you are looking todo, then a pickaxe 08-Mcoupled with the circuit in thisinstructable should do the trick.the cheapest 08-M that I foundwas about $3.00 USD.

comodore (/member/comodore/) dagenius

And how do you program them?Thanks!

Page 11: Control your motors with L293D and Arduino.pdf

We have a be nice comment policy. Please be positive and constructive.

I Made it! Add Images Make Comment

1-40of 70

Next » (http://www.instructables.com/id/Control-your-motors-with-L293D-and-Arduino/?&sort=ACTIVE&limit=40&offset=40#DISCUSS)

About UsWho We Are (/about/)Advertise (/advertise/)Contact (/about/contact.jsp)Jobs (/community/Positions-available-at-Instructables/)Help (/id/how-to-write-a-great-instructable/)

Find UsFacebook (http://www.facebook.com/instructables)

Youtube (http://www.youtube.com/user/instructablestv)

Twitter (http://www.twitter.com/instructables)

Pinterest (http://www.pinterest.com/instructables)

Google+ (https://plus.google.com/+instructables)

Tumblr (http://instructables.tumblr.com)

ResourcesFor Teachers (/teachers/)Artists in Residence (http://www.autodesk.com/artist-in-residence/home)Gift Pro Account (/account/give?sourcea=footer)Forums (/community/)Answers (/tag/type-question/?sort=RECENT)Sitemap (/sitemap/)

Go Pro Today » (/account/gopro?sourcea=footer)

We're Hiring! » (/community/Positions-available-at-Instructables/)

MobileDownload our new apps for iOS,Android and Windows 8!

Android(https://play.google.com/store/apps/details?

id=com.adsk.instructables)

iOS(https://itunes.apple.com/app/instructables/id586765571)

Windows(http://apps.microsoft.com/windows/en-

us/app/7afc8194-c771-441a-9590-54250d6a8300)

Join our newsletter:

Terms of Service (http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=21959721) |Privacy Statement (http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=21292079) |Legal Notices & Trademarks (http://usa.autodesk.com/legal-notices-trademarks/) | Mobile Site (http://m.instructables.com)

(http://usa.autodesk.com/adsk/servlet/pc/index?id=20781545&siteID=123112)

(/halloween/)

Join!

© 2014 Autodesk, Inc.

Englishenter email