Lab 6 - PWM - "Robot Motion"

Motors Overview

Driving high current loads with logic

Teaching Notes

A Note On Robot Sharing

Lab Overview

This lab is designed to provide you with experience using the pulse-width modulation features of the MSP430. You will need to program the MSP430 to generate pulse-width-modulated waveforms to control the speed / direction of your robot's motors. In this lab, you will make your robot move forward, backwards, a small (< 45 degree) turn left/right, and a large (> 45 dgree) turn left/right.

Driving Motors

Our mobile robots have DC motors to drive the wheels. The amount of torque provided by the motor is directly proportional to the amount of voltage provided. Therefore, there are two ways of varying the speed of the DC motors:

  1. Provide an analog voltage where the magnitude is proportional to the output torque desired.
  2. Provide a PWM signal where the duty cycle provides an "average" voltage proportional to the output torque desired. This is shown in Figure 1.

PWM to Motor

Figure 1: The PWM signal creates a certain duty cycle which will provide an "average" voltage to the motor. This average voltage is proportional to the motor's output torque.

The motor can move in two directions. If you ground one terminal of the motor and connect the PWM signal to the other side of the terminal, then the motor shaft moves in one direction. If you swap the terminals, the motor will move in the opposite direction.

You might want to program your robot so it turns like a tank; one wheel moves forward while the other one reverses. You will have to experiment with your robot to find out how long the PWM signal needs to be provided to turn an appropriate amount.

Required Functionality (50 pts)

Demonstrate movement forward, backward, a small (< 45 degree) turn left and right, and a large (> 45 dgree) turn left and right. The robot should perform these movements sequentially, completely disconnected from a computer (no USB cord).

Remote Functionality (15 pts)

Control your robot with your remote! You should use at least four different buttons on the remote: one each to indicate motion directions of forward, backward, left, and right.

Prelab (25 pts)

You need to provide the following:

  1. Answers to all bulleted questions below
  2. Completed Lab 6 schematic
  3. Software flowchart and/or pseudo-code

Consider your hardware (timer subsystems, chip pinout, etc.) and how you will use it to achieve robot control.

Spend some time here, as these decisions will dictate much of how difficult this lab is for you.

Consider how you will setup the PWM subsytem to achieve this control.

Consider what additional hardware you'll need (regulator, motor driver chip, decoupling capacitor, etc.) and how you'll configure / connect it.

Complete the Lab 6 schematic. Include a neat picture in your README.

Consider the software interface you'll want to create to your motors.

Include whatever other information from this lab you think will be useful in creating your program.

Notes

Motor Control Suggestions

There are many ways to control your robot motors using the resources on the MSP430. I'm leaving this purposesly open-ended to see the creative approaches you come up with. Here are a few ideas to get your started:

Or invent your own!

Using the MSP430 and Launchpad with the Robot

See the writeup available in the datasheets section of the site.

Motor Driver Chip

The robot motors require ~12V and a high amount of current b both of which would immediately burn out your microcontroller if it were directly connected to the motors. The motor driver chip (SN754410) takes a 5V input and produces a ~12V output. Each chip has up to four channels of 5V inputs (1A, 2A, 3A, and 4A) and four corresponding 12V outputs (1Y, 2Y, 3Y, and 4Y).

Measure voltage across the 12V rail to determine what is actually being supplied by your battery.

The motor driver chip can only supply 1A per circuit! Do not exceed that!

You can test your 12V PWM motor driver chip output by connecting it to the oscilloscope. Do not use the logic analyzer for the 12V PWM signals!

Motor Stall Current

To ensure you never exceed 1A drawn from your motor driver chip, you have to determine the worst-case current draw from your motors. This is called the motor stall current and usually occurs when your robot is pushing against an object it can't move (i.e. a wall) or switching directions quickly.

To measure motor stall current, connect your robot to a power supply in series with an ammeter. Allow the wheel to run freely and apply a voltage you expect to use. Then, stop the wheel with your hand and monitor the current. This is your worst-case expected current draw at that voltage. If it exceeds 1A, you can't run your motor at that voltage or risk burning your motor driver chip on motor stall. Reduce the voltage until the stall current is below 1A to see a safe voltage you can drive your motor at.

On my robot, the stall current does not go below one amp until my motor is being driven at 8V or less - roughly 60% duty cycle. Exceed this at your own risk!

Decoupling Capacitors

The robot motors have the potential to create voltage fluctuations due to sudden spikes in current draw. They can also induce noise on the 5V line. This can cause your microcontroller to reset. To mitigate these fluctuations and noise, you'll need to use some capacitors:

How to Drive Your Motors

Breaking Parts

You'll probably break parts on this lab - you'll know by the burning smell!

This will sometimes result in a short, causing you to burn out one of the fuses on the battery management board that protect the batteries. When the light on the battery goes from green to yellow, that means there's something wrong. Either the battery is dead or you've burned a fuse.

To test whether a fuse is burned, use the ohmmeter - a working fuse should have very little resistance. You should turn off the power before you do this! You can also use a voltmeter - there shouldn't be much voltage drop across a working fuse. If you have burned a fuse, don't just replace it and try again - try to figure out what caused the fuse to burn in the first place! If you burned your motor driver chip, replace that - but also figure out why you burned it! If you don't fix the root cause, you'll just break more parts and cost yourself more time / frustration.

Grading - Lab 6

Printable Lab 6 Cutsheet

Name:

Section:

Documentation:

Item Grade Points Out of Date Due
Prelab On-Time: Zero ---- Check Minus ---- Check ---- Check Plus ---- 25 BOC L33
Required Functionality On-Time: -------------------------------------------------------------------- Late: 1Day ---- 2Days ---- 3Days ---- 4+Days 50 COB L35
Remote Functionality On-Time: -------------------------------------------------------------------- Late: 1Day ---- 2Days ---- 3Days ---- 4+Days 15 COB L35
Code On-Time: Zero ---- Check Minus ---- Check ---- Check Plus ---- Late: 1Day ---- 2Days ---- 3Days ---- 4+Days 10 COB L35
Total 100