Pages created and updated by Terry Sturtevant Date Posted: February 19, 2020

CP316: Microprocessor Systems and Interfacing

Ultrasonic sensor speed control

Objectives

This lab will address servo motor speed control mediated by an ultrasonic distance sensor.

Equipment

Procedure

Basic servo motor control

You want to have at least two different speeds; i.e. a medium speed and a high speed. You also want to be able to stop the motor completely.
Note: In all of the lab exercises, you can recompile to change speed; i.e. you don't need to have user input to change speed.
  1. Modify existing sketch to control one motor. Question: If your PWM choices won't allow a "stop" position between one direction and the other, is there another choice that can be made to stop the motor?
    Demonstration - demonstrate what you have achieved.

Use alternate PWM process

One of the ways to keep your options open during prototyping is to develop different approaches in parallel.
  1. Use a different method of PWM control to calibrate the motor. If at all possible, use the same pin so that only the code needs to change.
    Demonstration - demonstrate what you have achieved.

Calibrate both motors

  1. Modify each sketch to control other motor as well.
    Is there anything about the other motor that requires a different approach? As above, use the same pin in both sketches so that only the code needs to change.
  2. Find parameters to match speed in motors.
    You want to match both the medium speed and the high speed. (If one motor has a higher top speed than the other, you may need to keep the faster motor at less than maximum speed.)
    Did either method prove substantially easier?
    Demonstration - demonstrate what you have achieved.

Use distance to adjust motor speeds

For cruise control, the speed can be higher if the distance is greater. The important thing is to have both motors adjust speed together so the robot will go in a straight line.
  1. Create a "too close" distance, within which the robot stops; a "slow distance", within which the robot goes at medium speed; and a "fast distance", beyond which the robot goes at maximum (straight line) speed.

    Demonstration - demonstrate what you have achieved.
Creative Commons License

Information on this site which is produced by Terry Sturtevant is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.5 Canada License.

Resources

To view pdf documents, you can download Adobe Acrobat Reader .
get Acrobat Reader
If you need to update a browser, you might try Firefox which is Get Firefox!
Since this page uses cascading style sheets for its layout, it will look best with a browser which supports the specifications as fully as possible.

If you are looking for an office package, with a word processor, spreadsheet, etc., you might try LibreOffice which is Get LibreOffice!

Go to the main page for the Department of Physics and Computer Science.

Valid XHTML 1.1

Valid CSS!

WCAG
2.0
(Level AA)

Wilfrid Laurier University