Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

LM386 Bat Detector Stability

Status
Not open for further replies.
View attachment 64429**broken link removed**

I have built this bat detector circuit, the ultrasonic detector and earphone are not shown in the diagram. I hope to pick up bat sounds between about 12KHz-200KHz with it.
* I'm not sure why it uses LM386s rather than op-amps.
* I have omitted the components between pin 1 and 8 on IC-1 and IC-2 as they are only there to increase amplification and there is plenty already.
* I omitted the capacitor resistor combination on pin 5 of IC-1 and IC-2 as I did not know what they were supposed to do apart from a comment about “stability” on the website and no component values were given.

It effectively picks up a Common Pipistrelle bat at 20-30KHz, but it without any input it "clicks" slowly then picks up speed over a minute or two to the point where it is unusable. Sample bat-clicks.wav in the zip file below starts with the unwanted noise then there is a burst of bat clicks, it wasn't on for long enough for the unwanted clicks to get out of control.

I tried a 22uF capacitor on pin 7 on IC-1 and a 1uF capacitor on IC-2, that reduced it when I tested it, but when I soldered it, it was worse.

I assumed that it was some sort of low-frequency instability, so I added a high pass filter from https://www.st-andrews.ac.uk/~jcgl/Scots_Guide/experiment/highpass/hpf.html with values 10nF and 1K8 on IC-1 between pin 5 and the capacitor. This stops the clicking but I get a “frying eggs” sound instead. Sample bat-eggs.wav in the zip file below starts with the unwanted noise then there is the sound of rattling keys - it was daytime so the bats were asleep so I couldn't ask them for a demonstration!

I have two more ideas:
* Use the inverting input on IC-1 and leave IC-2 on the non-inverting input so there is less possibility of the output feeding into the input. It probably depends on what phase shift there is through each IC though.
* Find out what the capacitor resistor combination on pin 5 of IC-1 and IC-2 do and calculate appropriate values. At a guess it might filter out high frequencies – would that sort out the “frying eggs”?

Any suggestions or comments would be helpful.

If you try the samples please turn the volume down! They are loud and unpleasant.
 
Last edited:
Take a look at the data sheet for some values for the output compensation. Also concider the bypass cap shown there. If it is powered from a 9 volt battery the filter caps on the supply pin should be large. Keep wires from the output away from the input.
 
I then tried a band-pass filter but that cut the amplification so much it didn't pick any bats up.

I've now got a low pass filter with f0 = 219KHz using 220 Ohm/3.3nF. There is no unwanted oscillation, neither the clicks or the frying eggs so perhaps they were both caused by high frequency oscillation. So far as sensitivity is concerned, I have tested it by rattling a bunch of keys and it picks that up, but that is quite loud compared with a bat. The bat has gone home again now, so I'll have to wait until tomorrow to see whether it is sensitive enough.
View attachment 64440
The calculation was from that useful website, but although it gives the relationship of the values of the components, it doesn't give absolute values as that is not relevant to the function of the filter. I have used 220 Ohm/3.3nF, but I could have doubled one and halved the other (or vice versa). Would there be any advantage in this? Would it for example have lower resistance overall for the desired frequencies or match the input impedance of one LM386s or the output impedance of the other better? (Sounds good and technical but I don't really know what I'm talking about here.)
 
Last edited:
ronv: I've had a look at the data sheet - thanks.

Take a look at the data sheet for some values for the output compensation.
There is no mention of output compensation in the text of the data sheet, although I can see a series 50nF/10R on the output in some diagrams which may be intended for stability. I've no idea how to calculate it, but just comparing the values with the ones in my low-pass filter, I think it would lose the upper frequencies that I want.

Also concider the bypass cap shown there.
I've tried this - see first message.

If it is powered from a 9 volt battery the filter caps on the supply pin should be large.
They are - see first message.

Keep wires from the output away from the input.
I've done so.

When the circuit is working properly no filter should be needed.
I'm not sure I understand this...

Maybe you could post your component values.
Sorry - it would have been more helpful to have attached this in my first message.
View attachment 64457
As you can see it doesn't give any values for the "stability components", presumably his prototype didn't need any so he has just copied these components from the datasheet without giving any values. If it is a high-cut circuit it might do as well or better than my low-pass filter. I don't know which would be better or how to calculate values for this.
 
Last edited:
Try building a better design - LM386's aren't really suitable for such a use, and I wouldn't expect it to work.

There seems to be a number of designs on the net, obviously from people who don't know anything about electronics, attempting to use LM386's in place of op-amps (presumably because it's often drawn with a similar symbol?).
 
Nigel
attempting to use LM386's in place of op-amps.....obviously from people who don't know anything about electronics
Haha - I thought it was just me who suspected that!

I'm no expert but as I wrote in my first message
I'm not sure why it uses LM386s rather than op-amps.
Surely a 741 would have enough gain to achieve the 20x20 which this circuit does.

I think I'm going to stick with what I've got though, as it's nearly there and so less work than building a new one, and I'd certainly get problems if I tried to design a new one with my limited knowledge.
 
Last edited:
I'm no expert but as I wrote in my first message Surely a 741 would have enough gain to achieve the 20x20 which this circuit does. I think a circuit with a 741 with a low-pass filter, negative feedback, two zener diodes to clamp the output to 0-5 volts, then the 4024 binary counter IC then a 386 for output might work.

Don't use 741's, they are low spec antiques (and don't work at high frequencies), use something like TL071, TL081 etc. - these beat 741's on every count.
 
they are low spec antiques
so quite appropriate for a low spec antique like me.....I haven't made any circuits for years, so it's just a name I remember!

I tried replacing the 386s with two 741s and then with two TL071s but it didn't work atall, so obviously I need to change the circuit to suit the opamps.

I've just drawn a new circuit, it's the first time I've used the software so it's a bit(!) rough.
View attachment 64464

There are several points I'm not sure about - which makes just about all of it.
* 741/TL071 - I've assumed that since I just want loads of amplification and a square wave output that I don't need any input or feedback resistors, but that didn't work in the old circuit so I will have to search the Web for a better opamp circuit.
* I've put a filter on the output of it to stop high frequency oscillations (see above).
* Zener diodes - not sure whether these are necessary to stop the input to the 4024 switching between 0-9.
* I think the 386 is probably unnecessary for an earphone or the line input to my digital recorder.

This is a second attempt without the LM386 and showing the power supply.
View attachment 64467
 
Last edited:
Nigel - thanks, I haven't found a circuit for a heterodyne detector before, they produce a nicer sound rather than the clicks of the frequency division ones.

The latter do have the advantage of not needing tuning in. I think the best ones allow you to search with a frequency division one then switch to heterodyne. There are also time contraction ones but I think they are only good for research.

Since I'm nearly there, I'm going to persevere with the current circuit a little longer, the bat didn't appear yesterday evening so I couldn't test my latest filter circuit. If I don't get anywhere with it maybe I'll test some op-amp circuits with some resistors for negative feedback.
 
Last edited:
An opamp usually needs negative feedback but also its (+) input must be biased properly at about half the supply voltage so its output can swing up and down.

The LM386 power amplifier already has negative feedback built-in and inputs that are biased and work when the input DC voltage is 0V.
 
Last edited:
Audioguru

LM386 power amplifier already has negative feedback built-in and inputs that are biased.....
I am a bit puzzled why the designer of the original circuit used 386s, but that might have been why - it saved him having to work out biasing and feedback, which is understandable if he was more interested in wildlife than electronics.

I've revised the op-amp bit of my circuit a bit.
View attachment 64552
its (+) input must be biased.....
I'm not sure about biasing the op-amp though, is it necessary if it's just a switched DC output that I want for the 4024 logic chip?

I have put some feedback on the op-amp, I think the resistors will give 20x gain and I will have to find something on the Web to calculate the capacitor in the feedback loop for restricting the high frequency response to less than 200KHz.

The ultrasonic transducer has a capacitance of 2.4nF and it is suggested to put a 6.8 mH inductor in parallel to detune it. The inputs to the op-amps and the 4024 are I believe effectively infinite. But so far as matching impedance of inputs and outputs is concerned that's far too complicated for me so I don't think I can worry too much.
 
Last edited:
I have built this bat detector circuit, the ultrasonic detector and earphone are not shown in the diagram. I hope to pick up bat sounds between about 12KHz-200KHz with it.

What transducer are you using?

I've built frequency division bat detectors using op amps configured as 40KHz bandpass filters, when used with the cheap piezo ultrasonic receivers. Although those devices really do peak only at 40 KHz, they will pick up Pips, Noctules and Daubentons OK.
Not so good with Seratines or Horseshoes though!

For a tunable heterodyne version, I used a Knowles Electret capsule: https://www.electro-tech-online.com/custompdfs/2012/05/EK-23132-000.pdf

which was pretty good --although it did need a lot more amplifaction in the higher frequency ranges.
I believe Knowles now do some MEMS ultrasonic devices, which are likely to be much more suitable. Haven't tried one though..

You'll find you need a lot of gain, to get any decent 'range'. I also found using a signal generator, connected to an audio amplifier, just driving a cheap Motorola type HF piezo horn very useful for testing.....

But a lot will depend on what transducer you are using?....
 
rogs
What transducer are you using?
Its an HY12. I'll be happy if I can just pick up the ones in the lower range to start with, I could always build a more advanced one later. I think the one in my garden is possibly a Common Pipistrelle, from the sound, size and activity and that would be around 40-50KHz. As you say, a few British species are over 100KHz, but most are below 80. I'm told there are a load of bats in one of my local parks, but I don't know which species although I am aware that there is one that hunts over water and there is a very large pond there.
 
Last edited:
So a 40KHz transducer then. These really do respond only to 40 KHz, and the sensitivity drops off very quickly either side of that. Not much good for a heterodyne detector, I'm afraid...

I've attached a sketch of a version I built about 20 years ago. Might give you a useful suggestion or two? Very simple - and low current! (useful for battery life!)

You might like to use a better quad op amp - but the TLO64 was the only suitable low current device at that time. To save power, the output from the 4017 counter drove an AC piezo directly. No audio amp..
As you can't tune a freq div type, and the transducer is only detecting the 40 KHz part of the bat ultrasound, it doesn't really matter what the output actually sounds like!

Sorry about the sketch. I did try and do one of these 'proper' schematics for another post, but it took ages, and only one or two bothered to look at it anyway.
So I dropped the time consuming 'pretty' drawing idea, and hope you can read what I've posted.
If it's of any use, and you can't read something, I can post further details?....

You really need to do a heterodyne, to be able to distinguish between the species, but you will hear the pipestrelles OK. And the Daubentons. (which are the one that hunt over water). They're much quieter though. They sound like a fire 'crackling' on a freq div detector!

BTW, the gain control on the circuit is to allow you to set the gain to avoid opamp 'noise' from setting the device off at high gain. You might get better signal to noise with a more modern lower noise opamp.

For a heterodyne, you will need a quieter preamp!

Edit: one further suggestion for testing. To be of any real use, your detector will need to work to detect bats over 20 or 30 metres away. To get a simple idea of whether you are in the 'ball park', sensitivity wise, you can gently rub your thumb and forefinger together, directly in front of the transducer. Even though you won't hear any significant audible sound, that action should generate enough ultrasound to activate the detector.

The 'old chestnut' of detecting ultrasound from shaking a bunch of keys will confirm your detector is working, but if it can't 'hear' your fingers rubbing together, you'll probably be disappointed in the range of the device.

And these little critters can move fast, in all directions, as you know.
How they ignore the ultrasound generated from other nearby bats, and just isolate their own 'echoes' amazes me. Incredible creatures......
 
Last edited:
rogs
I've attached a sketch of a version I built about 20 years ago. Might give you a useful suggestion or two?
That's great! Very useful, just the sort of help I wanted. If I was starting from scratch I'd use that as it stands. Since I have a completed circuit I'll pick out the most useful bits and apply them to my circuit, probably a bit at a time. The first two opamps are doing exactly what I was trying to do in my circuit, so I will start by copying them and leaving out the next two because there is no room on the current board. I misunderstood the diagrams I had seen about earthing the +input, I had forgotten that it is assumed that you use a balanced power supply, so I will add the two 100K resistors to create the ground rail. I will increase the value of the input resistor (and feedback resistors) to increase the input resistance.
For the moment I'll leave the digital IC as a 4024, but looking for information for your HEF4017 I have found
https://www.alldatasheet.com/view.jsp?Searchword=HEF4017 which seems to suggest that it is a flip-flop which doesn't seem right to me, it also refers to
https://www.alldatasheet.com/datasheet-pdf/pdf/15604/PHILIPS/74HC4017.html which is a decade counter which makes more sense, but neither mention a Schmitt trigger. I assume the Schmitt trigger would square off the variable input voltage to 0V/5V.


Very simple - and low current! (useful for battery life!)
Simple is good and batteries always run out when it's most important that they don't!

You might like to use a better quad op amp - but the TLO64 was the only suitable low current device at that time.
I think I've got a TL074 in my bits box.

To save power, the output from the 4017 counter drove an AC piezo directly. No audio amp..
As you can't tune a freq div type, and the transducer is only detecting the 40 KHz part of the bat ultrasound, it doesn't really matter what the output actually sounds like!
I am using an earpiece and a voice recorder, but the earpiece is annoying so I may add the sounder later.

Sorry about the sketch. I did try and do one of these 'proper' schematics for another post, but it took ages, and only one or two bothered to look at it anyway.
So I dropped the time consuming 'pretty' drawing idea, and hope you can read what I've posted.
If it's of any use, and you can't read something, I can post further details?....
Hand drawing is so much quicker I'd use it if I had a scanner.

You really need to do a heterodyne, to be able to distinguish between the species, but you will hear the pipestrelles OK. And the Daubentons. (which are the one that hunt over water). They're much quieter though. They sound like a fire 'crackling' on a freq div detector!
For a heterodyne, you will need a quieter preamp!
I may build one of these later if I get really enthusiastic about bats, Nigel has posted a circuit for one.

BTW, the gain control on the circuit is to allow you to set the gain to avoid opamp 'noise' from setting the device off at high gain. You might get better signal to noise with a more modern lower noise opamp.
Something I had been considering

Edit: one further suggestion for testing. To be of any real use, your detector will need to work to detect bats over 20 or 30 metres away. To get a simple idea of whether you are in the 'ball park', sensitivity wise, you can gently rub your thumb and forefinger together, directly in front of the transducer. Even though you won't hear any significant audible sound, that action should generate enough ultrasound to activate the detector.

The 'old chestnut' of detecting ultrasound from shaking a bunch of keys will confirm your detector is working, but if it can't 'hear' your fingers rubbing together, you'll probably be disappointed in the range of the device.
This is an extremely useful tip. As you say, the keys only check whether it works and a hint I saw somewhere else, of using a couple of 2p pieces, is somewhat more sensitive but only in the same sort of order of magnitude I think. I have been very limited in testing the circuit because the bat seems to have been on its holidays for a few days. I tried the digital(!) test on the current (386) circuit and the circuit is not sensitive enough, so my filter has been successful in stabilising the circuit but has reduced the sensitivity too much. It might be for what I want though because I'm mostly interested in short range. I can calibrate the digital test next time the bat appears and I know if the current circuit picks him up.

And these little critters can move fast, in all directions, as you know.
How they ignore the ultrasound generated from other nearby bats, and just isolate their own 'echoes' amazes me. Incredible creatures......
Maybe they have individual accents...
 
Last edited:
This is the HEF4017 I used : https://www.electro-tech-online.com/custompdfs/2012/05/HEF4017B.pdf

Not all versions have a Schmitt trigger on the clock input. I found it made a 'cleaner' divide by 10 division of the 40KHz signal - especially as the ambient state is at the half rail voltage od the opamp output. Bit unconventional, but it's simple and it works.
Again, driving the output of the 4017 directly into the output transducer required the use of a high impedance AC piezo buzzer, rather than a low impedance speaker or earpiece. The 4017 probably doesn't have enough drive capacity to make a useful noise from a low impedance device.

Don't use the 74HC4017 version unless you are using a 5V DC supply. The one I linked to can cope with a 3-18 V supply.

The TL074 will be a better choice, spec wise, but will draw a lot more current (relatively speaking)

I do have a (relatively!) simple circuit for a heterodyne version as well if you'd like me to dig that out. You will need a better transducer though.
Farnell do one: https://uk.farnell.com/knowles-acoustics/spm0204ud5/sensor-ultrasonacoustmems-4-204/dp/1367846RL but it's not cheap!!

Not actually tried one out (yet!), but it's a much better spec than the electret capsules I was using.

If you do get your freq div one working well, you'll want to try a heterodyne!

I would love to go the whole hog, and do a 'real time' one, without paying the 'research' type prices the commercial units cost. Some of the audio recorders like this one: **broken link removed** look promising --especially if use with the transducer I suggested above.

You'd still need a freq div or heterodyne to find them though!!

But we are talking real money now.........

Your last point.. must be something like that, but think of the difference in levels. Listening for your own attenuated 'echo', while ignoring direct ultrasonic 'blasts' from other nearby bats which would be many times 'louder' than you own echoes.......quite remarkable....
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top