View Single Post
  #2   Spotlight this post!  
Unread 28-01-2008, 22:52
wt200999's Avatar
wt200999 wt200999 is offline
Texas Instruments
AKA: Will Toth
FRC #3005 (Robochargers)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2004
Location: Dallas, Texas
Posts: 323
wt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud of
Send a message via MSN to wt200999
Re: Ultrasonic Range Finder

I believe that you must use 2 digital ports, no analog. How this thing works is you send a 10 microsecond (us) pulse to it, then you have to wait until you get an input pulse on your digital input port, and you have to measure the length of the pulse. This diagram from that site should help



from
http://www.robot-electronics.co.uk/htm/srf04tech.htm

For sending the output pulse you can simply do

Code:
rc_dig_out18 = 1;
for(x=0;x<10;x++);
rc_dig_out18 = 0;
or something similar.

To measure the pulse you have to set up an interrupt on whichever port you are using as an input (I would suggest port 1 or 2) and a timer. I ended up using timer3. I also wrote it to work with two sensors on 2 outputs and 1 input. I haven't tested the second one yet, but it should work. The only problem I am having is converting my time to millimeters...

If you have any questions about that ask away. I believe there is code somewhere on these forums for this as well, or I can post up mine tomorrow when I get back to school.

Edit: Take a look at this:
http://www.chiefdelphi.com/forums/sh...ad.php?t=42717
Interesting code that you could try.
__________________
Programming in LabVIEW? Try VI Snippets!

FIRST LEGO League 2004 - 2005
FRC Team 870 Student 2006 - 2009
FRC Team 3005 Mentor 2013 -

Last edited by wt200999 : 28-01-2008 at 23:23.