Maker Pro
Maker Pro

Distance measurement using HC-SR04

niranjan23

Apr 9, 2014
1
Joined
Apr 9, 2014
Messages
1
Hello......


I maked interfacing program for HC-SR04 ultrasonic seonsor with AT89S52....
but there is problem...with accurate distance.....I am not getting accurate distance in (cm)....
I attached program code below with some my project images....can you tell me what is the problem in my code...
[/ATTACH]
 

Attachments

  • IMG_20140402_220032.jpg
    IMG_20140402_220032.jpg
    136.6 KB · Views: 311
  • CODE.txt
    1.1 KB · Views: 49

Anish

Feb 5, 2011
46
Joined
Feb 5, 2011
Messages
46
Where is the code and what microcontroller are you using?
 

gorgon

Jun 6, 2011
603
Joined
Jun 6, 2011
Messages
603
If your picture is correct, it looks like you are overwriting the result with 0.0 continuously, making a blur.
 

morphingstar

Mar 1, 2012
58
Joined
Mar 1, 2012
Messages
58
When you calibrate distance you must use the difference method. Take the nearest point about 1 m away from the transducer and the farthest point the max. distance you want to measure + 20%. Then calibrate your system in a way that the 2 values shown on your indicator agree with the actual values of your reflector distances. This info is based on 40 khz, if yours is higher you may need to reduce the 1 meter distance. If it is too low you are introducing errors. I recommend >=15% of datasheet range for minimum.
Further you need to compensate for air temperature, the change is significant if you want accuracy. Consult air physics data for amount / range.
 
Top