Forum Rule: Always post complete source code & details to reproduce any issue!
Page 8 of 8 FirstFirst ... 6 7 8
Results 176 to 194 of 194

Thread: Bat detector

  1. #176
    Senior Member DD4WH's Avatar
    Join Date
    Oct 2015
    Location
    Central Europe
    Posts
    337
    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...l=1#post191560

    All the best,

    Frank DD4WH

  2. #177
    Senior Member DD4WH's Avatar
    Join Date
    Oct 2015
    Location
    Central Europe
    Posts
    337
    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

  3. #178
    Senior Member DD4WH's Avatar
    Join Date
    Oct 2015
    Location
    Central Europe
    Posts
    337
    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 ;-).

  4. #179
    Member
    Join Date
    Nov 2018
    Location
    Netherlands
    Posts
    28
    Quote Originally Posted by DD4WH View Post
    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.

  5. #180
    Junior Member
    Join Date
    Nov 2018
    Posts
    8
    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?

  6. #181
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,161
    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.

  7. #182
    Junior Member
    Join Date
    Nov 2018
    Posts
    8
    Quote Originally Posted by Theremingenieur View Post
    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?

  8. #183
    Member
    Join Date
    Nov 2018
    Location
    Netherlands
    Posts
    28
    For the people that want to build the bat detector (CorBer's version with my PCB) I wrote a document showing a way to build it.

    https://goo.gl/sAerua

    Best wishes for 2019!

    Edwin

  9. #184
    Member
    Join Date
    Jul 2015
    Location
    Ontario, Canada
    Posts
    67
    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

  10. #185
    Member
    Join Date
    Nov 2018
    Location
    Netherlands
    Posts
    28
    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.


    Click image for larger version. 

Name:	bat1spectrogram.jpg 
Views:	10 
Size:	104.4 KB 
ID:	15504

    Click image for larger version. 

Name:	bat1waveform.jpg 
Views:	11 
Size:	111.8 KB 
ID:	15505

    Click image for larger version. 

Name:	dualbat.jpg 
Views:	10 
Size:	137.3 KB 
ID:	15506

  11. #186
    Senior Member DD4WH's Avatar
    Join Date
    Oct 2015
    Location
    Central Europe
    Posts
    337
    @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 by DD4WH; 01-06-2019 at 04:42 PM.

  12. #187
    Member
    Join Date
    Nov 2018
    Location
    Netherlands
    Posts
    28
    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).


    Click image for larger version. 

Name:	petbat.jpg 
Views:	12 
Size:	138.0 KB 
ID:	15600

    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

  13. #188
    Junior Member
    Join Date
    Nov 2018
    Posts
    8
    how can I change the resolution of the frequency?

  14. #189
    Senior Member DD4WH's Avatar
    Join Date
    Oct 2015
    Location
    Central Europe
    Posts
    337
    what are you talking about?

    write at least 2 or 3 sentences to explain what your problem is

  15. #190
    Junior Member
    Join Date
    Nov 2018
    Posts
    8
    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.

  16. #191
    Member
    Join Date
    Nov 2018
    Location
    Netherlands
    Posts
    28
    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.
    Click image for larger version. 

Name:	batspect.jpg 
Views:	4 
Size:	55.1 KB 
ID:	15629

    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.
    Click image for larger version. 

Name:	batspecm.jpg 
Views:	5 
Size:	57.3 KB 
ID:	15630

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

    Kind regards,

    Edwin

  17. #192
    Junior Member
    Join Date
    Jan 2019
    Location
    Sweden
    Posts
    1
    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

  18. #193
    Member
    Join Date
    Nov 2018
    Location
    Netherlands
    Posts
    28
    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

  19. #194
    Senior Member DD4WH's Avatar
    Join Date
    Oct 2015
    Location
    Central Europe
    Posts
    337
    @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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •