Quote Originally Posted by ewandeur View Post
Hi !

I'm using a PIC12F629 with internal oscilator (4Mhz) a LM386 as amplifier, and a piezo to emmit ultrasound wave (from 28Khz to 60Khz).
All I can achieve is an annoying sound but no ultrasound at all.

I'm actually using the suroutine below, obtained from Melanie in this forum:

MakeSound:
For CounterA=1 to 1000
High gpio.0
PauseUS 10
Low gpio.0
PauseUS 10
Next CounterA
Return

Can anyone help me?

Tks in advance.
From memory I think the bandwidth of the LM386 is inversely proportional to the gain. More gain = less bandwidth. Open loop gain of the LM386 is something like 200, this will place a huge tax on the useable bandwidth. Generally above 15KHz or so, at very low output it's out of our hearing range. All told, Hi-Fi is 20Hz to 20KHz. I believe that the LM386 can go as high as about 100KHz with full feedback. i.e. No gain at all. In this configuration it's deemed a 'buffer' only.

Best Regards,
Trent Jackson