Electronic – arduino – Ultrasonic signal generation

555arduinosensor

I am busy with a robotic arduino project. I have a 40kHz ultrasonic transducer and receiver. What would be the best way to generate the 40kHz signal to drive the transducer.

I have found two ways to do this:

  1. 555 timer
  2. Arduino PWM

I have the following schematic for the 555 timer:

enter image description here

My concerns are related to which of these two will generate the best waveform. I am also concerned that having to switch the Arduino PWM on and off might impact on timing accuracy. Am I missing something or is there a much simpler way to drive the transducer?

Best Answer

If you have an available timer channel, and are running at a fairly fast clock rate either off a crystal or with the calibrated internal oscillator, I'd argue you should at least give using that a solid try before resorting to external circuitry - which you are unlikely to get 1% accuracy out of anyway given that it has a capacitor in it.

You can likely time the return of an internally generated signal as accurately as an externally generated one - at worst, if you are willing to loop the signal back into a different pin and thus directly reach a hardware timer with no interrupt latency in the way.

In terms of other methods, I believe it is possible to drive the transducer using a resonant circuit, which could arguably be the most "simple", however getting an accurate frequency and clean start transition may prove challenging. And if there's an unused timer channel and pin available to drive it anyway, then the argument could be made that an external generator, no matter how "simple" is more complicated to fabricate.

Depending on the properties of your transducer you may still need a transistor or other drive amplifier at lest to get maximum output.