Docstoc

texas a&m university

Document Sample
texas a&m university Powered By Docstoc
					          TEXAS A&M UNIVERSITY
ENGR 111B:                    Foundations of Electrical &
                              Computer Engineering



Lab 6: Pulse Width Modulation



Team Members: _________________________

                      _________________________


Section Number: __________            Team Number: __________



This Lab is due by the Beginning of the Next Lab Session.




Written By:   Hank Walker
              Lorne Liechty




Written by Texas A&M University                                 1
Lab 6: Pulse Width Modulation
Time Limit: 1 week

OVERVIEW
        Using RC circuits we can not only time individual events, but we can also create
repeating timers. This oscillatory timing is used in virtually every electronic device
available. In this lab students will examine the use of a digitally oscillating signal to
control DC motor speed. This approach contrasts with the simple resistor-based current
limiting method you used previously. Topics covered in this lab include the following
material:
    - Digitally Oscillating Signals
    - Pulse Width Modulation
    - Average Voltage, Current, and Power
    - How a PWM signal can be generated using a 555 timer
    - Diodes
    - PWM Signal Control of DC Motor

BACKGROUND
        To assist students in completing the exercises required by this lab, the following
background information has been provided. It is recommended that each student read all
of the following information as a beneficial review of the topics required.

DIGITAL OSCILLATIONS

        An oscillating signal is one which changes between two levels according to a
regular pattern of intervals. AC (Alternating Current) voltages are included in the realm
of oscillating voltages, but the term AC is reserved for signals which include both
positive and negative voltages. A digital oscillation also switches between two levels
according to defined intervals, and the ideal digital signal exists only at the specified
levels and does not exist at the levels in between. The signals represented in Figures B1
are two different digitally oscillating signals.




                            Figure B1: Digitally Oscillating Signals




Written by Texas A&M University                                                             2
Examining the signals in Figure B1, notice that the lower of the two voltages does not
have to be set to zero volts, or ground; the lower voltage of a digital signal is defined to
be a logical LOW or 0, but the value is not required to be zero. When a signal is not
centered around zero the signal is said to have a DC offset that raises or lowers the signal
to a new center voltage. Signals that do not have DC offsets fall into the realm of AC
signals, since their voltages will fall below zero and therefore reverse the flow of current.

        Each time that the voltage of a digital signal rises to its HIGH state and then back
to its LOW state, the signal is said to have pulsed. The amount of time that a digital
signal remains in its HIGH state before returning to the LOW state is called the pulse
width. The period of a digital signal is length of time before a signal repeats itself.
Adding the HIGH pulse width and the LOW state time together is also equal to the period
of the signal. The frequency of a digital signal is equal to the inverse of the period, and
represents the number of times that a signal repeats itself in one second. All of the stated
elements of a digitally oscillating signal are shown and labeled in Figure B2.




                              Figure B2: Digital Signal with Labels

PWM Signals

        Pulse Width Modulation (PWM) is a process which changes the pulse width of a
signal, while keeping the frequency/period constant. The result is a signal that may be
switched HIGH for a longer or shorter amount of time than it is switched LOW. When a
PWM circuit alters the pulse width in this way, it is said to be changing the duty cycle of
the signal, which is the ratio of the pulse width time over the total period. Duty
Cycle is a dimensionless quantity that is stated as a percentage. Figure B3 shows two
examples of pulse width modulated signals.




Written by Texas A&M University                                                             3
                            Figure B3: Pulse Width Modulated Signals

Average Voltage / Current / Power

        Another property of a PWM signal is that the time average values of its voltage
and current vary with its modulation. A digitally oscillating signal that is HIGH and
LOW for equal amounts of time has a time average voltage or current equal to 50% of the
difference between its HIGH and LOW voltage/current values. During the time that the
signal is HIGH, the voltage and current are at their maximum values, but when the signal
is LOW the voltage and current are at their minimum values. Power is equal to voltage
multiplied by current, and therefore the average power is directly proportional to the
square of the duty cycle, since both the average voltage and average current rise with
duty cycle.

        Since pulse width modulation varies the duty cycle of a signal, it also varies the
average voltage and current levels in the circuit. If the frequency is high enough, this
average voltage or current can be interpreted as a virtual DC value. An analogy is that a
video is a collection of still pictures, but it looks like smooth motion to our eyes, since the
pictures change faster than the eye can respond. Similarly, a PWM signal fed into a motor
will act as a smooth voltage if the PWM frequency is high compared to the rate at which
the motor can respond.

        Pulse width modulation is much more complicated than using a circuit with
resistors to divide the voltage or current. However, since resistors dissipate all of their
power as heat, they perform little useful work with the power they are given. Because a
PWM signal can change the apparent DC values of a circuit without the use of resistors,
they waste very little power. This is a useful property in situations where power is not
unlimited.




Written by Texas A&M University                                                               4
HOW THE 555 TIMER GENERATES A PWM SIGNAL

        The 555 timer is an integrated circuit that has been used for decades in electronics
for pulse generation, time delay generation, and pulse width modulation. As shown in
Figure B4, a 555 timer consists of two comparators and a Flip-Flop which is a device
used in digital logic similar to an SR Latch. Flip-Flops are not covered in this series of
labs, but they are extensions of latches that also hold their outputs stable until they have
been changed by a differing digital input. The comparator inputs are fed by an RC time
constant provided by the user, An animated schematic of the 555 as an oscillator is
available online at http://www.williamson-labs.com/pu-aa-555-timer_med.htm to help
you understand its function. Many other 555 timer resources are available on the Web.
See http://www.uoguelph.ca/~antoon/gadgets/555/555.html for a tutorial.




                           Figure B4: NE555 functional block diagram



Diodes

        As shown in Figure B5, a diode is made by combining two portions of p-type and
n-type semi-conducting material.




Written by Texas A&M University                                                            5
                          Figure B5: Diagram of a PN Junction Diode

A diode is an electrical device which regulates the flow of current through a circuit.
Depending on the polarity of the voltage applied across it, a diode will be either turned on
or off. Figure B6 shows the two possible states of an ideal diode and how the current in
the circuit is affected by the diode’s state.




                                  Figure B6: States of Diode

As you can see, if the diode voltage is forward biased then the current will flow freely in
the circuit. However, if the diode voltage is reversed biased current cannot flow in the
opposite direction through the diode. It is also important to note that when in the forward
biased state an actual diode will have an associated voltage drop across it, which is usual
equal to approximately 0.7 volts for a silicon diode.

The PWM Generation Circuit

        Figure B7, contains a schematic of one method for using a 555 timer to create a
fixed frequency PWM signal.




Written by Texas A&M University                                                           6
                  Figure B8: Schematic for a PWM Generator Using a 555 Timer

In the schematic, C1, R1, R2, and the potentiometer are all used to vary the timing of the
circuit. The reason that the pulse width of the signal is variable in this configuration is
that diode D2 creates a path for current to bypass the resistance between the tap of the
potentiometer and D1 to charge capacitor C1. Further, as the capacitor discharges, D2
prohibits the flow of current directly to ground and forces the capacitor to discharge
through D1 and the previously avoided resistance. During the charging cycle a voltage
drop is induced across D2; as such diode D1 is necessary to repeat that same voltage drop
during the discharge cycle so that the operating frequency of the signal is maintained.
The equations which govern the Duty Cycle and frequency of this configuration are given
as:

              t1 ( HIGH )  0.67 * R A * C1          t2 ( LOW )  0.67 * RB * C1

                                                                      1
                    Period  T  t1  t 2           Frequency  f 
                                                                      T
where RA is equal to the total resistance of R2 plus the resistance between R2 and the tap
of the potentiometer (between 100 and 10.1k ohms), and RB is equal to the resistance
between the tap and R1 plus the resistance of R1 (between 100 and 10.1k ohms). The
duty cycle varies from approximately 1% to 99%.

DC Motor Control
       If you swap the power connections of the motor (e.g. swap the black and white
wires on the cable driving the motor), the motor will change directions. NOTE: Be
careful not to swap the black (ground) and white (positive battery voltage) wires
running from the Lego brick outputs. This will put reverse voltage on your circuits,
and may destroy chips such as the LM393 and NE555. The motor reverses directions


Written by Texas A&M University                                                          7
when the connections are swapped because the current flowing through the motor has
changed directions. When current moves through the windings of a motor, it produces an
associated electromagnetic field. The magnetic field produced by the wires attached to
the armature (rotating core) of your DC motor reacts with the inherent magnetic field of
small permanent magnets attached to the sides of the stator (fixed shell). This reaction
either attracts or repels the windings of wire attached to the axle and causes it to turn.
Figure B9 is a basic diagram of a DC motor and its components to assist in understanding
its operation.




                            Figure B9: Diagram of Basic DC Motor

Conveniently enough, if a magnetic field is produced by flowing current in one direction,
the opposite magnetic field is produced by flowing current in the opposite direction and
therefore causes the motor to turn in the other direction. This is what causes the motor to
change directions when the motor power wires are switched.

DC MOTOR SPEED CONTROL

        The DC motors on your robot are capable of varying their speed based upon the
current that is drawn through them. The driving force of the motor is caused by the
interaction of the magnetic field produced by the current though the windings on the
armature and the permanent magnets attached to the stator. The magnitude of the force
caused by this interaction varies as the current through the windings varies, thus
regulating the speed of the motor.

Speed Control Using a PWM signal

        In Lab 4, you controlled the speed of your motors by limiting the current through
it with a potentiometer. A PWM signal can also be used to vary the motor speed. As
mentioned previously, the average voltage and current of a PWM signal can be adjusted
by modifying the duty cycle of the signal. When the current through the motor is varied
using a PWM signal, the end result is the same as when the current is modified using a
resistor; causing the motor to slow down.

        A PWM signal has two advantages when controlling motor speed. First, since it
turns the motor on or off, it does not waste as much power as using a resistor to control


Written by Texas A&M University                                                             8
the speed. Second, unloaded motors usually have a linear speed-voltage relationship. The
relationship for the NXT motor is shown in Figure B10.




               Figure B10: Unloaded NXT speed vs. voltage (from www.philohome.com).

        However, in Lab 4, you discovered that the speed is superlinear in voltage when
the motor is under load. The NXT characteristics are shown in this table from
http://www.philohome.com:



                                 Rotation         Mechanical Electrical
                     Torque               Current                       Efficiency
                                  speed            power      power
       NXT

       4.5 V       16.7 N.cm      33 rpm     0.6 A       0.58 W        2.7 W          21.4 %
        7V         16.7 N.cm      82 rpm     0.55 A      1.44 W       3.85 W          37.3 %
        9V         16.7 N.cm     117 rpm 0.55 A          2.03 W       4.95 W          41 %
       12 V        16.7 N.cm     177 rpm 0.58 A          3.10 W       6.96 W          44.5 %


         As can be seen, doubling the voltage from 4.5V to 9V increases motor speed by
3.5x. In a PWM signal, since the motor is either all the way on (full voltage) or all the
way off, the speed is simply proportional to the full power speed times the duty cycle. So
a 50% duty cycle signal will run the motor at half its full speed for that voltage and
torque. (Torque is the twisting force on the motor, e.g. the force that the wheel exerts
when resisting turning against the floor).




Written by Texas A&M University                                                                9
LAB EXERCISES
BEFORE YOU COME TO LAB: As in Lab 4, you will drive the robot in a circle with a
radius of 2 feet. In order to do this, you must first calculate what speeds you will need
each motor to operate at, so that the robot will follow the circular path. Use Figure L1
and the equation below to determine the wheel speeds necessary to navigate this path.


            Speed1 Radius1    2 feet
                          
            Speed 2 Radius2 2 feet  w                               R1

                                                                R2



           w = width of robot

                                                  Figure L1: Circular Path of Robot

The width of the robot from wheel center to wheel center is 11.3 cm, and the tires are 5.7
cm in diameter. The ratio should produce a circular path which places the outside edge
of the robot on the 4 foot diameter circle. Enter the values for the speeds of the right and
left wheels in Table L2. As in Lab 4, the outer wheel will run at full speed, and you will
reduce the speed of the inner wheel using PWM.

                            CIRCULAR PATH WHEEL SPEEDS
                                  Right Wheel Left Wheel
                        Speed
                        (ft/s)
                                            Table L1

    You will use the 555 timer to produce a PWM signal which will control the speed of
the inner wheel. First, you will need to construct the circuit given in Figure L2.




                                 Figure L2: PWM Speed Control



Written by Texas A&M University                                                           10
     The pinouts of the Texas Instruments NE555P timer are shown in Figure L3.
VERY IMPORTANT: Unlike most chips, pin 1 is ground, rather than pin 4 as in the
LM393. Due to its ancient age, the 555 violates the normal pin-out convention.




                               Figure L3: Texas Instruments NE555P pinout

        As discussed above, the two 100 resistors limit the PWM duty cycle range from
about 1% to about 99%. The diodes permit the duty cycle to be >50% (high). The output
drives a 1k resistor to the base of a 2N3704 NPN transistor to power the motor, since the
555 output cannot quite provide the current required of the motor. As a reminder, the
2N3704 has a non-standard pinout, shown in Figure L4.




Figure L4: Packaging Diagram of 2N3704 NPN Transistor. It is housed in a TO-92 package. With the flat
side up, the emitter is on the left, collector in the middle, and base on the right. (Most transistors have the
                                base in the middle and collector on the right).

When determining which capacitor is which, the following website for capacitor codes
may be useful: http://xtronics.com/kits/ccode.htm.

The diodes have a line on the end that corresponds to the line in the schematic. That is,
current flows out of the end with the line.

EXPERIMENTAL PROCEDURE

    1. The first test will be to run the robot in a straight line. Attach your PWM circuit to
       the faster motor. Calculate the duty cycle needed to have faster motor run at the
       same speed as the slower motor. Remember that in Lab 4, you computed the
       difference in resistance between the two motors, and put a potentiometer on the
       lower-resistance (faster) motor to slow it down. In this case you will adjust the


Written by Texas A&M University                                                                             11
      duty cycle of the PWM circuit to slow the faster motor down by a corresponding
      amount. For example, suppose the left motor is 50 ohms and the right motor is 55
      ohms, for a 7.2V battery, the left motor draws the left motor draws 144 mA and
      the right motor draws 131 mA. To reduce the left motor current to 131 mA, the
      effective left motor voltage must be reduced to 6.55V (131 mA * 50 ohms). This
      is 91% of the battery voltage (6.55V/7.2V). So the PWM circuit should be set to
      91% duty cycle.

   2. Calculate the values of RA and RB above to achieve the appropriate duty cycle and
      adjust the potentiometer accordingly. Recall that RA is the value of Ra plus the
      value between the Ra connection and the tap on the pot in Figure L2. Similarly for
      RB.

   3. We can use an oscilloscope to measure the duty cycle directly, but an alternative
      is to measure the voltage from the 555 with your voltmeter. Your voltmeter
      responds more slowly than the 555 frequency, so will measure the average value.

   4. Run your robot with the calculated duty cycle. Tweak the potentiometer until the
      robot runs in a straight line. Afterwards, measure the resistance of each side of
      the potentiometer and calculate the duty cycle actually used. Use your voltmeter
      to measure the average voltage out of the PWM circuit. Note that you should
      measure it directly at pin 3, since the voltage at the base of the transistor will be at
      most 0.8V. Record all values in Table R1.

   5. Using the process above, calculate the potentiometer resistance which would
      cause the robot to follow a circular track with a radius of 2 ft. Use the speeds that
      were calculated before the lab in Table L1. Record the calculated value of RA in
      Table R2.

   6. Test your calculated values by running the robot in a circle. If your values are not
      satisfactory, adjust them so that the robot successfully navigates a 4-ft diameter
      circle. Record your corrected value of RA, along with their associated percent
      error from the calculated values in Table R2.




Written by Texas A&M University                                                            12
RESULTS: to be uploaded onto WebCT

                             Straight Line Values

                        Speed (ft/s)
                        Calculated RA
                        (kΩ)
                        Calculated Duty
                        Cycle (%)
                        Measured PWM
                        Output Voltage
                        (V)

                        Tweaked RA
                        (kΩ)

                        Calculated
                        Tweaked Duty
                        Cycle (%)

                        Measured MWP
                        Tweaked Output
                        Voltage (V)
                                    Table R1


                                  CIRCLE RUN
        Calculated RA               Corrected RA
        Resistance                  Resistance      % Error
        Inside                      Inside
        Wheel                       Wheel
                                    Table R2




Written by Texas A&M University                               13
REPORT: to be uploaded onto WebCT
REPORT REQUIRMENTS

   Answer the following questions:

   -   What are the pros and cons of the current limiting (via resistor) motor speed
       control method used in Lab 4?
   -   What are the pros and cons of the PWM motor speed control method?
   -   What would be your recommendation and why, for which system to use if:
          o Your robot needed cheap and effective speed control.
          o Your robot was going to be used by NASA to explore Mars.




Written by Texas A&M University                                                        14

				
DOCUMENT INFO
Shared By:
Stats:
views:91
posted:12/8/2009
language:English
pages:14
Description: texas a&m university