Re: how to write a mikroc code for ultrasonic sensor

Re: how to write a mikroc code for ultrasonic sensor

check this schematic. Is it what you want to do. The sensor I think converts distance measured into volts. I think if that is given to adc and calibrated gives the distance. I have to code. Do you want ultrasonic based or infrared based distance measuring? What are you using the sensor for? Robotic application or Automobile?

Distance is calculated as: L = C × T/2 , where L is the length, C is the speed of sound in air, T is the time difference from the transmission from the transmitter to the receiver. This is divided by 2 for the two-directions the sound travels. Speed of sound is about: C = 344m / s (20 degrees C room temperature).

Re: how to write a mikroc code for ultrasonic sensor

its an 8 bit timer / counter module of pic. when it is configured as a timer, it will count for 0 to 255 and then set a falg. TMR0 can be used in your project 'cse of it has got better resolution than other methods.

The occasional visit of success provides just the excitement an engineer needs to face work the following day.
Koichi Tanaka