View Single Post
  #11   Spotlight this post!  
Unread 11-01-2006, 17:23
dcbrown dcbrown is offline
Registered User
AKA: Bud
no team
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Hollis,NH
Posts: 236
dcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud of
Re: Ultrasonic Range Finder

I'm using the SF04 which is similar.

I start a ping via:


iopin_sonar_out = 1; // start 10us pulse

/* wait 10us, @instruction is 100ns and there are 3 per loop */
/* loop counter = 100/3=33 */
for (counter=33; --counter != 0; ); /* ~10us delay */

iopin_sonar_out = 0; // end pulse

Then you wait for the output (echo) line to go high and time the pulse between going high until going low again. Ours is tied to one of the configurable interrupt lines and captures the system clock time in the interrupt routine at the two echo pulse edges then does the math.

You also have to wait some time between pulses, something like 50ms before you can start another ping.

See http://www.robot-electronics.co.uk/htm/srf05tech.htm for more info.

DCBrown