kris_maher
New Member
Hi,
I'm building an Ultrasonic Rangefinder, it transmits a amplified square wave at 40KHz, and receives (via receiver circuit) a weakened sine wave which is then filtered, amplified and converted to a square wave again before being sent back to the microcontroller for processing.
I initially tried programming with via measuring the echo (delay) between the signals however perhaps it was my coding that might have had a glitch.
Anyway I've decided to check out "Phase Shift Detection" method for distance measurement. I would need to measure the phase difference between the square waves via sampling using ADC.
Just wondering if someone can point me in the right direction thanks since I've never done anything related to phase shift before (except only in engineering maths). Also the return signal would be 40KHz as well and also I'm not using any other hardware such for phase shifting, I'm expecting to do it all in software once the received signal is taken in by the micro. Oh and btw I'm using an external 16MHz crystal.
Thanks again,
PS: My code already transmits a continuous square wave via CTC mode using interrupts at 40KHz on timer 1.
PS2: I have this formula though which I've found from some research though I'm not sure if it's correct or not for my job.
Phase Shift = (2*pi*f*L) / C.
For C = speed of sound (taken as 340.29m/s), L = distance of object
I'm building an Ultrasonic Rangefinder, it transmits a amplified square wave at 40KHz, and receives (via receiver circuit) a weakened sine wave which is then filtered, amplified and converted to a square wave again before being sent back to the microcontroller for processing.
I initially tried programming with via measuring the echo (delay) between the signals however perhaps it was my coding that might have had a glitch.
Anyway I've decided to check out "Phase Shift Detection" method for distance measurement. I would need to measure the phase difference between the square waves via sampling using ADC.
Just wondering if someone can point me in the right direction thanks since I've never done anything related to phase shift before (except only in engineering maths). Also the return signal would be 40KHz as well and also I'm not using any other hardware such for phase shifting, I'm expecting to do it all in software once the received signal is taken in by the micro. Oh and btw I'm using an external 16MHz crystal.
Thanks again,
PS: My code already transmits a continuous square wave via CTC mode using interrupts at 40KHz on timer 1.
PS2: I have this formula though which I've found from some research though I'm not sure if it's correct or not for my job.
Phase Shift = (2*pi*f*L) / C.
For C = speed of sound (taken as 340.29m/s), L = distance of object
Last edited: