Hi to all..
I'm having a problem with my srf04 ultrasonic sensor
I'm using basic stamp 2 SX (BSX2) and I found this example on a
website
The problem is the readings that I get are not correct for example if
the distance is 20cm.
The readings that I get from the srf04 are:
21 inc. and 51 cm (Please what is the problem?)
'
`Devantech SRF04 Example
wDist var word
INIT con 0
ECHO con 1
' CONVERSION FACTORS:
'
' The PULSIN command returns the round-trip echo time in 2us units
' which is equivalent to the one-way trip time in 1us units.
'
' distance = (echo time) / (conversion factor)
'
' use 74 for inches (73.746us per 1 in)
' use 29 for centimeters (29.033us per 1 cm)
'
convfac con 74 ' use inches
'---------
main
gosub sr_sonar
debug dec wDist, cr
pause 200
goto main
sr_sonar:
pulsout INIT,5 ' 10us init pulse
pulsin ECHO,1,wDist ' measure echo time
wDist=wDist/convfac ' convert to inches
pause 10
return
Reply by sreenu dindi●August 16, 20032003-08-16
Hey I had done it. I had implemented a different method . I used the
timer1 pulse detector. Using the capture mode is easier.
bye
sreenu_dindi <s...@yahoo.com>
wrote:
Hi, I am trying to
measure the distance using srf04. I am using ccs compiler. The pic16f877
is unable to recognize the echo.. Though srfo4 is returning an echo, i had
verified it with an OScilloscope. my program ismain() { int echo_time=0;
On Wednesday 13 Aug 2003 11:40 pm, sreenu_dindi wrote:
>
> while(input(pin_d3))
> echo_time++
>
My C is a bit rusty but don't you need a ; after echo_time++ ?
Ian
Reply by sreenu_dindi●August 13, 20032003-08-13
Hi,
I am trying to measure the distance using srf04. I am using
ccs compiler. The pic16f877 is unable to recognize the echo..
Though srfo4 is returning an echo, i had verified it with an
OScilloscope. my program is
main() {
int echo_time=0;