Bat detector

Hi Edwin,

thanks a lot for all your help and the video, that explains a lot to me and answers a lot of questions!

Some things react differently in my setup:

* when I switch to the spectrum, it shows one static spectrum all the time, not a dynamic spectrum
* when I switch to waterfall again, it often takes some minutes to show a waterfall again, even if I increase gain
* when I start to record, it shows "RECORDING", but I cannot stop the recording by pressing the left encoder push button. There is no reaction any more, although the heterodyne sound still works. The recordings are present on the SD card, but are of a size of zero bytes

Maybe I am using a wrong sketch? I took the one from message #159
https://forum.pjrc.com/threads/38988-Bat-detector?p=191560&viewfull=1#post191560

All the best,

Frank DD4WH
 
Compiled the code again and uploaded it to the Teensy.

Now the spectrum works and the switching between display modes works as expected! Nice.

Recording does not work: Tried more than 20 times with four different brands and sizes of SD cards [also formatted the SD card with SDFormatter]:

* go to Record with left encoder
* then I press the right encoder button, the text "RECORDING" appears [oddly, it is printed at different positions every time I try to record !?]
* after that, the detector does not react any more, not when I press any button, neither when I turn an encoder
* I have to cut power to start the detector again

So, I am stuck now. Probably I am using a different sketch. Did you compile with 180MHz?

Which version of SDFAT lib are you using??? Could that be a cause?

All the best,

Frank DD4WH
 
seems I had an "old" version of the uSDFS lib (February 2018), now I updated the lib (March 2018) and recording works!

But how can I adjust the sample rate for my playback? It seems it is always 8ksps, so recordings with 352ksps take 44 times as long to play back, which is a bit boring to listen too ;-).
 
seems I had an "old" version of the uSDFS lib (February 2018), now I updated the lib (March 2018) and recording works!

But how can I adjust the sample rate for my playback? It seems it is always 8ksps, so recordings with 352ksps take 44 times as long to play back, which is a bit boring to listen too ;-).

Turning the right encoder button at playback will set playback rate between 8 and 44 Khz, you can see the value in the right top corner.
 
hello guys I use a temperature sensor and a rtc module in the bat detector, this infrared temperature sensor mlx90614 uses i2c communication just like the rtc module, since the tenssy 3.6 has more pins sda and scl as I can assign these pins to these sensors, which are not the 18 and the 19 that are the pins that the audio shield uses, or they recommend me to use a multiplexer?
 
On one pair of I2C pins (i.e. pins 18/19), you can run up to 120 I2C devices under the condition that these have all different I2C addresses and they are all communicating at the same speed (default 400kB/s). There is no need for a multiplexer or whatever. Just thoughtful and purposeful circuit design and code development.
 
On one pair of I2C pins (i.e. pins 18/19), you can run up to 120 I2C devices under the condition that these have all different I2C addresses and they are all communicating at the same speed (default 400kB/s). There is no need for a multiplexer or whatever. Just thoughtful and purposeful circuit design and code development.

then I would have to connect the pins of the audio shield, the rtc module and the mlx90614 sensor in the pins 18/19 and specify in the code the addres of each one to read the data of each, you have an example of how I can perform What do you mention?
 
As an intermittent teensy user, I just stumbled upon this thread. It is a fascinating project. As someone that is somewhat familiar with signal processing I thought I would add a couple of comments. If they are "out to lunch" please excuse me.

1) If you are interested in obtaining a more accurate estimate of the actual frequency, a method has been developed based on the 3 closest frequency lines to the peak. I believe that it is an empirical formulation, and that it only works if the hanning window is used. More information is available in the book "Vibration Based Condition Monitoring" by Robert Randall on pages 89 - 91. The trick to using it is to actually find these three points. I have done it in matlab but currently don't have a good feel for the cpu resources required. If you are interested I will give more information about the technique.

2) If we think of the bat sound as a carrier frequency with amplitude and frequency modulation, then it should be interesting to perform a demodulation and listen to that. Page 96 - 103 of the same book gives a digital demodulation technique. If you can get the PhD thesis of Coates, he elaborates on this technique. I have used his technique in matlab again. There are also DSP tuned radios. I suppose these algorithms ought to work as well. Perhaps an analog demodulation technique would work and then digitized the results of this? This would be interesting but much too computationally intense for a teensy in real time.

Jake
 
Hi Jake,

I also kind of accidentally stumbled across this project.
It is a fun project, the capabilities are what you might expect from a professional device.

There is not a single frequency to find or determine. I am by no means a bat expert but the calls a bat makes are not just a single frequency. The navigation calls I was able to record change over time. This time is just a few milliseconds. Determining the species usually by taking the start and stop frequencies, the duration of the call and the time in between the calls, and compare these to known calls. Determining just one exact frequency might not be interesting.

In this call we can see both Frequency an amplitude changing. The calls I recorded started quite high and these drop a little in frequency over a time period of 4ms or so the last ms the sound decreases in amplitude.
I don't think any analog radio detector-like decoding could help us listening to these calls.

Just for fun I attached the spectrogram of a small part of a recording and the exact same piece as waveform.
The last image is a longer section of the same recording showing two different calls on higher and lower frequencies.


bat1spectrogram.jpg

bat1waveform.jpg

dualbat.jpg
 
@edwin: thanks you very very much for the brilliant description of the bat detector hardware and setup! Very nice for everyone who wants to build it!

@Jake: thanks a lot for your DSP suggestions!

I see Edwin has already commented on the non-stationary nature of the frequency of bat calls, they are in nearly all cases heavily FM-modulated containing sweeps of up to 120kHz bandwidth in a few milliseconds.

re: 1.): for the reason above, a carrier estimation would not be optimum and would have to be performed in very small time windows. You probably refer to one of the numerous methods of three point carrier frequency estimation in the literature like this one?

citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.555.2873&rep=rep1&type=pdf

This and other variants are also able to perform with different window types, including von Hann, Hamming, unwindowed etc. The CPU load is very low, I use this method in realtime with a sample rate of 100kHz in a software defined radio on the Teensy 3.6.

But if you refer to another method, I would be very interested in a link or a paper, thanks in advance!

re 2.): yes, thats a very good idea! In fact, the implemented heterodyne mode is exactly what an AM direct conversion radio does in demodulating AM radio transmissions: a local oscillator produces a sine wave which is mixed (digitally multiplied) with the mic signal. The multiplication produces two signals, one with the substracted frequencies (which we want to hear!), the other one with the added frequencies (which are eliminated by a lowpass filter). The output is the demodulated audio, which is the down-transformed audio of the bat in realtime. This has already been implemented and is not at all too computationally intense for the Teensy 3.6. ;-).

There was also the idea of a real time pitch transformation of the bats´calls by performing overlapping FFTs - shifting the frequency in the frequency domain to the audible spectrum - and doing inverse FFT afterwards: but that is surely something that is too much for the Teensy 3.6., mainly because we need at least a sample rate of 300kHz to cover all the bats´ ultrasound spectrum (going from 14kHz to about 140kHz). --> if you want to elaborate and try an implementation of that idea, it would be highly appreciated!

All the best,

Frank DD4WH
 
Last edited:
I just discovered I do not need a pet bat to do some testing.


I already used a simple signal generator and a ribbon tweeter to get some test signals for nice reference but that was no fun to look at and listen to.

Recently I bought a SA9227+PCM5102A DAC board and hooked this up to the same type of ribbon speaker.
Although it was advertised to work with Win7 and Win8, windows 10 also worked right away.

At first I could not get any ultrasound from the device but after I used the BRAVO-HD audio CPL tool by Saviaudio I was able to play the bat calls.

Using this board and a cheap ribbon tweeter seems enough to make some nice test sounds. All together this cost around 45 USD or 40 Euro's and you end up having a spare speaker since the tweeters come in pairs. (it worked well enough for me without an audio amplifier, although it might be wise to use one sing this device only makes line output level).


petbat.jpg

Now we can test with some test signals generated on the computer (audacity can also do that for you) and also play some bat calls from your own recordings or downloaded from the internet.
A simple click on the files here are enough to play them although I am not sure if every file has the correct sample rate.

Kind regards,

Edwin
 
what are you talking about?

write at least 2 or 3 sentences to explain what your problem is
 
I'm sorry, what I want to do is be able to get a better resolution per point for the fft analysis since I'm using the detector to detect mechanical faults that are in inaudible ranges but for the analysis I require a resolution of 10 hz and the minimum is 43hz I do not know if there is any way to modify it.
 
If there is anything I would like to change, it is the part that i can see on the display.

Right now, I can see the bat call's as a very small blip on a wide display like this.
batspect.jpg

I would like to know if it is possible to show only part of the audio spectrum (maybe that could also be interesting for CandelaRD, if he ony wants to view subsonic audio)
What I would like to see is not the full with of te audio spectrum that is available on a specific sample rate, but I like to be able to only see like 30Khz-80Khz.

It would make the bat calls look like this on the display.
batspecm.jpg

I hope you get the Idea what I am looking for.
It would be nice if this was user selectable.

Kind regards,

Edwin
 
Hi,

I stumbled upon this project and find it interesting. I have wanted to get a cheap bat detector for a long time, but TE has previously been very expensive to my knowledge. What is the aproximate cost for the components to build this detector? What kind of microphone is recommended to use to be able to detect most bats in northern Europe?

V3X
 
Look at post #183, the is a full parts list in the link,

The microphone used is Knowles SPU0410LR5H-QB.

The total price in parts should be just under 100 euro.
My own calculations was 85 euro's but I always buy parts in small numbers and no single parts. Small bags of encoders, switches, buttons and knobs usually come form eBay as bags of at least 10pcs.


The most expensive parts are the Teensy, about 32, and audioboard about 16 euro's.
The display and powerbank should both be near 7 euro's or something.

The microphone is quite affordable.
I payed 5 euro's for the mic and 8 for shipping :-(

I tried to get a bunch of these tiny breakout boards made and will try to solder this tiny thing onto that board, just for fun.
If it works, I could include it with the mainboard I guess.


Edwin
 
@CandelaRDZ:

So I suspect you are using the spectrum view of the detector, NOT the spectrogram view, is that right?

You can calculate your frequency resolution by dividing the sample rate by the number of points used in the FFT --> eg. 381000 / 256, so your frequency resolution is about 1.5kHz for that sample rate [you can view frequencies up to half of the sample rate, eg. 381/2 = 190kHz, well the mic allows up to 130kHz, I would guess].

If you want to have a higher resolution than 1.5kHz, you would have two possibilities:

1. use a higher number of FFT points
2. use techniques like ZoomFFT to increase the resolution

Both are not easy to achieve in real time, the first one needs a lot of processing time, the second a lot of programming time ;-).

One question for you to ask yourself:

Why do you need such an extraordinarily high accuracy in ultrasound frequencies? You say 10Hz for frequencies of > 100kHz, that is an accuracy of 0.01%, why do you need this and are you really sure you would trust the Teensy clocks and their temperature dependencies having this kind of accuracy?

Have fun with the Teensy,

Frank DD4WH
 
Hi Frank,

Interesting, anything in particular you like compared to the code we have developed before. I am in the process to start rebuilding the software you started again based on new ideas on several topics. Would be nice if we could "join" the forces, maybe inform Jean-Do ?

greetings
Cor
 
Hi Cor,

yes, very nice!

Maybe you would like to contact him on the thread mentioned above?

All the best,

Frank
 
Hello everyone,

Sorry to have started in the wrong section!
I just finished a new participatory workshop with the assembly in 1 day of 10 Passive Recorder by 8 participants.
For information, I am currently working on an Active Recorder with the same features as Passive Recorder plus two functions:
- Heterodyne function (manual with 10-120 kHz potentiometer or Auto with +/- 10kHz potentiometer around maximum energy.
- Reading recorded files in time expansion x10 (last file automatically selected).
The model is functional since this week. You can consult a small demonstration film on this link.
I'm just starting the routing of the PCB. For the box, I will contact "La Tolerie Plastique", a French company that has a custom box creation service for affordable prices (~ 25 to 30 € the box for 100 minimum).

Of course, I am willing to participate in your projects, knowing that I also have several projects in mind:
- Create a Passive Stereo Recorder to perform mini tracking. The stereo seems asked in France to work on the corridor of passage over the road and highway.
- I am currently working on a specific Passive Recorder software to make it work in RhinoLogger (automatic recording of Rhinolophus activities in second positives per minute). I have already developed a specific detector of this type and has been operating permanently on a site for 2.5 years. You will find a presentation (in French!) on this link. This mode of operation will now be done on Passive Recorder with special software. It is functional and a test of one night 10 days ago gives good results. I still have to code the temperature storage.
- A recent discussion with Frank made me discover the technique of Zerocrossing (not very documented in France). It gives me ideas to realize a surveillance system to trigger automatically recordings on specific species ... The power reserve on Passive Recorder is sufficient to realize this detection.

Best regards,

Jean-Do.
 
Hi Jean-Do,

There is no wrong section, I know from my own experience that fora are often filled with topics and its easy to miss one ;) Thanks for sharing your project. As you will see this has become a rather long-lasting topic starting with a message from Frank (DD4WH) in oktober 2016 which I see as the start of teensy-batdetector development.
Since then the software has been adapted several times, my latest source can be found at https://github.com/CorBer/teensy_batdetector. My aim with this is to build a bat-detector that helps me to distiguish as easy as posssible between bat-species by providing feedback both visual and audio. The current source has both heterodyne and auto-heterodyne (tunes to incoming peak frequencies) and a simple divider and something I have called auto_Time_expansion. Although the auto_Time_expansion is probably the least scientific approach I find that the most intriguing mode. When I set the detector to that mode the sound from the world around you becomes slowed down. This isnt a continous function but works by picking up a signal and directly playing it back at a slower speed. This only works properly with short soundbursts from bats/crickets/mice etc.

As stated in my request to join this topic is that I would like to share ideas on both software and hardware to provide people that want to build their own bat-detector with some guidance.

regards
Cor
 
Back
Top