Maker Pro
Maker Pro

Distance measurement using HC-SR04

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: 47
If your picture is correct, it looks like you are overwriting the result with 0.0 continuously, making a blur.
 
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