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
- Arduino Uno
- AVR Data Sheet [pdf,660pp;
©2015]
- oscilloscope
- wave generator
- HC-SR04 ultrasonic distance sensor
HC-SR04
datasheet
- LCD display shield
- Roboot body with servo motors
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.
-
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.
- 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
-
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.
-
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.
- 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.
Wilfrid Laurier University
© 2019 Wilfrid Laurier University