hello,
distance=time*0.028+1.093
I tried also to understand and find out this:
FOSC=20Mhz
Cycle= 4/20=0.2µS
timer count= 0.2*8=1.6µS (prescaler=8)
at 20°C sound speed = 34000 cm/sec
within 1.6µS distance = 1.6*0.000001*34000=0.0544 cm per count
but sound distance is twice ( to come an go back)
so relationchip becomes 0.0544/2=
0.0272 cm per count
to
START the measure ,the device needs a pulse of 10µS on trigger input
then send (itself) a burst of 8 periodes of 40Khz (so during 200µS)
then echo output signal goes to 1 status...an return to 0 status when echos is back
Timer1 measure this duration
To avoid to ear the receiver when emitter send the burst salve of 40khz ,
timer1 start must begin to count after :10+210=210µS .
so minimum distance (theorical) is :
210*0.0544=
5.712 cm (0.0544 because olny one way)
and add a litle offset for calibration here offset is 1.093 cm
(maybe half of the heigh of each sensor * 2)
This offset can change also with the START event for timer1 counting !
delta temperature of 10°C => delta 1.7% on distance without compensation.
So it is better to add temperature compensation on this model of sensor..
I did it with a LM35DZ sensor..
or use another type witch include Temperature compensation
Modele US-100 Y4U1 with 5 pins (instead of 4 )