Useful links


EXPERIMENT #9 PRELAB

From now until the end of the semester you should be thinking about how you will design your circuit. You need to think about making the circuit as robust as possible so that it is less dependent upon random factors such as which car you use and the battery. So lets look at the circuits that you used to negotiate the track - a 'tape-following' circuit, a 'tape-avoiding' circuit and one that combined the two circuits. Look at the two circuits in the figure below, the left one is the one that you used in the previous lab and the other is a circuit that combines the two strategies in a different way.

The sequential circuit that we will be using to control the speed of the motors is called a pulse width modulator because it supplies at the output a square wave whose duty cycle is variable. This square wave is to be supplied to the motors. Instead of using a variable resistor to vary the motor speed we will supply the motor maximum voltage/current for a limited period of time – a period set by the duty cycle of the signal. The longer the motor is provided with current during each period of the square wave, the faster the motor runs.

Pasted Graphic 14

A block diagram of the pulse width modulator is shown in the figure below. It consists of an oscillator – this provides the clock pulse that runs the counter, a counter that simply counts from 0 to 15 over and over, and the comparator that is the heart of the device (you will figure out what it does during this lab). The counter supplies one set of inputs to the comparator and the user supplies the other set - it is these user supplied inputs that will be used to determine the duty cycle of the resulting square wave.

Pasted Graphic 15

The PWM accepts inputs from sensors directly or from logic that uses the sensor data in a more sophisticated algorithm. The output of the PWM comes from the comparator on the PWM module and is input to the CA module to turn the motors on and off as well as vary the speed of the motors.

Pasted Graphic 17


  1. Draw the timing diagram for the signals on the PWM module by filling in the diagram below - signals Q0, Q1, Q2, and Q3 are the outputs of the counter and the outputs of the comparator one of which you will use to drive the motors on your vehicle. See links to the left for schematics of the PWM and the MUX module. Assume that the inputs to the comparator are A0=1, A1=0, A2=1, and A3=1.


Pasted Graphic 34


  1. Describe how the MUX module works (the schematic can be found by using one of the links in the left sidebar. What does the multiplexer choose between and how is the selection done?

    EXPERIMENT #9


    Pulse Width Modulation - more robust speed control

    So far the only way we can control the speed of the vehicle is to control the value of the variable resistor attached to the vehicle. As you found when you played with the different navigational circuits that some of the designs - the tape following design in particular - are very sensitive to the speed. In fact the tape following designs will not work without much additional circuitry OR the pulse width modulator (PWM). The most important contribution of the pulse width modulator is that of providing a larger range of control at the slower speeds. Because the pulse width modulator pulses the motor with maximum voltage the torque provided is much greater than providing a smaller voltage. So the car can run at VERY slow speeds with the PWM.


    Pasted Graphic 2


    a) investigate the workings of the Pulse Width Modulator -

    First we will look at how the PWM works using the digital designer's friend. You can monitor the output signals with the oscilloscope since they are time varying, periodic signals, but the oscilloscope only has two channels and is not optimized to interface with TTL logic. A logic analyzer on the other hand has 16 channels and can be programmed to interface with several types of logic (TTL, CMOS ...).

    ------------------ SETTING UP THE PWM and MUX modules

    Below the current amplifier module on each side of your protoboard place the PWM module and then the MUX module. Hook each module up to Vcc and ground.

    ------------------ SETTING UP THE LOGIC ANALYZER

    The logic analyzer (see photo below) allows you to monitor 15 time-varying digital signals that are not necessarily periodic. The probe is a ribbon cable with a connector on one end that plugs into the logic analyzer (lower right) and 16 probes on the other end that attach to points in the circuit under test.

    Pasted Graphic 22


    To connect to points in the circuit we will be using either a 14- or 16-pin test clip to make the signals more accessible. These test clips attach to individual chips - every pin on the test clip should touch only one pin on the IC. Make sure that the clip is firmly seated - ask the TA to check it the first time. You should be able to see why we need these test clips - it is much easier to attach the logic probes to the leads on the test chip than to the chip itself. Once the test clip is in place the individual probes can be attached to the leads and the signals monitored.

    Pasted Graphic 18


    Attach the logic analyzer to the oscillator - Since the pulse width modulator (PWM) is a sequential circuit it needs a clock pulse to transition from one state to the next. In this circuit the rising edge of a clock pulse (square wave with 50% duty cycle) is used to change the state of the counter. With the vehicle on its stand and the power off, place the PWM module on the protoboard and connect pin 8 to ground and pin 16 to Vcc both supplied by the battery through the logic voltage. Carefully squeeze the 14-pin test clip and clip it to the oscillator 74LS624 IC- the chip on the right as viewed from above. The pins on the logic probe are numbered just like the chip. Find pin 7 which should be connected to ground inside the module and connect the black wire to it - this provides a reference for the other signals. Connect the probe with the brown label to pin 6.


    Turn on the logic analyzer and the vehicle and you should see the clock on the screen of the logic analyzer. Draw the clock and estimate its period. Is this period short enough? Long enough? What would determine the period for this application?


    1. Turn on the logic analyzer and the power to the vehicle. One of the green traces on the screen should show the clock pulse. Draw the clock and estimate its period. This period should be adequate for our purposes. List some factors that might affect your choice of period.


      Attach the logic analyzer to the counter - Lets look at the counter next. Its purpose in the circuit is to simple count from 0 to 15 over and over and over ... With the power off on the vehicle, connect the 16-pin test clip to the counter 74LS 169A and connect the black wire to ground (pin 8). Connect the logic probes as specified in the table below.


      Pasted Graphic 21


    2. Once the probes are connected you should see the clock as supplied by the oscillator and the four outputs from the counter. Sketch these timing diagrams in your notebook. Do they look like the ones you drew for prelab?
    3. Each of the 4 signals coming from the counter is a periodic square wave. How do the periods of each of these signals compare with the period of the clock pulse?


      To specify the duty cycle of the square wave output to the PWM 4 signals need to be supplied. They represent a number from 0-15 that is compared to the output of the counter which determines how many of the 16 pulses the output should be high - as we shall see. A simple way to specify these four signals is to use one of our other modules called the MUX module because is has a multiplexer chip that lets these four signals originate from the switch on the module so that we can set the number by hand OR from sensors. Place this module on the protoboard near the PWM and hook up the power and ground. Connect pins 4, 7, 9, and 12 from the MUX module to pins 10, 12, 13, and 15 of the PWM. Look closely at the red switch on the MUX module - the swithes are labeled 1, 2, 3, 4, and 5. Switch 5 controls the select pin on the MUX (74LS257 chip) and should be UP to manually set the duty cycle using the switch. Switch 5 in the down position allows an alternate set of signals to drive the PWM's duty cycle. REMEMBER: power and ground must be connected first for this module to work.

      Pasted Graphic


    4. Using the link in the left sidebar look at the schematic of the PWM. From what chip on the PWM do the outputs connected to pins 5,6,7 of the PWM connect to? What is the function of this chip?
    5. Controlling the duty cycle/introducing the MUX module - Set switch 1 and 2 UP and 3 and 4 DOWN. Monitor both the clock pulse from the PWM (pin 6) and the resulting square wave output from the PWM (pin 5) with channels 9 and 10 on the logic analyzer.


    6. Draw the clock pulse and the signal from pin 5 of the PWM. Explain the shape of the pulse from the PWM.
    7. Now monitor the signal from pin 6 and pin 7 of the PWM. Draw these signals and explain their shape.
    8. Put the switch into different positions and describe how the signal from pin 5 of the PWM is related to the switch settings.


      Controlling the speed of the vehicle - Make certain that both PWMs and MUXs are connected to both motors so that you can control with the switch on the MUX module the speed of both motors. To do this you need only use the output of pin 5 from the PWM to drive the CA modules. The CA is then hooked up to the motors in the standard way. Initially set all of the switches on a lowest setting - lets say 0010 (only switch 2 is UP), turn the variable resistor on the car all the way down so that it is at its lowest value - you want the PWM to provide all the speed control.


    9. Are the motors running? If not increase the setting of the switches one step up (or down) at a time until the motors running. Place the vehicle on a table. Does it run? Again if not slowly increase the setting until it does. For most vehicles the car should run, though painfully slowly, at a setting of about 0010.
    10. Experiment with different settings of the switches to change the speed of the motor. What might be a good range for navigating the track?
    11. Now set the switch to the highest value 1111 - all switches UP. Put the car on the stand and try to - by adjusting the variable resistor knob on the back of the try to set the wheels turning at the same speed as they were when you set the switches to the lowest position where the car would move when set on the table. This needs only be approximate. The point that I would like you to get is that even though the wheels are moving at the same slow speed when the speed is controlled by the variable resistor the motor does not have enough torque to move the vehicle when it is on the table.


      b) speed control using the PWM

      REMOVE THE MUX module from the circuit. We are going to use the tape following circuit so hook it up to the motors. Take the vehicle to the track and try to navigate on of the sharper curved turns. As you will see this navigation scheme fails very quickly because once the sensors lose the tape the vehicle stops or keeps going but off the tape. Try to find a speed using the variable resistor on the back where the vehicle will navigate the turn. You will probably find it very difficult to hit just the right spot. Now we are going to use the outputs of the tape following circuitry to drive the duty cycle of the PWM. Since you have removed the MUX module the signal from the tape following circuitry must provide the 4-bit input that previously came from the switches on the MUX module. These inputs are pins 10, 12,13, and 15 of the PWM module. Pin 10 is the least significant bit and pin 15 is the most significant bit. At first connect the signal from the tape following circuit that drives the left motor to the third most significant bit (pin 13) of the PWM on that side. Do the same for the right side. This sets the duty cycle at 1/4 the maximum since we are providing 0100 as input to the PWMs. Now try to navigate the same curvy portion of the track. Did the performance improve? Tape following circuits with multiple sensors using the PWM actually perform quite well.

      Pasted Graphic 1

    12. In your lab notebook draw the circuit including the PWM indicating how you hooked up the tape following circuit. Try 2-3 sensor layouts and indicate which allows your to follow the track the best. Describe your experience with car using the tape following circuit with and without the PWM.