|
||||||||
|
||||||||
|
DAN149 SRF04 Interface By Michael Simpson
A couple of you have requested an interface to the some sort of sonar device. I chose the SRF04 because its cheaper then the SRF08 and a bit faster. The SRF04 will cost you between $30-$40. How it works you supply a pulse from low to high and back low again on the trigger lead to start the SRF04. This sends out a pulse. The SRF04 will then pause for a few ms then deliver a pulse on the output line. To read the range we measure the length of this pulse. I wont go into the speed of sound or the formulas used as the Dios has a command built-in that take care of all that for you. This command is called sonar. sonor pingport,echoport,variable The command will populate the variable given with the distance to the detected object in 1/64" units. If you want just inches just divide by 64. I will give you a couple program examples later. Hookup Before you hookup the unit you will have to attach wires/header or some other connector to the SRF04 as it comes with 5 holes that must be soldered.
Here I attached a 5 pin right angle header.
Schematic 1 I used a Dios Mini ultra but any Dios/DLC product will work. This first program is just a real simple example of how to read the SRF04. It will display the distance in inches in the debug window. Program 1 (download it here) 'sonar example This program is a bit more complicated. I took one of my generic bot programs and added a collision avoidance system using the SRF04. If you are telling the bot to move forward with the IR remote and it detects an object it will slam on the breaks and attempt to back up until its back out of range.
Program 2 (download it here) 'Kronos Crawler IR
control program Parts
|
Copyright © 2001 - 2007 Kronos Robotics