Author Topic: Want to hear the bat flying in the front yard  (Read 22626 times)

0 Members and 1 Guest are viewing this topic.

Offline Terry Bites

  • Super Contributor
  • ***
  • Posts: 2496
  • Country: gb
  • Recovering Electrical Engineer
« Last Edit: June 30, 2024, 02:28:13 pm by Terry Bites »
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19796
  • Country: gb
  • 0999
Re: Want to hear the bat flying in the front yard
« Reply #51 on: July 06, 2024, 07:14:49 pm »
Most cheap ultrasonic transducers are tuned for a narrow resonant frequency, with 40kHz being the most common one. I've not tested one at other frequencies, but it'll be similar to one of those piezo discs. A small electrect microphone will be much better.

Using a frequency counter is a bad idea, because it rejects all the amplitude information. It will just lock on to one sound, making it incapable of detecting more than one bat. The only advantage is it scales down the entire spectrum.

I looked at the kit schematic again. Attached is just one channel, with the component values made clearer, as the picture in the PDF was low resolution and very fuzzy.
2303427-0

The first two op-amps amplify the signal by a factor of 121, with a lower cut-off of 16kHz. The third op-amp then inverts the signal. The analogue swithers are alternately switched on by the oscillator, selecting between the inverted and non-inverted signal, at the oscillator frequency. This is then low pass filtered by R5 and C11, with a cut-off of 7kHz.

I think I might use a similar circuit, but it can be greatly simplified. Rather than using an op-amp to invert the signal, just have one op-amp, which can be programmed to inverting or non-inverting, with an analogue switch. This doesn't cut down on the number of op-amps but it means the oscillator doesn't need an inverting output and only one analogue switch is required.

I simulated it and the results are decent. R4, R5 and C1 bias the signal to half the supply voltage. When S1 is on, the circuit is inverting and when off it's non-inverting.

I'll swap the final op-amp for an LM386 to drive a small speaker.

I might also use a common emitter amplifier for the first microphone amplifier stage, because it should have lower noise than the TL072.


EDIT:
I've simulated the microphone amplifier. The response probably counteracts the reduction in sensitivity vs increasing frequency of the electret microphone quite well.

I'm moving towards using a TL074, with two sections for the amplifier, one for the inverting/non-inverting amplifier part for the heterodyne circuit and one as Schmitt trigger oscillator.


EDIT:
For completeness, here's the BJT amplifier from the website linked below, which uses the obsolete NE612 as a demodulator.
http://bertrik.sikken.nl/bat/ne612het.htm

The microphone is noddled as a signal source with an impedance of 4k7.

It has a sharper peak, than the op-amp circui9t, but lower noise. I might use two stages, a BJT and op-amp for more gain.
« Last Edit: July 07, 2024, 06:33:29 pm by Zero999 »
 

Offline RoGeorgeTopic starter

  • Super Contributor
  • ***
  • Posts: 6578
  • Country: ro
Re: Want to hear the bat flying in the front yard
« Reply #52 on: July 24, 2024, 08:05:05 am »
This summer couldn't spot any bats, until last night around ~3-4AM.  By coincidence, last weekend I did a crude ultrasound probe for detecting singing coils or other ultrasound sources.  The breadboard was still on the workbench and wired, but from indoors it didn't catch any bat ultrasounds.



The schematic was made to keep all as minimalistic as possible.  No amplifier and no mixer.  The MEMS mike (which has an internal preamp) is DC coupled to an ATtiny13.  The MCU is acting as an analog comparator and frequency divider.  The speaker is a piezo disc connected directly to the MCU, so no audio amplifier either.  No volume, sensitivity or other controls.  Only 6 components and a few lines of code in a .S file (this draft code happens to be written in assembly, using Eclipse, AVR-GCC and debugWire, with a generic CH340G USB to serial as a debugger/programmer):

Code: [Select]
#define __SFR_OFFSET 0x00
#include <avr/io.h>

.global main
main:
cli // disable interrupts globally

ldi r18, (1 << PB4) + (1 << PB3) + (1 << PB2)
out DDRB, r18 // PB4, PB3, PB2 as DO

sbr r18, (1 << CLKPCE) // set the CLKPCE bit before writing the value
out CLKPR, r18
ldi r18, 0
out CLKPR, r18 // write CLKPS3..0 all 0 for CLK prescaller div x1

//  disable the WDT

// enable Analog Comparator (AC), interrupts on raising edge
sbr r18, (1 << ACIE) + (1 << ACIS1) + (1 << ACIS0)

// enable Analog Comparator (AC), only raising edge, w/o interrupts
// sbr r18, (0 << ACIE) | (1 << ACIS1) | (1 << ACIS0)
out ACSR, r18

ldi r18, (1 << SE)
out MCUCR, r18 // enable sleep, sleep mode Idle

#define MAXCOUNT 10
#define HALF MAXCOUNT/2

// use r18 as a variable for counting the AC pulses/interrupts
#define COUNTER r18

// use r19 as a constant that turns LED/speaker on
#define SPK_ON r19
ldi SPK_ON, (1 << PB4) + (1 << PB3) + (0 << PB2)

// use r20 as a constant that turns LED/speaker off
#define SPK_OFF r20
ldi SPK_OFF, (0 << PB4) + (0 << PB3) + (1 << PB2)

// enable interrupts globally
sei
rjmp reset_counter

wait_AC_event:
sleep // sleep until an AC interrupt will wake the CPU

// sbi ACSR, ACI // clear the interrupt bit (because AC int are disabled)
// sbi ACSR, ACO // clear the interrupt bit (because AC int are disabled)

inc COUNTER // count the raising edges detected by the AC

// set LED/speaker bit(s) PB2, PB3, PB4 accordingly

//if COUNTER >= HALF, jmp to check_COUNTER_ovf
cpi COUNTER, HALF
brpl check_COUNTER_ovf
//else
rjmp wait_AC_event

check_COUNTER_ovf:
out PORTB, SPK_OFF
//if counter < MAXCOUNT, jmp to wait_AC_event
cpi COUNTER, MAXCOUNT
brmi wait_AC_event
//else
reset_counter:
ldi COUNTER, 0 // else reset the counting
out PORTB, SPK_ON

rjmp wait_AC_event // loop forever



//dealing with interrupts
.global ANA_COMP_vect
ANA_COMP_vect:
sbi ACSR, ACI // clear the interrupt bit (because AC int are disabled)
// sbi ACSR, ACO // clear the interrupt bit (because AC int are disabled)

reti

.global WDT_vect
WDT_vect:
// WDT shouldn't occur, but if it does, loop here forever
cli
forever_trapped_1:
rjmp forever_trapped_1
reti

// according to [url]https://www.nongnu.org/avr-libc/user-manual/assembler.html,[/url]
// these names should have work as a catch-it-all, but they didn't
//
//.global BADISR_vect
//BADISR_vect:
//.global __vector_default
//__vector_default:
//
// used this workaround instead:
.global INT0_vect
.global PCINT0_vect
.global TIM0_OVF_vect
.global EE_RDY_vect
.global ANA_COMP_vect
.global TIM0_COMPA_vect
.global TIM0_COMPB_vect
.global WDT_vect
.global ADC_vect

INT0_vect:
PCINT0_vect:
TIM0_OVF_vect:
EE_RDY_vect:
//ANA_COMP_vect:
TIM0_COMPA_vect:
TIM0_COMPB_vect:
//WDT_vect:
ADC_vect:

// other interrupts shouldn't occur, but if they do, loop here forever
cli
forever_trapped_2:
rjmp forever_trapped_2

.end

Will have to add a battery, and/or move the circuit on a permanent breadboard to make it portable.  Maybe the bat will visit again.  :)
« Last Edit: July 24, 2024, 08:58:15 am by RoGeorge »
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19796
  • Country: gb
  • 0999
Re: Want to hear the bat flying in the front yard
« Reply #53 on: July 26, 2024, 08:11:50 pm »
I would be very surprised if that circuit worked.

Not only is there no pre-amplifier, other than what's built-in to the MEMS mic, but it also lacks a high-pass filter to remove audible sound.

Try this.


By the way, mic is the correct abbreviation for microphone, not mike.
 

Offline RoGeorgeTopic starter

  • Super Contributor
  • ***
  • Posts: 6578
  • Country: ro
Re: Want to hear the bat flying in the front yard
« Reply #54 on: July 27, 2024, 05:58:49 am »
Thanks for the schematic.  Main problem was that the next night was stormy and it rained violently, and the bat didn't visit.  :)

Then the weekend came.  During weekend, there is a lot of noise from a pub across the street, and from more cars.  I've noticed from the previous recordings that the bat is "barking" louder when it's noisy outside (for example when a car is passing).  So I guess when the night is noisy, the bat is using other quieter hunting areas.  That would explain why the bat appearance has shifted to the late AM hours, because the pub sometimes has loud music until midnight, sometimes even later.  I suspect bats don't like noisy places.



About the detector, that one was for made for hearing singing coils, or to detect other (indoors) ultrasound sources.  Should be good enough for the bat, too.  The recorded level a couple of summers ago (from a bat, using the same mic) was made using 20mV/div.  The signal was about 20-50mVpp:


I've measured the sensitivity of the ATtiny13 comparator with a signal generator.  It flips reliably starting from about 5-6mVpp.  The expected 20-50mVpp from the bat should be plenty.

About the high pass filter, there is one.  The 10k/47nF low pass RC at the negative input makes the comparator more sensitive to high frequencies.  When the signal is swinging slowly, the RC filter on the negative input has enough time to follow the signal about as well as the positive input of the comparator, so not much flipping.  At high frequencies, the RC cell works as a voltage averager, and keeps the negative input of the comparator at a constant voltage, while the positive input is swinging fast, making the comparator flip at each period.  Overall, the circuit acts as a zero-crossing detector, but for high frequencies only.

In theory, the capacitor should have been much smaller, f=1/(2*pi*R*C) will indicate about 1nF for 10k\$\Omega\$ and 16kHz, but in practice that was making the comparator too insensitive even for high pitch frequencies, so I've used a 47n that happened to be at hand.  That was picking some other audible sounds, indeed, but it was good enough for indoors testing.  For the final version I'll probably use 2 or 3 RC cells calculated for 10kHz or so (for the indoors ultrasounds probe, not for bats).  A single RC cell is not selective enough to separate audio from ultrasounds.



Another problem with the indoors probe was the ceramic disc.  The sound edges are too sharp, and that interfere with the ultrasounds.  A miniature laptop-speaker (to avoid wearing headphones) with some low pass filter should work much better than a piezo disc.  Attiny can supply about 50mA through a DO.  In practice, I've measured the resistance of a DO pin to be about 50-80ohms, depending on the Vcc.  The output resistance measures about the same for either high or low level of the DO.  Should be easy to soften the voltage edges of the DOs by adding a capacitor.
« Last Edit: July 27, 2024, 06:15:03 am by RoGeorge »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf