){.nav-menu .menu-item-has-children a{padding-right:20px}.nav-menu .menu-item-has-children a:after{position:absolute;right:7px;top:10}}.vce-ad-container{margin:30px auto;display:block;clear:both;width:728px;position:relative;max-width:100%}.vce-ad-below-header{margin-bottom:0}@media only screen and (max-width:1200px) and (min-width:1024px){.vce-ad-container{width:630px}.vce-ad-below-header{width:728px}}@media only screen and (max-width:1023px){.vce-ad-below-header,.vce-ad-container{width:728px}}@media (max-width:767px){.vce-ad-container{width:375px}}@media (max-width:400px){.vce-ad-container{width:300px}}@media (max-width:320px){.vce-ad-container{width:280px;max-width:100%}}:root .main-navigation ul ul{opacity:1}@media only screen and (min-width:1024px) and (max-width:1200px){.container{max-width:1000px}.vce-main-content{width:700px}.main-navigation ul ul{display:none}.top-header{overflow:hidden}.main-navigation a{padding:15px 9px 15px}.search-header-wrap a{padding:15px}.header-3-wrapper .site-branding{max-width:300px}h1.entry-title{width:540px}.entry-title{display:block}}@media only screen and (min-width:670px) and (max-width:1023px){.header-3-wrapper .site-branding{max-width:300px}.header-3-wrapper .nav-menu>li>a{padding:0 15px}h1.entry-title{width:540px}.entry-title{display:block}}@media only screen and (max-width:1023px){.container{max-width:90%}.vce-main-content{width:100%;padding:15px 0!important}.main-navigation ul ul{display:none}.vce-res-nav{float:left;position:absolute;left:0}.header-3-wrapper{height:50px!important;padding-top:0!important;text-align:center}.header-3-wrapper .site-branding{position:relative;float:none;top:0!important;left:initial!important;text-align:center;max-width:initial;padding:3px 0 7px}.site-branding{padding:4px 0 7px;display:inline-block}.site-branding img{max-width:120px;max-height:28px}.main-header .header-3-wrapper .site-title,.main-header .header-3-wrapper .site-title a.has-logo{line-height:40px!important;font-size:26px!important}.sidebar{margin:0 auto 20px;float:none!important;display:block;clear:both;padding-top:0!important;width:100%;max-width:300px}h1.entry-title{max-width:100%}.vce-responsive-nav{display:block;margin:10px 0 9px}.nav-menu,.top-header{display:none}.main-header .site-title,.main-header .site-title a{line-height:36px!important;font-size:40px!important}li>ul{margin:0}}@media only screen and (min-width:200px) and (max-width:670px){html{margin-top:0!important;overflow-x:visible}html body,button,input,textarea{font-size:14px;line-height:22px}.container{max-width:95%}.vce-main-content{padding:0 0 10px!important}.main-box,.sidebar .widget{margin-bottom:10px}.vce-wrap-right{width:100%;max-width:100%;text-align:center}.vce-single .entry-header{margin:20px 0}.vce-wrap-right{text-align:center}body h1.entry-title{font-size:24px;line-height:30px;padding:0 20px}body p{margin-bottom:20px}body h1{font-size:24px;line-height:34px;margin-bottom:10px}body h4{font-size:18px;line-height:28px;margin-bottom:10px}.sidebar .widget-title{line-height:22px}.vce-wrap-right>ul{float:none;display:inline-block;margin:10px 0 0}}#cookie-notice *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}#cookie-notice .cookie-notice-container{display:block}#cookie-notice.cookie-notice-hidden .cookie-notice-container{display:none}.cookie-notice-container{padding:15px 30px;text-align:center;width:100%;z-index:2}.cn-close-icon{position:absolute;right:15px;top:50%;margin-top:-10px;width:15px;height:15px;opacity:.5;padding:10px;outline:none}.cn-close-icon:before,.cn-close-icon:after{position:absolute;content:' ';height:15px;width:2px;top:3px;background-color:#fff}.cn-close-icon:before{transform:rotate(45deg)}.cn-close-icon:after{transform:rotate(-45deg)}#cookie-notice .cn-button{margin:0 0 0 10px}.cn-button.bootstrap{font-family:-apple-system,BlinkMacSystemFont,Arial,Roboto,"Helvetica Neue",sans-serif;font-weight:400;font-size:13px;letter-spacing:.25px;line-height:20px;margin:0;text-align:center;text-transform:none;display:inline-block;touch-action:manipulation;white-space:nowrap;outline:none;box-shadow:none;text-shadow:none;border:none;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;text-decoration:none;padding:8.5px 10px;line-height:1}.cn-button.bootstrap{color:#fff;background:#20C19E}.cn-text-container{margin:0 0 6px 0}.cn-text-container,.cn-buttons-container{display:inline-block}@media all and (max-width:900px){.cookie-notice-container #cn-notice-text{display:block}.cookie-notice-container #cn-notice-buttons{display:block}#cookie-notice .cn-button{margin:0 5px 5px 5px}}@media all and (max-width:480px){.cookie-notice-container{padding:15px 25px}}

L293D Arduino Motor Driver Shield – A Quick Walk

On COVID-19 lockdown days, I came across several motor driver modules in my scrap box in the attic – surprisingly most of them are unused Chinese modules. The L293 Arduino Motor Driver Shield, in particular, is extremely elegant, and I wanted to see how to play with that gem. Well, I figured it’s about time that I shared my own experiences with the L293 Arduino Motor Driver Shield. This is not intended to be an in-depth tutorial as there is plenty of information already out there. I’ve just presented briefly how it’s enough to inspire me!

L293 motor driver shield

Quite often you’ll need a full-featured motor shield for your Arduino based mechatronics projects as such a compact shield can control a number of everyday dc motors, servo motors, and stepper motors. Besides such devoted dc motor shields will help you to drive certain solenoids and electromechanical actuators. Perfect for most mechatronics projects!

The motor driver shield comes with two L293D dual-channel H-Bridge motor ICs, so it can individually drive up to four dc motors. The shield offers a total of four H-Bridges and each H-bridge can deliver up to 600mA drive current to the dc motor. The next key component of the motor shield is the 74HC595 shift register IC that extends 4 digital pins of the Arduino to the 8 direction control pins of the L293D ICs. This is the official (Adafruit) schematic drawing of the motor shield.

Original Creator: Adafruit Industries

Note that the output channels of both the L293D ICs are broken out to the edge of the motor shield with two 5-pin screw terminals (M1-M2-M3-M4)to connect four dc motors having voltages between 4.5V to 25V DC. You can also connect two bipolar stepper motors to output terminals – one to M1-M2 and other to M3-M4. In case of unipolar stepper motors, you can connect the center taps of both stepper motors to the Gnd terminal. Moreover, the motor shield puts out the 16-bit PWM output lines to a pair of 3-pin headers to which you can connect two standard servo motors.

On a side note, a serious drawback while working with motors is the large amounts of electrical noise they generate. The motor noise can interfere with the rest of the electronics and can even spoil delicate/sensitive components. Capacitors are usually the most basic but effective way to suppress motor noise, and as such here I urged you to use at least one 100nF ceramic capacitor across the motor terminals. For the neatest noise suppression, you can use three capacitors for one motor – one across the power supply terminals and one from each terminal to the motor case.

This topic is nothing new and there’re already quite a few good posts on the web on this. But I thought I would try to provide a short note on how to filter out the electrical noise from motors in electronic circuits.

First off, keep in mind that the electrical noise generated by a dc motor falls into two categories – electromagnetic interference and the electrical noise generated on the power rails. To suppress the level of electromagnetic interference, motors should be placed as far away from sensitive circuits as physically possible. Further, the metal enclosure (shell) of the motor must be properly grounded. The electromagnetic interference (RFI) can also be coupled into the circuit, but this type of interference (common-mode interference) can be minimized effectively via a simple low-pass filter.

When it comes to the electrical noise on the power rails, filtering at the power source is needed. This can be done by including a ‘beefy’ capacitor across the power terminals. Following scope, capture denotes the noise at the battery terminal when a small toy car dc motor is powered directly by a 4.8V battery pack (Thanks to Kerry D. Wong). See, the noise level is quite severe and the noise Vpp level cut through 3V at times, which is high enough to cause malfunction especially in digital/logic circuits.

The example circuit shown next is tailored for filtering out dc motor electrical noise in bidirectional motor drivers. The values for the inductors (hundreds of mH) and capacitors (hundreds of nF) used in the schematic can be varied empirically to achieve optimum results. Needless to say, there’re several precautions you can take to help minimize the effects of motor electric noise on your system. Practice makes perfect!

To sum up, with adequate shielding, grounding, and correct filtering practices the electrical noise generated by a dc motor can be reduced to a level that is ‘invisible’ for even the most sensitive electronic circuits.

Play safe with your ideas

Getting back to the principal theme, a terminal block with a jumper is included in the motor shield to power the motors. Note that an Arduino can only give a few hundred mA on the 5V Arduino header. So, I strongly recommend to use an appropriate dc supply for the dc/stepper motors in use (the servo ports are internally powered and does not use an external power supply). That is to say, simply plug in the 9VDC supply for the Arduino board into its dc input jack, and connect the dc/stepper motor supply to the external power block (EXT_PWR) of the motor shield. Always ensure that the power supply selection jumper (PWR) is removed from the motor shield. Remember, the stepper and dc motor connections will not work if the onboard green indicator LED is not lit brightly!

Before using the L293D motor driver shield with Arduino IDE, you need to install the AFMotor library. This Adafruit library contains the requisite commands to control dc, stepper and servo motors. However, driving servos with the motor driver shield is pretty easy as the motor driver shield actually breaks out Arduino’s 16-bit PWM output pins 9 and 10 to the edge of the shield with two 3-pin ‘servo’ headers. Since you’re using the onboard PWM pins, the sketch works with the built-in Arduino Servo library. The aforesaid AFMotor library can be downloaded from here


About my initial tryout

My first try was with the “MotorTest” example sketch included in the AFMotor library (see below). Obviously here you need to declare the motor port number to which the motor is wired. For port M1 write 1, for M2 write 2 and so on. Also if you want to connect multiple motors to the motor driver shield, you need to create a separate object for each motor.

For the quick test, I used a small dc motor (5V/100mA) of a desktop USB fan, wired to M4 screw connector of the motor driver shield. One 6F22 9V rechargeable battery is used to power the entire setup – Arduino Uno + L293 motor driver shield – at that time, and it worked the right way (watch the quick test video).

And, see the casual lab snaps:

What’s next?

The proposed mechatronics hobby project centered on this L293 Arduino Motor Driver Shield (v1.0) is mostly ready, and I am now waiting for a few to supplementary parts to arrive in the next few weeks. I will document my build and post the final results in the near future. Good luck with developing your own ideas and creating your own systems. See you again soon!

The long list of credits & references includes:

Leave a Comment X