Sonar Application PIC16F877 (by Douglas)
Hello Jonathan,
Sorry for my english.
I am starting with ldmicro and PIC and i need to build a project to measure the distance of objects with a Ultrasonic Sensor (Sonar) and to determinate the distance i will need to measure the pulse lenght of the sensor to know the distance.
Example: Distance = (s * t)/2 (in metres)
where:
s [m/s] the speed of sound in air
t [s] the round trip echo time.
Some delay times:
Round trip echo time Distance
t = 588us 10cm
t = 5.8ms 1m
Is it possilbe to build with ldmicro?
I am looking forward on your feedback.
Douglas (Brazil)
(no subject) (by Jonathan Westhues)
It's possible, though the time resolution will be limited by the cycle time. (Some micros have hardware that would let you measure with better resolution, but LDmicro doesn't support that.)
See the attachment, which measures the positive width of a pulse on Xin. The width is in units of cycle times; so with an 0.2 ms cycle time, for example, the 10 cm distance corresponds to a count of ~3, and the 1 m distance to a count of ~29.