ping sensor with 8051 mc
sara alla
Posts: 1
can i interface 8051 microcontroller with ping sensor and what about the code ?
Comments
You read the value, and 5us is Preamble (discard) and 115us-18ms is echo, so capture and compensate.
Once you have set up as a gated timer and enabled interrupts, the software is trivial, but a little more complex is dynamic range, and compensation.
See
http://en.wikipedia.org/wiki/Speed_of_sound
The 8051 has 16 bit timers, so Dynamic range needs more attention than on a Prop, but choose a newish part like the Atmel AT89LP52, and it drops out quite nicely.
Speed is ~346.18m/s or ~346.18mm/ms, so you want your timer to be 346.18 counts per millisecond, or clocked at 346180Hz
The LP52 adds prescalers to a basic 8051 (/1../512) that allow this from a generic BAUD Crystal like 11.0592MHz : 11.0592e6/(346.18/1m) = 31.94 => /32
and now your captured value is read directly in mm (well LSB is mm, total system precision is poorer than that ).
You can contrast this with a Prop, which has a quite different timer : It is actually a 80MHz, 32 bit adder.
Here, you configure a Prop to add 283 every cycle : Gives what I call a 'virtual clock' of 80e6*283 and the upper 16 bits count at
80e6*283/2^16 = 345459Hz, so your top 16 bits in a Prop, match those 16 bits in the prescaled AT89L52.