Bat detector

I use this microphone:
Have fun with the Teensy,
Frank

Thanks for chiming in. For those in the UK, micbooster.com also sells the SPU0410 on a tiny board. Its not on their website but you can inquire.
I have been testing my current setup without my preamp also, this has advantages if you want to hear a lot more in the frequencies below 30Khz. The preamp I use especially provides more gain at higher frequencies.

Wow, what a fast reply! - Thank you :cool:

I am in the UK so the link is much appreciated.
I think I may have found it on their website.

https://micbooster.com/home/146-ultrasonic-mic-board.html?search_query=SPU0410&results=2
 
My contact was with Nick Roast and at that time the board was still pre-production (mine is very small and round). But its good to see its now really available, thanks for the info !!
 
Progress report:

I have further increased the size of the sampe_buffer, from 64Kb to 96Kb. At 281K samplerate the short burst of noise when writing to the SD comes new gets recorded every 150ms or so.
Next to this I have connected my preamp to the 3.3v from the Teensy instead of the (probably more noise prone) 5V coming directly from the USB. This does reduce the gain of the preamp clearly but also has had a good effect on the overall backgroundnoise. In the image below you can see the noisespectrum when recording (micgain is 50) in a noisefree (nearly) environment. I used audacity to plot this for a section of around 100ms of a recording (no SDwrite noise).

For the software side I am still clearing up and commenting more of the code to make it more accessible.

Screenshot from 2018-09-02 14-55-57.png

regards
Cor
 
My mic has not arrived yet however I thought I'd get the sketch installed. I'm struggling to find the uSDFS library, can anyone point me to the right place?
 
I have not experienced that myself but I know others have. This might have to do with the fact that I am running this inside Visual Code with the platformIO IDE.

Cor
 
Brilliant, thank you, I wondered whether it might be that one.

I seem to have something wrong but I've got to head out now so will check later:
"uSD.h:40:15: error: conflicting declaration 'typedef short int boolean'"
looks like it is defined elsewhere as:
typedef bool boolean;

while I had other issues with other existing libraries, this one is new to me.
I would either comment the typedef in uSD.h or proceed it with a #undef boolean line

dont't forget, editing a library require a change in the settings (either F_CPU or other parameters under tools) to force recomplilation of the libraty
 
I would either comment the typedef in uSD.h or proceed it with a #undef boolean line

Thanks, I commented it out and all compiles ok now :)

Apologies if I should ask elsewhere but I can't get it to upload - possibly my unfamiliarity with the Teensy:

Code:
07:33:19.378 (post_compile 1): Sending command: comment: Teensyduino 1.43 - LINUX64 (teensy_post_compile)
07:33:19.378 (loader): remote cmd from 4: "comment: Teensyduino 1.43 - LINUX64 (teensy_post_compile)"
07:33:19.379 (loader): remote cmd from 4: "status"
07:33:19.521 (post_compile 1): Status: 0, 0, 0, 0, 0, 0, /tmp/arduino_build_160315/, DD4WH_Bat_detector_v1_2.ino.hex
07:33:19.521 (post_compile 1): Sending command: dir:/tmp/arduino_build_193541/
07:33:19.521 (loader): remote cmd from 4: "dir:/tmp/arduino_build_193541/"
07:33:19.521 (post_compile 1): Sending command: file:DD4WH_Bat_detector_v1_2.ino.hex
07:33:19.521 (loader): remote cmd from 4: "file:DD4WH_Bat_detector_v1_2.ino.hex"
07:33:19.548 (loader): File "DD4WH_Bat_detector_v1_2.ino.hex". 165212 bytes, 256% used
07:33:19.548 (loader): File contains data beyond chip size, yikes!

"File contains data beyond chip size, yikes!" - that doesn't sound right...

If I press the button on the Teensy, the LED stops flashing, goes dimmer and the Teensy loader verbose info shows:

Code:
07:34:14.422 (ports 6): got command: "list"
07:34:14.428 (ports 6): got command: "list"
07:34:14.514 (loader): remote connection 4 closed
07:39:09.417 (ports 6): del child: location=/sys/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0/0003:16C0:0486.0003/hidraw/hidraw2
07:39:09.417 (loader): remote connection 4 opened
07:39:09.418 (ports 6): del child: location=/sys/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.1/0003:16C0:0486.0004/hidraw/hidraw3
07:39:09.418 (ports 6):   devnode=/dev/bus/usb/001/003, subsystem=usb, ifacenum=-1
07:39:09.418 (ports 6): unknown action: unbind
07:39:09.418 (ports 6): del child: location=/sys/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0/0003:16C0:0486.0003
07:39:09.419 (ports 6): unknown action: unbind
07:39:09.420 (ports 6): del child: location=/sys/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.1/0003:16C0:0486.0004
07:39:09.420 (ports 6): unknown action: unbind
07:39:09.420 (ports 6): unknown action: unbind
07:39:09.420 (ports 6): del child: location=/sys/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0
07:39:09.421 (ports 6): del child: location=/sys/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.1
07:39:09.422 (ports 6): unknown action: unbind
07:39:09.437 (ports 6): del device: location=/sys/devices/pci0000:00/0000:00:14.0/usb1/1-3
07:39:10.109 (ports 6): add device: subsys=usb, type=usb_device, location=/sys/devices/pci0000:00/0000:00:14.0/usb1/1-3
07:39:10.109 (ports 6):   devnode=/dev/bus/usb/001/006, subsystem=usb, ifacenum=-1
07:39:10.109 (ports 6): usb_add: /dev/bus/usb/001/006 (Teensy) Bootloader

I've had a look at the troubleshooting area but this looks different. Any ideas?
 
Hi,

Looks as if your compiler is not set for a teensy 3.6, the 165Kb Hex should fit easily on a 3.6. As I am not using this compiler setup I cannot comment on the other messages. I work using Visual Code with the PlatformIO IDE to debug/compile directly to a teensy.

regards
Cor
 
Looks as if your compiler is not set for a teensy 3.6, the 165Kb Hex should fit easily on a 3.6. As I am not using this compiler setup I cannot comment on the other messages. I work using Visual Code with the PlatformIO IDE to debug/compile directly to a teensy

Thanks, I'll investigate further. Weirdly the IDE seems to think things are ok - "Sketch uses 165200 bytes (15%) of program storage space. Maximum is 1048576 bytes.", it's just the Teensy loader that is showing the error.

EDIT:
Sorted it - the udev rules had not installed correctly - installed those and rebooted and I can download blink_fast and also DD4WH_Bat_detector_v1_2.ino.hex. Now I need to attach the screen and see if anything appears :)
 
Last edited:
Ok, screen is connected up and it's now displaying something sensible. Initially I just got a white screen but it turns out you have to put an SD card in or it just spins writing out a serial message. I changed the order of the code slightly so that it displays an error on the screen if the SD card is missing.

Anyway, looks good but frustratingly my MIC has not arrived yet :-(

IMG_20180914_112712.jpg
 
Hello DD4WH, thanks for this amazing progect.
Im trying to replicate but i m not able to compile your .ino (ff.h is missing)
where can i find that? maybe teensy new versions have a different name for the SD card libraries?

cheers
 
Hi i noticed you arrange your code differently , there is no .ino?
Maybe its a noobish question but are you using another IDE or how could i stick your code into arduino IDE?


thanks in advance

if you copy the code into, say, "Arduino/teensy_batdetector" where Arduino is your sketch folder, simply create an empty file "teensy_batdetector.ino"
this keep Arduino happy and allows you regular C/C++ programming (without Arduino interferences)
 
if you copy the code into, say, "Arduino/teensy_batdetector" where Arduino is your sketch folder, simply create an empty file "teensy_batdetector.ino"
this keep Arduino happy and allows you regular C/C++ programming (without Arduino interferences)

Im did what you proposed where teensy_batdetector.ino its a completely empty file
222.png

But now i get problems in definition of classes
222222.png
Code:
Arduino:1.8.7 (Windows 10), TD: 1.44, Tarjeta:"Teensy 3.6, Serial, 180 MHz, Faster, US English"

C:\Users\Javier\AppData\Local\Temp\arduino_build_499454\sketch\effect_granular.cpp: In member function 'void AudioEffectGranular::begin(int16_t*, int16_t)':

effect_granular.cpp:39: warning: unused variable 'subsample' 
  int subsample=0;

      ^

main.cpp:399: warning: ISO C++ forbids converting a string constant to 'char*' 
 char * SRtext="281";

               ^

main.cpp: In function 'void set_sample_rate(int)':
main.cpp:726: warning: ISO C++ forbids converting a string constant to 'char*' 
     SRtext = " 8";

            ^

main.cpp:730: warning: ISO C++ forbids converting a string constant to 'char*' 
     SRtext = "11";

            ^

main.cpp:734: warning: ISO C++ forbids converting a string constant to 'char*' 
     SRtext = "16";

            ^

main.cpp:738: warning: ISO C++ forbids converting a string constant to 'char*' 
     SRtext = "22";

            ^

main.cpp:742: warning: ISO C++ forbids converting a string constant to 'char*' 
     SRtext = "32";

            ^

main.cpp:746: warning: ISO C++ forbids converting a string constant to 'char*' 
     SRtext = "44";

            ^

main.cpp:750: warning: ISO C++ forbids converting a string constant to 'char*' 
     SRtext = "48";

            ^

main.cpp:754: warning: ISO C++ forbids converting a string constant to 'char*' 
     SRtext = "88k";

            ^

main.cpp:758: warning: ISO C++ forbids converting a string constant to 'char*' 
     SRtext = "96";

            ^

main.cpp:762: warning: ISO C++ forbids converting a string constant to 'char*' 
     SRtext = "176";

            ^

main.cpp:766: warning: ISO C++ forbids converting a string constant to 'char*' 
     SRtext = "192";

            ^

main.cpp:770: warning: ISO C++ forbids converting a string constant to 'char*' 
     SRtext = "234";

            ^

main.cpp:774: warning: ISO C++ forbids converting a string constant to 'char*' 
     SRtext = "281";

            ^

main.cpp:778: warning: ISO C++ forbids converting a string constant to 'char*' 
     SRtext = "352";

            ^

main.cpp: In function 'void spectrum()':
main.cpp:836: warning: unused variable 'colF' 
      int colF=ENC_VALUE_COLOR;

          ^

main.cpp:801: warning: unused variable 'curF' 
     int curF=int(freq_real/(sample_rate_real / FFT_points));

         ^

main.cpp: In function 'void waterfall()':
main.cpp:1068: error: 'class AudioEffectGranular' has no member named 'beginTimeExpansion'
                granular1.beginTimeExpansion(GRANULAR_MEMORY_SIZE);

                          ^

main.cpp:1096: error: 'class AudioEffectGranular' has no member named 'stopTimeExpansion'
         granular1.stopTimeExpansion();

                   ^

main.cpp: In function 'void startRecording()':
main.cpp:1130: warning: ISO C++ forbids converting a string constant to 'char*' 
       if (rc) die("close", rc);

                              ^

main.cpp:1166: warning: ISO C++ forbids converting a string constant to 'char*' 
             die("unlink", rc);

                             ^

main.cpp:1171: warning: ISO C++ forbids converting a string constant to 'char*' 
           die("close", rc);

                          ^

main.cpp:1177: warning: ISO C++ forbids converting a string constant to 'char*' 
       die("open", rc);

                     ^

main.cpp: In function 'void continueRecording()':
main.cpp:1219: warning: comparison between signed and unsigned integer expressions 
   if (recorder.available() >= N_BUFFER  )

                            ^

main.cpp:1222: warning: comparison between signed and unsigned integer expressions 
     for (int i = 0; i < N_BUFFER; i++) {

                       ^

main.cpp: In function 'void stopRecording()':
main.cpp:1258: warning: ISO C++ forbids converting a string constant to 'char*' 
         if (rc) die("close", rc);

                                ^

main.cpp: In function 'void changeDetector_mode()':
main.cpp:1380: error: 'class AudioEffectGranular' has no member named 'beginDivider'
          { granular1.beginDivider(GRANULAR_MEMORY_SIZE);

                      ^

main.cpp:1393: error: 'class AudioEffectGranular' has no member named 'beginTimeExpansion'
          { granular1.beginTimeExpansion(GRANULAR_MEMORY_SIZE);

                      ^

'class AudioEffectGranular' has no member named 'beginTimeExpansion'

Este reporte podría tener más información con
"Mostrar salida detallada durante la compilación"
opción habilitada en Archivo -> Preferencias.
those functions are defined (public) in AudioEffectGranular class inside effect_granular.h
so i think im messing up with the code integration
Sin título.png
 
Hi

I am currently on a holiday, be aware that I have build the most recent version of the batdetector with VisualCode as my IDE and inside a platformIO setup and on a Linux system (LM 18.3). Your warnings might be due to differences in the setup as you seem to be on windows10 and probably using the arduino IDE.
In my setup the locally changed audio-library effect-granular is used during compiling, it seems in your case the compiler still takes the default effect-granular files.

Cor
 
Im did what you proposed where teensy_batdetector.ino its a completely empty file
But now i get problems in definition of classes

You can ignore the warnings, they only refer to different language standards.
The errors, which complain about effect-granular, as CorBee explained means you are using different library.
So, you have to find I CorBee's GitHub his modified effect-granular library and copy that into your local Arduino library.
 
Hi

I am currently on a holiday, be aware that I have build the most recent version of the batdetector with VisualCode as my IDE and inside a platformIO setup and on a Linux system (LM 18.3). Your warnings might be due to differences in the setup as you seem to be on windows10 and probably using the arduino IDE.
In my setup the locally changed audio-library effect-granular is used during compiling, it seems in your case the compiler still takes the default effect-granular files.

Cor

Hi CorBee, i hope you enjoy your holidays.
First time i heard about platformIO im going to give it a try.
 
Hi

If you (like me) program on different platforms with different compilers using platformIO is really great. I program on TI MSP430s, arduino, teensy, esp8266 using platformio in visualcode. Full access to libraries across the compilers.

regards
Cor
 
If you (like me) program on different platforms with different compilers using platformIO is really great. I program on TI MSP430s, arduino, teensy, esp8266 using platformio in visualcode. Full access to libraries across the compilers.

Thanks @CorBee, I'd not considered PlatformIO before you mentioned it, despite using VCode. I have now installed it and got your code to compile and upload to the Teensy - it lives!
I've now realised I'm missing a couple of rotary encoders so I can't do much until I get them :-(
Do you have any you'd recommend? - Would something like this do? - https://uk.farnell.com/alps/ec12e2424407/encoder-vertical-24-det-24ppr/dp/1520813?MER=bn_search_1TP_SearchNB_2

I do use MSP430 for other applications so I'll have to experiment with PlatformIO. I usually use Eclipse for MSP430 so I'll be interesting in seeing how it compares...
 
The Alps encoders are probably ok, as long as you both an encoder and pushbutton. Function.

Platformio works fine using Arduino style programming on Msp430
 
The Alps encoders are probably ok, as long as you both an encoder and pushbutton. Function.
Platformio works fine using Arduino style programming on Msp430

Ok, encoders have arrived, I've fitted them and can now control things :cool:

I am struggling to get my head around what is going on though. I can see a spectrum display and that responds to speech and changing the sampling rate works as expected. When I try changing to one of the other display modes, I get no display (I do get the menu and info etc but no data). What am I doing wrong there?

Also, could someone point me towards a definition of the terms:
detector_heterodyne
detector_divider
detector_Auto_heterodyne
detector_Auto_TE
detector_passive
 
Back
Top