Lab12_Motor_Drive_System

advertisement
ECE 381
Lab 12 – DC Motor Driver
DC Motor Drive System
Objective
Develop a PSoC design that uses an external H-bridge driver IC and pulse width modulation to control the direction and
speed of a DC motor.
Background
This lab introduces motor control with a simple DC motor driving circuit. An H-bridge allows one to control the direction
of current flow through a motor by opening and closing the correct combinations of switches to power. The lab
illustrates the use of pulse width modulation as a way to control a low-speed analog output. (See the textbook, Section
15.7, pp. 377-380 and Section 14.3 pp. 343-344.)
We will use a L293DNE Quadruple Half-H Driver IC to implement the H-bridge. Use the outputs of Buffer 1 (pin 3) and
Buffer 2 (pin 6) to drive the motor. If the buffer control inputs are set to ‘0’ on pin 2 and ‘1’ on pin 7 the motor will be
connected to power in a certain direction, if the buffer pair is enabled (pin 1). Placing a ‘1’ on pin2 and a ‘0’ on pin 7
causes rotation in the opposite direction (when enabled). We will control the motor speed by intermittently enabling
the buffer pair using the PSOC’s PWM output signal.
Hardware Configuration



Place a PWM module (or a counter) and configure it to drive one of the PSoC’s pins. Connect this pin to pin1 of
the L293DNE.
Make 2 more PSOC pins outputs to drive the buffer control inputs (pins 2 and 7).
Configure P1[7] to be a STDCPU HighZ input named STOP/START set to interrupt on a RisingEdge. Connect P1[7]
to SW on the PSoC Evaluation Board. Remember, SW floats when not pressed and is connected to Vcc when
pressed. You will need to use a pull-down resistor. Create a GPIO Interrupt Service Routine that will cause your
system to stop or reverse the motor direction whenever SW is pressed.
Notes



The pulse width varying system you build will also be used to demonstrate how you can rotate a servo motor to
a specific angle.
Could sense speed using generator, clicker, optical encoder (display actual speed vs set speed)
Could control speed with feedback using PID controllers
Requirements


At startup, the motor should be going 1/3 speed in one direction. Pressing the switch causes the motor to stop
(brake it, then release the power drive). Pressing the switch again cause the motor to run 2/3 speed the other
direction. Further switch presses cause stop, original rotation, stop…
Your switch should be properly debounced.
Testing
Verify that your design meets all the requirements specified above.
Download