Subido por Juleishka Pagan

ELEN 4020 Microcontroller Lab7

Anuncio
UNIVERSIDAD INTERAMERICANA
RECINTO DE BAYAMON
DEPARTAMENTO DE INGENIERIA
LABORATORY NO 7
DC MOTOR CONTROL
And
LCD Display
Name
ID
1
2
3
4
SUPERVISOR SIGNATURE _______________
DATE : _________________________ ________
August 19, 2014
April 24,2015
By Roman Lopez Ph. D.
7.1 Objective: As engineers, motion control is one of our most common uses of mechatronics. We will
frequently use DC motors to produce motion; however, the task of controlling these motors is made more
difficult by several details which you will look at in this lab.
This labs focused on powering a dc, and controlling current with a transistor. A transistor acts as
an electronic switch, and is useful when using more than one power supply, while requiring
motor control from the circuit board. The Arduino board is powered by the laptop. A switch was
used to control motor speed.
7.2. Parts
Arduino Mega
Potentiometer
Transistor
DC motor
Switch
Resistors 330 Ohms
LCD Display
7.3 DC motor control with a single transistor
Using a single transistor and a flyback protection diode, create a driver circuit that can run a Lego motor
in one direction at different speeds. Note that the black and white wires on the Lego wiring harness
control the motor. We will talk later about what the other wires do in a later lab, but leave those
unconnected for now. Use the +5V supply on your breadboard for this driver. Read the output of a
potentiometer in to your Arduino and use that value to control the speed of the motor.
7.4. Procedure: Connect a motor and the switch
Attach a DC motor to the collector of the transistor. Most motors will require more amperage
than the microcontroller can supply, so you will need to add a separate power supply as well. If
your motor runs on around 9V, you could use a 9V battery or an external power supply. The
ground of the motor power supply should connect to the ground of the microcontroller, on the
breadboard.
Figure 7.1 Arduino Mega
7-1
Figure 7.2 Motor Control Circuit using a transistor
Figure 7.2: Typical V0 connections for display contrast
(NOTE a 0.6V to 0.6V is needed to see the message).
Adjust V0 to +7.0V (VLCD=+5V) as an initial setting. When the module is operational, readjust
V0 for optimal display appearance. NOTE: Do not connect +5V (Pin 15) directly to the backlight
terminals. This will ruin the backlight.
7.5. Program the microcontroller
1) Write a quick program to test the circuit. Your program should make the transistor pin an
output in the setup method. Then in the loop, it should turn the motor on and off every ten
seconds, just like the blink sketch does.
2) Modified the program and add input (Switch) to control the dc motor to change on if the
switch in on and off the motor if the switch is of (used interrupts).
3) Create your own subroutine to do the pulse wide modulation (do not use the Arduino
PWM library).
7-2
Figure 7.3 LCD and Arduino connection (In the case where the LCD is powered
with Arduino +5V USB cable, set the contrast resistor to 2K).
4) Modified the program in order to change the motor speed every 4 seconds from 0 to
%100 of the motor speed (used your own PWM ).
5) Add a LCD Display to show the motor speed (figure 7.1 and figure no 7.2).
Now that you see it working, try changing the speed of the motor sending pulses instant on/off
sates.
7.7. Report:
What is the voltage and current across the motor terminals while the motor is running at?
a)
b)
c)
d)
e)
f)
g)
h)
i)
10% of total motor speed.
20%
30%
40%
50%
60%
80%
90%
100%
Is the voltage across the motor terminals a function of motor load? If so, describe the variation you
observe.
7-3
Descargar