H-Bridge Motor Control

Similar documents
1602 LCD adopts standard 14 pins(no backlight) or 16pins(with backlight) interface, Instruction of each pin interface is as follows:

Arduino Shield Manual

Arduino Shield Manual

DEPARTMENT OF ELECTRONICS ENGINEERING

Lab 6 Introduction to Serial and Wireless Communication

Arduino Motor Shield (L298) Manual

Eric Mitchell April 2, 2012 Application Note: Control of a 180 Servo Motor with Arduino UNO Development Board

Character LCDs. Created by Ladyada. Last updated on :45:29 PM EDT

Home Security System for Automatic Doors

Using Arduino Microcontrollers to Sense DC Motor Speed and Position

Basic Pulse Width Modulation

Arduino Lesson 13. DC Motors. Created by Simon Monk

Selecting and Implementing H-Bridges in DC Motor Control. Daniel Phan A

Electronics 5: Arduino, PWM, Mosfetts and Motors

DC Motor control Reversing

AMZ-FX Guitar effects. (2007) Mosfet Body Diodes. Accessed 22/12/09.

AN2680 Application note

High voltage power supply (1 to 20 KV)

cs281: Introduction to Computer Systems Lab08 Interrupt Handling and Stepper Motor Controller

ECE124 Digital Circuits and Systems Page 1

ETEC Digital Controls PIC Lab 10 Pulse Width Modulation

DC Motor Driver 24V 20A [RKI-1340]

How To Control A Car With A Thermostat

IR Communication a learn.sparkfun.com tutorial

LAB 7 MOSFET CHARACTERISTICS AND APPLICATIONS

CHAPTER 11: Flip Flops

Sequential Logic: Clocks, Registers, etc.

Robot Board Sub-System Testing. Abstract. Introduction and Theory. Equipment. Procedures. EE 101 Spring 2006 Date: Lab Section # Lab #6

Experiment 8 : Pulse Width Modulation

OPERATING MANUAL. Table of contents. 2 Phase Stepping Motor Driver 2M542. Rev. A. Introduction page 2. Specifications page 2 Timing chart page 3

Arduino Lesson 14. Servo Motors

Your Multimeter. The Arduino Uno 10/1/2012. Using Your Arduino, Breadboard and Multimeter. EAS 199A Fall Work in teams of two!

ABB Drives. User s Manual HTL Encoder Interface FEN-31

Arduino DUE + DAC MCP4922 (SPI)

Pololu DRV8835 Dual Motor Driver Shield for Arduino

Arduino Lesson 16. Stepper Motors

Table 1 Comparison of DC, Uni-Polar and Bi-polar Stepper Motors

Working with microcontroller-generated audio frequencies (adapted from the Machine Science tutorial)

3-Digit Counter and Display

Arduino project. Arduino board. Serial transmission

Electronic Brick of Current Sensor

EET272 Worksheet Week 9

Theory of Operation. Figure 1 illustrates a fan motor circuit used in an automobile application. The TPIC kω AREF.

Talon and Talon SR User Manual

The MOSFET Transistor

Data Sheet. Adaptive Design ltd. Arduino Dual L6470 Stepper Motor Shield V th November L6470 Stepper Motor Shield

Operation Manual. Plasma torch height controller. Model: Compact THC Controller 150

Ultrasonic Distance Measurement Module

Whale 3. User Manual and Installation Guide. DC Servo drive. Contents. 1. Safety, policy and warranty Safety notes Policy Warranty.

QUICK START GUIDE FOR DEMONSTRATION CIRCUIT BIT DIFFERENTIAL ADC WITH I2C LTC2485 DESCRIPTION

Pulse Width Modulation (PWM) LED Dimmer Circuit. Using a 555 Timer Chip

MIDECO 64-outputs MIDI note decoder USER MANUAL. Roman Sowa 2012

ECEN 1400, Introduction to Analog and Digital Electronics

DC Motor with Shaft Encoder

ABB Drives. User s Manual. Pulse Encoder Interface Module RTAC-01

ARRL Morse Code Oscillator, How It Works By: Mark Spencer, WA8SME

Application Note AN-1040

Points Position Indicator (PPI1) for Points Motors with Common Ground

Help on the Embedded Software Block

Data Acquisition Module with I2C interface «I2C-FLEXEL» User s Guide

HT46R14A Single Phase AC Induction Motor Frequency Converter Application

Display Board Pulse Width Modulation (PWM) Power/Speed Controller Module

Pmod peripheral modules are powered by the host via the interface s power and ground pins.

Low Cost Pure Sine Wave Solar Inverter Circuit

How to Move Canon EF Lenses. Yosuke Bando

Electronics. Discrete assembly of an operational amplifier as a transistor circuit. LD Physics Leaflets P

DATASHEET. ADAM Arduino Display Adaptor Module. Arduino Compatible Shield P/N: 4Display-Shield-FT843 For the 4D Systems 4DLCD-FT843 Display

AP331A XX G - 7. Lead Free G : Green. Packaging (Note 2)

A Practical Guide to Free Energy Devices

Design Project: Power inverter

ARDUINO SEVERINO SERIAL SINGLE SIDED VERSION 3 S3v3 (REVISION 2) USER MANUAL

[F/T] [5] [KHz] [AMP] [3] [V] 4 ) To set DC offset to -2.5V press the following keys [OFS] [+/-] [2] [.] [5] [V]

Gates, Circuits, and Boolean Algebra

Physics 120 Lab 6: Field Effect Transistors - Ohmic region

Controlling a Dot Matrix LED Display with a Microcontroller

Servo Motors (SensorDAQ only) Evaluation copy. Vernier Digital Control Unit (DCU) LabQuest or LabPro power supply

Arduino Lesson 1. Blink

PRODUCTIVITY THROUGH INNOVATION 600 CONTROL DIRECT DRIVE TECHNICAL/OPERATION MANUAL

EXPERIMENT 3: TTL AND CMOS CHARACTERISTICS

Application Note AN-1135

Notes about Small Signal Model. for EE 40 Intro to Microelectronic Circuits

So far we have investigated combinational logic for which the output of the logic devices/circuits depends only on the present state of the inputs.

1. Learn about the 555 timer integrated circuit and applications 2. Apply the 555 timer to build an infrared (IR) transmitter and receiver

Basic DC Motor Circuits. Living with the Lab Gerald Recktenwald Portland State University

The self-starting solar-powered Stirling engine

Basic DC Motor Circuits

Pulse Width Modulation Applications

FREQUENCY RESPONSE OF AN AUDIO AMPLIFIER

GLOLAB Two Wire Stepper Motor Positioner

DIODE CIRCUITS LABORATORY. Fig. 8.1a Fig 8.1b

Electronic Rotary Table Divider V2.1 Construction

Accurate Measurement of the Mains Electricity Frequency

Step Response of RC Circuits

Four/Five Axis TB6560 CNC Driver Users Manual

Features, Benefits, and Operation

Arduino Due Back. Warning: Unlike other Arduino boards, the Arduino Due board runs at 3.3V. The maximum. Overview

GLOLAB Universal Telephone Hold

STUDY OF CELLPHONE CHARGERS

PHYS 2P32 Project: MIDI for Arduino/ 8 Note Keyboard

Transcription:

University of Pennsylvania Department of Electrical and Systems Engineering ESE 206: Electrical Circuits and Systems II Lab H-Bridge Motor Control Objective: The objectives of this lab are: 1. To construct an H-bridge using 6 enhancement MOSFETS. 2. To use this H-bridge to control a motor using a Q-Drive and an Inverted Q-Drive. You will be able to switch the motor ON and OFF, and control its direction. 3. To use an Arduino Microcontroller to control the Q-Drive and Inverted Q-Drive. Introduction: A MOSFET transistor is a three terminal semiconductor device in which current, flowing from the drain-source terminals, is controlled by the voltage on the gate terminal. A MOSFET can be used as a switch, by controlling the voltage provided to the gate. For an enhancement n-mosfet (NMOS), if the gate voltage is sufficiently high, current flows from the drain to the source. Conversely, for a p-mosfet (PMOS), with a sufficiently high gate voltage, current flows from source to drain. Figure 1 shows the terminals of a NMOS (a) and a PMOS (a). (a) (b) Figure 1: Terminal Names for NMOS (a) and PMOS (b) We will be using the IRF630 for NMOS and the IRF9630 for the PMOS. Take a look at the datasheets and make sure to know the pin configurations of both. Motivation for the H-Bridge: A D.C. Motor requires a voltage difference between its terminals to rotate. The direction in which a motor rotates in determined by which side of the motor is connected to the positive and negative terminals. Swapping the positive and negative terminals will cause the motor to rotate in the

opposite direction. An H-Bridge is used to control the direction of the motor and to also provide enough current for the motor to run. Operation: 1. To force a motor to switch in two directions, one requires a minimum of 4 switching elements. We will use 4 MOSFET to control the direction of the motor. Consider Figure 2 shown below. Figure 1: H-Bridge Configuration Source: http://en.wikipedia.org/wiki/h_bridge Initially, all switches are open. There is no potential difference across the ends of the motor. It will therefore, not rotate in any direction. If only switches 1 and 4 are ON (Q-Drive), there will be a voltage drop across the motor and it will run. This also occurs when only switches 2 and 3 are ON (Inverted Q- Drive), however the motor runs in the opposite direction. If only S1 and S3 are ON, or if only S2 and S4 are on, there will be no voltage drop across the motor and it will brake. Note that if S1 and S2 are open at the same time, the circuit will short and you will have very high current and rapid heating of the MOSFETs. This also occurs if S3 and S4 are open at the same time. Be sure to never let this situation occur! Prelab Assignment: 1. Find some literature on H-Bridges and take some time to learn the basics. 2. Write out a truth table like the one you see below. Put 0 (OFF) or 1 (ON) for inputs, and for output write the response of the motor or the circuit. There are 16 possible situations. Which scenarios result in a dangerous circuit output? S1 S2 S3 S4 Result 0 0 0 0 1 0 0 0 0 1 0 0 etc.

2. We will be controlling these four MOSFETS with only two inputs 2 more MOSFETS. We will be shorting the gates of S1 and S4 and controlling these two MOSFETs with a fifth MOSFET (S5), and also shorting the gates of S2 and S3 and controlling it with the sixth MOSFET (S6). So, for example, if S5 is ON, then S1 and S4 will also be. In this configuration, S5 (Input 1) controls both S1 and S4, while S6 (Input) controls S2 and S3. Prelab Assignment: 3. Create another truth table this time with only 2 inputs. List the resulting motor or circuit behavior. There are four possible situations. Which scenarios result in a dangerous circuit output? Procedure: Part I: Implementation using MOSFETS We will use 2 PMOS and 4 NMOS to construct our initial H-Bridge. The 2 PMOS (S1 and S3) are used as the source for the current and the NMOS (S2 and S4) are used as the sinks. NMOS S5 and S6 will be connected as shown in order to control the H-Bridge. We will then use a 5 V power supply to supply the inputs (Gates of S5 and S6) in configurations of your choosing. Figure 3 shows a schematic of the circuit. Figure 3: Circuit Schematic of H-Bridge Build the initial H-Bridge circuit as shown above. Remember that PMOS conduct from source to drain, and NMOS conduct from drain to source (See Figure 1 above).

The source terminal of both the PMOS connect to the power supply (12 V), and their drains are connected to the motor and to the drains of the NMOS directly below them. The source terminals of the NMOS are grounded. S5 is triggered by Input 1 and S6 is triggered by Input 2. To test the working of the circuit, you will use the Tri-State switch, as shown in Figure 4. 5 V Input 1 GND Input 2 Figure 4: Tri-State Switch in H-Bridge Circuit Connect a 5 V power supply (NOT V CC!) to the positive terminal of the switch, and GND to the negative terminal. Connect Input 1 and 2 to two lines of the switch, and take turns switching the inputs to 5 V (ON) and GND (OFF). Make sure your motor is connected so that it performs as listed in Table 2 below. Input 1 Input 2 Motor Description ON OFF Rotates in clockwise direction. OFF ON Rotates in the counterclockwise direction. ON* ON* Motor brakes rapidly* OFF OFF Motor does not rotate. Table 2: Truth table for H-Bridge control *DON T LEAVE BOTH INPUTS ON FOR MORE THAN 10 SECONDS THIS SHORTS THE POWER SUPPLY. Now test your H-bridge against the truth table shown in Table 2. If your circuit satisfies all four cases, show your TA, and proceed to the next part. Part II: Control with Arduino As you may know, the Arduino can be used for many different purposes, one of them supplying input voltages. We will be using the Arduino to supply the two H-Bridge inputs. Use the Arduino

Duemilanove provided and connect it via USB to your computer. Open up the Arduino 0022 IDE program on your desktop. Here is a reference if you are unfamiliar with Arduino. Open up a new sketch and copy the code listed below into the sketch. Read over the code carefully. How does it function? What do the variables leftstatus and rightstatus monitor? Put your name in the lcd.print( My name is ) line of code. #include <LiquidCrystal.h> int gate1 = 11; int gate2 = 12; LiquidCrystal lcd(8,9,4,5,6,7); int analogpin = A0; int adc_key_old; int adc_key_in; int NUM_KEYS = 5; int key = -1; int adc_key_val[5] = {30, 150, 360, 535, 760; int leftstatus = 0; int rightstatus = 0; int timeout = 120; int freq = 50; int duty = 100; void setup() { pinmode(gate1, OUTPUT); pinmode(gate2, OUTPUT); // set up the LCD's number of columns and rows: Serial.begin(9600); lcd.begin(16, 2); // Print a message to the LCD. lcd.clear(); lcd.print("hello, world!"); lcd.setcursor(0,1); lcd.print("my name is "); delay(3000); lcd.clear(); lcd.setcursor(0,0); adc_key_old = analogread(analogpin); digitalwrite(gate1, LOW); digitalwrite(gate2, LOW); void loop() { while(true) { constantout(leftstatus, rightstatus, freq); // <--- Comment Out in Part III adc_key_in = analogread(analogpin); adc_key_in = get_key(adc_key_in); if (adc_key_in == 3){ if (leftstatus == 0) {

leftstatus = 1; Serial.print("Left Status = "); Serial.println(leftstatus); delay(300); else if (leftstatus == 1) { leftstatus = 0; Serial.print("Left Status = "); Serial.println(leftstatus); delay(300); else if (adc_key_in == 0){ if (rightstatus == 0) { rightstatus = 1; Serial.print("Right Status = "); Serial.println(rightstatus); delay(300); else if (rightstatus == 1) { rightstatus = 0; Serial.print("Right Status = "); Serial.println(rightstatus); delay(300); lcd.clear(); lcd.setcursor(0,0); lcd.print(leftstatus); lcd.print(" "); lcd.print(rightstatus); lcd.print(" - "); lcd.setcursor(0,1); if (leftstatus == 0 && rightstatus == 0){ lcd.print("brake"); else if (leftstatus == 1 && rightstatus == 0) { lcd.print("clockwise"); else if (leftstatus == 0 && rightstatus == 1) { lcd.print("counterclockwise"); else { lcd.print("brake ("); lcd.print(timeout); lcd.print(")"); timeout--; if (timeout < 1) {

timeout = 120; rightstatus = 0; leftstatus = 0; //end while loop // end loop() int get_key(unsigned int input) { int k; for (k = 0; k < NUM_KEYS; k++) { if (input < adc_key_val[k]) { Serial.print("k = "); Serial.println(k); return k; if (k >= NUM_KEYS) { k = -1; return k; void constantout(int left, int right, int frequency){ float totalperiod = 1000/frequency; if (left == 0) { digitalwrite(gate1, LOW); //if left is OFF, output ground if (right == 0) { digitalwrite(gate2, LOW); //if right is OFF, output ground if (left == 1 && right!= 1){ digitalwrite(gate1, HIGH); //if 1 0, have pulse for fraction of time then off if (right == 1 && left!= 1) { digitalwrite(gate2, HIGH); if (right == 1 && left == 1) { digitalwrite(gate1, HIGH); digitalwrite(gate2, HIGH); //end constantout

You will also need an Arduino LCD board to display your output. Because the LCD board may or may not have external output pins, we may have to create space for us to take the output from the Arduino (Pins 11 and 12) while still using the LCD. If the LCD has no external output pins, you need to use two 8-pin sockets and two 6-pin sockets and mount them on the Arduino, followed by the LCD on top of the pin sockets. See Figure 5 below for a final look at what your controller will look like. + + = Figure 5: Controller Components and Final Configuration Connect wires with clips to Digital pins 11, 12 and GND at the bottom of your pin sockets. Be sure that they only touch one pin and there are no accidental shorts. Connect those wires to your H- Bridge circuit inputs (Input 1 and Input 2 bypass the switch in this case). Upload your code and test out the controller! Explore the buttons on the LCD shield. How does the LCD shield control the circuit? Part III: Speed Control Input Variation We have been putting in as inputs constant DC signals. However, you can control the DC motor by changing the type of input signal. With the H-bridge inputs connected directly to your function generator again (back through the switch - not the Arduino for now), input a 5 V, 2.5 V offset square wave as the input for the 4 different circuit configurations. Experiment with the frequency and duty cycle of the square wave. What are the ranges of both parameters such that the motor still runs? How do these parameters affect the speed of the motor? Arduino Control

Finally, as you may have noticed in the code, the output of the Arduino is controlled by a function called constantout. This function simply makes the outputs HIGH or LOW depending on the user input on the LCD board, and keeps them constant at this level. Create a new function called pulse that fulfills these criteria: 1. Output is void 2. Four input variables - two input statuses leftstatus and rightstatus, a duty cycle variable, and a frequency variable. 3. Depending on the state of leftstatus and rightstatus, outputs to one of the digital pins a one period square wave with period determined by the frequency and time on HIGH or LOW determined by the duty cycle. (Hint: Remember your if-statements and the Arduino function digitalwrite ). We only need to create a square wave for one period because the while-loop in the code repeats this function indefinitely. Comment out the old constantout function call in the code, and instead insert your pulse function. Be sure to create duty cycle and frequency variables. Upload the code, connect the output pins to the H-Bridge, and test to see how the motor performs. Show your TA as your exit ticket. Written by Vignesh Subramanian, Matthew Kaye, and Parth Chopra, Mar. 2012.