Lab 9 – Sonar 

advertisement
EENG 383
Microcomputer Architecture and Interfacing
Fall 2015
Lab 9 – Sonar October 29, 2015
In this lab you use the HCS12 microcontroller on the SSMI board to interface to an ultrasonic
range sensor (sonar). At periodic intervals the distance to an object is displayed on the LCD
module. The periodic intervals are generated using the output compare ISR. The input capture
unit is used to measure the echo pulse which is proportional to the distance to the object.
The documentation for the sensor is on https://acroname.com/products/r93-srf04 and
http://www.robot-electronics.co.uk/htm/srf04tech.htm. (You may have a newer model, the
SRF05, but it is completely compatible with the SRF04. It just draws less current and has a little
longer range.)
1 PrelabQuestions(completepriortocomingtolab)
Read the sonar’s technical documents before coming to lab and answer the following questions:
1. What is the conversion factor from the pulse width in μS to the distance in cm? You can
calculate this using the speed of sound, and taking into account that the pulse must travel
twice the distance to the object (i.e., travels to the object, and then travels back).
2. What is the minimum distance (cm) that can be measured? Maximum distance (m)? Use
the timing diagram and the conversion factor to calculate distance.
3. Sketch the timing diagram for both the input and output pulses for an object that is 1.5m
away for the sonar.
4. If you attach the sonar to connector J1 on the SSMI board, what pin of the connector is
used to trigger the sonar? What pin of the connector is used for the echo pulse output?
2 Connections



Connect the LCD to the SSMI board according to your schematic from Lab 7. Include a
trimpot potentiometer for the contrast adjustment. You do not need the other
potentiometer that you used in Lab 7 for the analog input.
Connect the sonar to connector J1 of the SSMI board.
Connect your power supply.
3 LCD
Verify the LCD is working. Use your program from Lab 7.
1
EENG 383
Microcomputer Architecture and Interfacing
Fall 2015
4 SonarImplementation
Generate the required trigger input signal to the sonar using the output compare ISR. Make the
trigger pulse occur every 80ms. Verify the trigger input and echo pulse output on the
oscilloscope. Note: The trigger pulse on connector J1 is hardwired to PM1. PM1 cannot
generate an output compare. You have to select a PTx port for the output compare and attach a
wire from the PTx port to PM1. Make sure that PM1 is set as an input pin.
Use input capture to measure the echo pulse in μs. Be sure to handle the case where there is no
object within range.
Sign-Off 1: Demonstrate your program and data waveform to the instructor.
5 DisplayingDistance
Use the conversion factor for the sonar and display an object’s distance on the LCD. The LCD is
to display “Out of Range” if there is no object within range.
Sign-Off 2: Demonstrate your program to the instructor. Include in your report:
1. The C language program, along with a corresponding flowchart or pseudo code.
2. Scope traces of the trigger and echo pulses.
3. An explanation of the circuit and program.
2
EENG 383
Microcomputer Architecture and Interfacing
Fall 2015
Lab 9: Sonar Name: ________________________________Name: ________________________________
Task Description Initials Sign-Off 1 Sonar Implementation
Sign-Off 2 Displaying Distance
6 Rubric
Deliverables
C code with flowchart/pseudocode
Circuit and program Explanation
Graph(s)
Composition
20 pts Pre-Lab
/ 10
Questions
/ 7 Demonstrations
/3
5 pts
Total
/ 50 pts
3
5 pts
/5
20 pts
Sign-Off 1: Sonar Implementation
/ 10
Sign-Off 2: Displaying Distance
/10
Download