Project 16 Using an L293D Motor Driver IC

Similar documents
Arduino Lesson 15. DC Motor Reversing

Create moving images in forward and reverse with your Arduino when you connect a motor to an H-bridge and some still images BATTERY POTENTIOMETER

A4988 Stepper Motor Driver Carrier with Voltage Regulators

Objectives: Learn how to input and output analogue values Be able to see what the Arduino is thinking by sending numbers to the screen

MP6500 Stepper Motor Driver, Digital Current Control

Me Stepper Driver. Overview

Thursday, September 15, electronic components

LCMM024: DRV8825 Stepper Motor Driver Carrier,

EP486 Microcontroller Applications

MigaOne-Arduino Tutorial: Position/Limit Sensing and Cycling with the Arduino Platform

Prototyping & Engineering Electronics Kits Basic Kit Guide

A4988 Stepper Motor Driver Carrier, Black Edition

ARDUINO MINI 05 Code: A000087

L298N Dual H-Bridge Motor Driver

A4988 Stepper Motor Driver Carrier

GUIDE TO SP STARTER SHIELD (V3.0)

1/Build a Mintronics: MintDuino

Arduino Programming Part 3. EAS 199A Fall 2010

Physics 120/220. Microcontrollers Extras. Prof. Anyes Taffard

MegaPi Born to Motion Control

Adafruit TB A DC/Stepper Motor Driver Breakout Board

Instruction Manual for BE-SP3 Circuit. 10/21/07

EXPERIMENT 7 Please visit to learn all features of arduino before you start the experiments

solutions for teaching and learning

MAKEVMA401 5 VDC STEPPER MOTOR WITH ULN2003 DRIVER BOARD USER MANUAL

Serial.begin ( ); Serial.println( ); analogread ( ); map ( );

University of Hull Department of Computer Science C4DI Interfacing with Arduinos

Arduino 101 AN INTRODUCTION TO ARDUINO BY WOMEN IN ENGINEERING FT T I NA A ND AW E S O ME ME NTO R S

ROBOTLINKING THE POWER SUPPLY LEARNING KIT TUTORIAL

Earthshine Design Arduino Starters Kit Manual - A Complete Beginners Guide to the Arduino. Project 13. Serial Temperature Sensor

Physical Computing Self-Quiz

Physical Computing Self-Quiz

Experiment 4.A. Speed and Position Control. ECEN 2270 Electronics Design Laboratory 1

Robotic Systems ECE 401RB Fall 2006

Make your own secret locking mechanism to keep unwanted guests out of your space!

Motor driver board. EB022

Project 17 Shift Register 8-Bit Binary Counter

Lab 01 Arduino 程式設計實驗. Essential Arduino Programming and Digital Signal Process

IME-100 ECE. Lab 3. Electrical and Computer Engineering Department Kettering University. G. Tewolde, IME100-ECE,

Wii Nunchuk Transceiver. Wiring Diagrams

Grove - I2C Motor Driver

Digital Pins and Constants

KNOCK LOCK MAKE YOUR OWN SECRET LOCKING MECHANISM TO KEEP UNWANTED GUESTS OUT OF YOUR SPACE! Discover: input with a piezo, writing your own functions

AT42QT1010 Capacitive Touch Breakout Hookup Guide

Controlling a fischertechnik Conveyor Belt with Arduino board

Introduction to Microcontrollers Using Arduino. PhilRobotics

HDBB Breakout board user s manual

Lab-3: LCDs Serial Communication Analog Inputs Temperature Measurement System

This is the Arduino Uno: This is the Arduino motor shield: Digital pins (0-13) Ground Rail

Discharge by touching: BNC coax shield, outlet metal cover plate, wire connected to GND

Physics 364, Fall 2012, Lab #9 (Introduction to microprocessor programming with the Arduino) Lab for Monday, November 5

Note. The above image and many others are courtesy of - this is a wonderful resource for designing circuits.

AUDIO AMPLIFIER PROJECT

Explorer V1.20. Features

Lab 2.2 Ohm s Law and Introduction to Arduinos

IME-100 Interdisciplinary Design and Manufacturing

EECE 2411/2211-Introduction to Electrical and Computer Engineering Lab. Lab 3

ESPino - Specifications

Basic Electronic Toolkit for under $40

Lesson 8: Digital Input, If Else

ACE-SDC-V3 Stepper Driver +Controller with USB 2.0 Communication

Analog Input. Sure sure, but how to make a varying voltage? With a potentiometer. Or just pot.

Project 18 Dual 8-Bit Binary Counters

Earthshine Design Arduino Starters Kit Manual - A Complete Beginners Guide to the Arduino. Project 15. Shift Register 8-Bit Binary Counter

How-To #7: Assemble an H-bridge Circuit Board

Goal: We want to build an autonomous vehicle (robot)

Iocard USB DcMotors Manual. Date:15/02/12 Rev.:2.0

UNIT 10: Driving motors

Using a Stepper Motor Like a Servo Controlled by a Potentiometer (G Payne 2017)

8051 Intermidiate Development Board. Product Manual. Contents. 1) Overview 2) Features 3) Using the board 4) Troubleshooting and getting help

TEVATRON TECHNOLOGIES PVT. LTD Embedded! Robotics! IoT! VLSI Design! Projects! Technical Consultancy! Education! STEM! Software!

SINCOS. Linear Stepper Motor Power Stage. Manual 2066-A006 GB

AT42QT101X Capacitive Touch Breakout Hookup Guide

Necessary software and hardware:

Christian Brothers University 650 East Parkway South Memphis, TN

Mercury Baseboard Reference Manual

Sanguino TSB. Introduction: Features:

Vector 3D printer complete wire list including extruder PWA listing

Lesson 0 Installing IDE

TB6600 Stepper Motor Driver

University of Portland EE 271 Electrical Circuits Laboratory. Experiment: Arduino

RKP08 Component List and Instructions

EQ573 Assembly guide. EQ573 Assembly guide Main board 1. Diodes. 2. Resistors (1) 3. Test pins. 4. Ceramic capacitors.

Basic Interface Techniques for the CRD155B

PWR Meter click. PID: MIKROE 3169 Weight: 31 g

Components List No Product Name Quantity Picture 1 Uno 1 R3 Controller Board 2 USB Cable 1 3 LCD1602 Module 1 4 Breadboard 1 5 9V 1A Power Supply 1 4

Smart Objects. SAPIENZA Università di Roma, M.Sc. in Product Design Fabio Patrizi

Applications of 8051 Microcontrollers

cs281: Introduction to Computer Systems Lab03 K-Map Simplification for an LED-based Circuit Decimal Input LED Result LED3 LED2 LED1 LED3 LED2 1, 2

MAKE & COLLABORATE: SECRET KNOCK LOCK

Grove - Mini I2C Motor Driver v1.0

Filthy Fack! Famous germanium 5-knobbed fuzz clone

BUILD: ARDUINO NANO + NEMA17 BIPOLAR STEPPER 12V 0.4A + EASYDRIVER

SWITCH 10 KILOHM RESISTOR 220 OHM RESISTOR POTENTIOMETER LCD SCREEN INGREDIENTS

MINITRONICS v1.0 DATASHEET

Adafruit Metro Mini. Created by lady ada. Last updated on :12:28 PM UTC

Variable Power Supply Digital Control Circuit Diagram Using Lm317

Digispark DIY: the Smallest USB Arduino

Arduino Prof. Dr. Magdy M. Abdelhameed

Arduino Programming. Arduino UNO & Innoesys Educational Shield

Transcription:

Project 16 Using an L293D Motor Driver IC In the previous project, you used a transistor to control the motor. In this project, you are going to use a very popular motor driver IC called an L293D. The advantage of using this chip is that you can control two motors at the same time, plus you can control their direction. The chip can also be used to control a stepper motor, as you will find out in Project 28. (You can also use a pin-for-pin compatible chip known as the SN754410, which has a higher current rating.) Notice anything missing from the parts list? Diodes, perhaps? Not to worry; the IC has its own internal diodes, so you do not need one for this project. Parts Required DC Motor L293D or SN754410 Motor Driver IC 10KΩ Potentiometer Toggle Switch 10KΩ Resistor Heatsink 104

Connect It Up First, make sure your Arduino is powered off by unplugging it from the USB cable. Now, take the required parts and connect them as shown in Figure 5-3. Again, check the circuit thoroughly before powering it up. The L293D gets VERY hot when in use. Therefore, a heatsink is essential. Glue the heatsink to the top of the chip using a strong epoxy glue. The larger the heatsink, the better. Be warned that the temperature can get hot enough to melt the plastic on a breadboard or any wires touching it. Do not touch the heatsink as you may burn yourself. Do not leave the circuit powered up and unattended in case it overheats. It may be prudent to use stripboard instead of a breadboard for this project to save damaging your breadboard due to heat. Figure 5-3. The circuit for Project 16 (see insert for color version) Enter the Code Once you are satisfied that your circuit is connected correctly, upload the code in Listing 5-2. Do not connect the external power supply at this stage. Listing 5-2. Code for Project 16 // Project 16 - Using an L293D Motor Driver IC #define switchpin 2 // switch input #define motorpin1 3 // L293D Input 1 #define motorpin2 4 // L293D Input 2 #define speedpin 9 // L293D enable Pin 1 #define potpin 0 // Potentiometer on Analog Pin 0 int Mspeed = 0; // a variable to hold the current speed value 105

void setup() { //set switch pin as INPUT pinmode(switchpin, INPUT); // set remaining pins as outputs pinmode(motorpin1, OUTPUT); pinmode(motorpin2, OUTPUT); pinmode(speedpin, OUTPUT); void loop() { Mspeed = analogread(potpin)/4; // read the speed value from the potentiometer analogwrite(speedpin, Mspeed); // write speed to Enable 1 pin if (digitalread(switchpin)) { // If the switch is HIGH, rotate motor clockwise digitalwrite(motorpin1, LOW); // set Input 1 of the L293D low digitalwrite(motorpin2, HIGH); // set Input 2 of the L293D high else { // if the switch is LOW, rotate motor anti-clockwise digitalwrite(motorpin1, HIGH); // set Input 1 of the L293D low digitalwrite(motorpin2, LOW); // set Input 2 of the L293D high Once the code has finished uploading, set the potentiometer at its midpoint and plug in the external power supply. The motor will now rotate; you can adjust its speed by turning the potentiometer. To change direction of the motor, first set the speed to minimum, then flick the toggle switch. The motor will now rotate in the opposite direction. Again, be careful of that chip as it will get very hot once powered up. Project 16 Using an L293D Motor Driver IC Code Overview The code for this project is very simple. First, you define the pins you are going to put to use on the Arduino: #define switchpin 2 // switch input #define motorpin1 3 // L293D Input 1 #define motorpin2 4 // L293D Input 2 #define speedpin 9 // L293D enable Pin 1 #define potpin 0 // Potentiometer on Analog Pin 0 Then, set an integer to hold the speed value read from the potentiometer: int Mspeed = 0; // a variable to hold the current speed value 106

In the setup function, you then set the appropriate pins to either inputs or outputs: pinmode(switchpin, INPUT); pinmode(motorpin1, OUTPUT); pinmode(motorpin2, OUTPUT); pinmode(speedpin, OUTPUT); In the main loop, you first read in the value from the potentiometer connected to Analog Pin 0 and store it in Mspeed: Mspeed = analogread(potpin)/4; // read the speed value from the potentiometer Then you set the PWM value on PWM Pin 9 to the appropriate speed: analogwrite (speedpin, Mspeed); // write speed to Enable 1 pin Then you have an if statement to decide if the value read in from the switch pin is either HIGH or LOW. If it is HIGH, then output 1 on the L293D is set to LOW and output 2 is set to HIGH. This will be the same as output 2 having a positive voltage and output 1 being ground, causing the motor to rotate in one direction: if (digitalread(switchpin)) { // If the switch is HIGH, rotate motor clockwise digitalwrite(motorpin1, LOW); // set Input 1 of the L293D low digitalwrite(motorpin2, HIGH); // set Input 2 of the L293D high If the switch pin is LOW, then output 1 is set to HIGH and output 2 is set to LOW, reversing the direction of the motor: else { // if the switch is LOW, rotate motor anti-clockwise digitalwrite(motorpin1, HIGH); // set Input 1 of the L293D low digitalwrite(motorpin2, LOW); // set Input 2 of the L293D high The loop will repeat, checking for a new speed value or a new direction and setting the appropriate speed and direction pins. As you can see, using the motor driver IC is not at all as daunting as you might have thought at first. In fact, it has made your life a lot easier. Trying to recreate the above circuit and code without it would have been far more complex. Never be intimidated by ICs! A slow and careful read of their datasheets will reveal their secrets. Let s see how the new component introduced in this project works. Project 16 Using an L293D Motor Driver IC Hardware Overview The new component in Project 16 is the Motor Driver IC. This will be either the L293D or the SN754410, depending on what you have chosen (there are other chips available and a little research on the internet will find other pin compatible motor drivers). The L293D is what is known as a Dual H-Bridge. A H-Bridge is a useful but simple electronic concept (see Figure 5-4). 107

Figure 5-4. A H-Bridge made of switches (image by Cyril Buttay) In Figure 5-4, a motor is connected to four switches. The configuration is called a H-Bridge as it resembles a letter H with the load bridge the centre. Now take a look at Figure 5-5. Figure 5-5. Changing motor direction on the H-Bridge (image by Cyril Buttay) On the left hand side, the top left and the bottom right switches are closed. By doing so, the current will flow across the motor from left to right and the motor will rotate. If you open those switches and close the top right and bottom left switches instead, the current will flow across the motor in the opposite direction and hence cause it to rotate in the opposite direction. This is how an H-Bridge works. The Motor driver IC is made up of two H-Bridges. Instead of switches, it uses transistors. In the same way that the transistor in Project 15 was used as a switch, the transistors inside the H-Bridge switch on and off in the same configuration as Figure 5-5 to make your motor rotate in either direction. The chip is a Dual H-Bridge because it has two H-Bridges inside it. Thus you are able to control two motors and their directions at the same time. Note that you could make your own H-Bridge out of transistors and diodes, and it would do the same job as the L293D. The L293D has the advantage of being tiny and having all those transistors and diodes packaged up inside a small space. 108

EXERCISE Now try out the following exercise. Exercise 1: Instead of just one motor, try connecting up two, with two direction switches and potentiometers to control the direction and speed. Figure 5-6 shows the pinouts of the chip. Figure 5-6. The pinouts for the L293D (or SN754410)