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; lcd_init(); do { echo_time=0; delay_ms(1000); output_low(PIN_D2); output_high(PIN_D2); delay_us(15); output_low(PIN_D2); delay_us(100); while(input(pin_d3)) echo_time++ printf(lcd_putc,"\fecho:%04ld\n",echo_time); } while (TRUE); } it is not entering the while loop at all. Please reply me as asap .Thank you Sreenu Dindi |
|

srf04
Started by ●August 13, 2003
Reply by ●August 14, 20032003-08-14
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 ●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, Sreenu Dindi University of South Carolina Department of Electrical Engineering Phno: 803-765-9589 |
Reply by ●November 10, 20032003-11-10
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 |
|
