Presentation is loading. Please wait.

Presentation is loading. Please wait.

PHY 235 Robotics Workshop Day 5 Distance Sensing Using The Ultrasonic Ping Sensor.

Similar presentations


Presentation on theme: "PHY 235 Robotics Workshop Day 5 Distance Sensing Using The Ultrasonic Ping Sensor."— Presentation transcript:

1 PHY 235 Robotics Workshop Day 5 Distance Sensing Using The Ultrasonic Ping Sensor

2 Distance Detecting In a previous class session we used an Infrared light source, along with an infrared detector, to determine if an object was blocking the Boe-bot. The infrared detector could be thought of as a crude measurer of distance. In this class session we will look at another (more accurate) way of determining distance – by using high frequency sound waves (ultrasound).

3 The Ping Sensor The Ping))) sensor measures distance. Range: 3 cms to 3.3 m. Highly Accurate (to within 1 or 2 cm)

4 How does it work? 1.The ZX-24a sends out a short pulse to the Ping to tell it to start execution. 2.Ping waits a short time, (so ZX-24a can generate a pulseIn command). 3.Ping sends a HIGH (1) signal to ZX-24a, then sounds a short burst of 40Khz sound towards an object.

5 How does it work? 4.When Ping receives an echo, sends a LOW to ZX-24a. 5.ZX-24a stores the time between HIGH and LOW signals as a measure of distance.

6 Ultrasound

7 Activity 1 Locate the Ping Ultrasound sensor. (Your instructor will distribute) Find three Jumper wires. Build this circuit

8 Activity 1 - Code The Ping))) sensor needs a start pulse from the ZX-24a to start its measurement. A pulse to P15 that lasts 10 μs and goes from 0->1 is given by pulseOut (15, 5, 1)

9 Activity 1 - Code After the start pulse is sent, we change pin15 to an input pin and use a pulseIn command to store the duration of the Ping))) sensor's echo pulse. pulseIn(p15, 1, time) The pulseIn command stores in the variable time the round trip time for the Ping))) sensor's chirp to get to the object, reflect, and return.

10 PulseIn PulseIn(pin, level, var) From the help page: “ This routine waits for the input pin to be in the idle state (the opposite of that specified by the level parameter), waits for it to change to the specified logic level and then measures the time that it stays at that level. The pulse width is stored in the specified variable and has units of seconds with a default resolution of approximately 1.085µs”

11 Activity 1 Here is code for testing the Ping sensor: const p15 as byte = 20 dim time as single Sub Main() do call putpin(p15, 0) ' set p15 as output pin, output = 0 call pulseout(p15, 5, 1) ' send a 10 microsec start pulse on p15 call putpin(p15, 2) ' set p15 as input pin call pulsein(p15, 1, time) 'record time to transition from 0->1->0 debug.print " time="; time loop End Sub

12 Activity 1 Recall how the PING sends its return pulse. The pulseIn command allows us to capture this return pulse.

13 Activity 1 Test this program by measuring the timing values of a few close-up objects. For close-up measurements, the Ping))) sensor only needs to be 8 to 10 cm above a flat surface. However, if you are measuring objects that are more than a half a meter away, you may need to elevate your Ping))) sensor to prevent echoes from the floor (or table) registering as detected objects.

14 Activity 1 – Calibrating Ping How does the number recorded in the time variable related to actual distance? pulseIn measures time in units of seconds Thus, the time taken for the sound wave to go from the ping to an object and back again is = time However, we need to divide this value by 2, to find the time it takes for the sound wave to reach the object.

15 Activity 1 – Calibrating Ping Now, Sound travels 1 cm in about 29.034 μs. So, the distance to the object should be about Distance = time/(2*.000029) Use your Boe-bot and a ruler to verify that this formula is approximately correct.

16 Activity 1 – Metric Ping const p15 as byte = 20 dim time as single dim cm as single Sub Main() do call putpin(p15, 0) ' set p15 as output pin, output = 0 call pulseout(p15, 5, 1) ' send a 10 microsec pulse on p15 call putpin(p15, 2) ' set p15 as input pin call pulsein(p15, 1, time) 'record time to transition from 1->0 cm = time / (2.0*0.000029) debug.print "cm ="; cm loop End Sub

17 Ping Restrictions The Ping sensor cannot reliably detect objects that are: Too close Too far Too small At too great an angle

18 Activity 2 You are to create a 3-prong wire harness for the Ping sensor so that it can be mobile with respect to the Boe- bot. You will need to do some soldering for this task. Your instructor will demonstrate. Next you are to create a platform for the Ping sensor that is made from a small PC board and attach this to the side of the Boe-bot with screws and nuts. Again, your instructor will demonstrate.

19 Activity 2 Next, use your new Ping sensor board to create a program that will allow the Boe-bot to follow along a wall, at a specified distance from the wall (+- a small error amount). For example, the Boe-bot should be able to move parallel to a wall at a distance of 10cm (+- 2 cm) from the wall at all times. (See next slide) If you finish early, modify your program so that the Boe-bot can navigate corners. That is, it should be able to reach a corner, turn, and continue wall following. (You may need to add other sensors to do this).

20 Activity 2 10cm8cm12cm


Download ppt "PHY 235 Robotics Workshop Day 5 Distance Sensing Using The Ultrasonic Ping Sensor."

Similar presentations


Ads by Google