Bat detector

I understand that recording data required some processing. Thus what parameters did you recommend before record?
 
Nothing special, just use any setting you wish. Recording is ment to save raw data for later analysis. And like stated using 44Khz SR is not at all effective for bats. You should use at least 96Khz (for bats that dont produce sounds with frequencies higher than 45Khz) and anything higher will allow recording of higher-frequencies.
 
SD card

Ok, thanks for details. To lowering processing issue I force Sample rate at 8Khz, in PASS mode : But I try and writing freeze..even with SDhc not low cost.
I could be an issue with the code modification...
Some time I can read name files on the card. And start reading file. Need to found good SR also..or some *.raw file sample.
Long work for investigation...
 
Last edited:
Hi,

Which SD card are you using ? Do you have the same problems with the original sketch from DD4WH ?

Cor
 
Hi folks,

It's been i while since I have been here. It seems I have to do some reading.

I did run into some problems with uSDFS, the seems 13 days ago changes were made that makes the old corber code fail. Maybe it does work with newer code.
I hope to find me some time to test the latest on Github.

I allso have been playing with the ICS microphone I used it singele ended but did ty -out to GND using a capacitor. The signals seemed to be just about the same as on the SPU microphone. just a tiny bit lower signal on some frequencies. Ik kind of looks like someone suggested the unused output should be floating. I have to check that.

Anyway, glad to see the activity here.

Kind regards,

Edwin
 
Hi Edwin,

I feel that there are several people having problems to understand how to use the ICS40730 in single ended mode for maximum performance ;-).

Here is the <magic> with that MIC:

GND --> connect to GND
VDD --> connect to 1.5-3.6V power supply
OUTPUT- --> DO NOT CONNECT ANYTHING, EVEN A WIRE IS NOT ALLOWED, LEAVE THIS PAD ABSOLUTELY UNTOUCHED [this is also stated in the data sheet]
OUTPUT+ --> this is the microphone audio output, which you can connect to a standard audio OP-Amp as usual.

So, its much easier than you might have thought!? :)

With that setup, I am able to obtain an SNR of about 64dB [including MIC, preamp, wires, using the standard 3V3 regulator on the Teensy board, using the ADC of the Teensy in 12bit mode] and a superb high frequency response up to 160kHz (see post https://forum.pjrc.com/threads/38988-Bat-detector?p=208496&viewfull=1#post208496). However, if you manage to build a superduper audio amp you might be able to use the full 74dBA SNR range of the ICS40730.

Good luck!

Frank DD4WH

P.S.: your result of not seeing a difference to the SPU mic might be related to the fact that you connected OUT- OR that the SGTL5000 analog preamp is not really good in amplifying frequencies in the high ultrasound range.
 
Last edited:
The microphones work fine Frank, even with out- tied to ground with a capacitor.... It was clearly stated in the last lines of the datasheet.

Well, I only soldered about 10 of my mics with extra capacitors. Nor ready for testing (again) together with a bunch of other freshly soldered mics.
Man, this ICS40730 realy is a huge one :)

I also had been playing with Cor's code. Not with the latest but just to see why people are complaining it does not work, even when I thought i made good instructions.


I found two "problems" uSDFS has been updated tan this gives error of missing ff_utils.h, I used the older library I had stored and it worked right away.

The other problem was an exitstatus 1 error when compiling almost is finished. This did not appear with Arduino 1.8.7 with Teensyduino 1.44 but now that we have the 1.8.9 and 1.46 version I can not get the code from post 159 to compile.

Switching back again to the older uSDFS and Arduino 1.8.7 with Teensyduino 1.44 fixed the errors.

Edwin



IMG_20190621_211047172.jpg
 
For the people struggling to find the older versions the Arduino 1.8.7 windows installer

Here the Teensyduino 1.44 Windows installer

The old uSDFS library


If everything fails, use the precompiled hex v0.84 with the code by Corber as found on github today.
Or this older hex file (082?) I had on my computer.


Open Teensy.exe in C:\Program Files (x86)\Arduino\hardware\tools
Select open hex file, and press the button on the Teensy to load the file.

The time and date will notbe correct I guess but at leas it could save you with struggling to get things compiled.

Edwin
 
Many thanks for your help....I dont have old sd micro. I continu with my SD HC in fat32. I download corberjune.ino.hex with old tools teensy duino : it works :
I can see the message of Sd recording, Button stop work. I can read the file into audacity. I check only with noise.
The other hex file is to big for teensy tools

I was not able to compile with A1.8.7 , T 1.44 and this old uSDFS. First I need to rename the function SDHC_isr wich is into two librairy ( uSDFS and SD)...like yet discribe in my first post here. Some other compilation problems.

Under last version of Arduino and Teensy I have try someexample in SD and uSDFS. Most of them are working.
Remi
 
Many thanks for your help....I dont have old sd micro. I continu with my SD HC in fat32. I download corberjune.ino.hex with old tools teensy duino : it works :
I can see the message of Sd recording, Button stop work. I can read the file into audacity. I check only with noise.
The other hex file is to big for teensy tools

I was not able to compile with A1.8.7 , T 1.44 and this old uSDFS. First I need to rename the function SDHC_isr wich is into two librairy ( uSDFS and SD)...like yet discribe in my first post here. Some other compilation problems.

Under last version of Arduino and Teensy I have try someexample in SD and uSDFS. Most of them are working.
Remi

Hi,

You mention a corberjune.ino.hex ... that you download ... I guess that is a compiled version of my code that I upload at https://github.com/CorBer/teensy_batdetector ? When sharing your work (and problems) try to be accurate in describing what you are doing as this might lead very easy to confusing remarks.

regards
Cor
 
Hi Edwin,

what an impressive amount of microphones!!! Looks like a lot of soldering fun ;-).

with out- tied to ground with a capacitor.... It was clearly stated in the last lines of the datasheet

This is wrong for single ended mode and is not stated in the datasheet, that is what my posts in the last days were about.

As you can see on page 9 of the manual, the codec in figure 7 has a differential input. Only for differential output connect OUT- of the mic to IN- of the codec (IN- is not the same as GND in a differential input codec).

For a single-ended MIC output leave OUT- unconnected. --> see page 8 of the datasheet:

"The unused output pin should be left disconnected when the mic is used in single-ended mode; do not connect the unused pin to ground."

But maybe we are talking about different microphones and different datasheets ???

This is the one I am using:

http://www.invensense.com/wp-content/uploads/2018/12/DS-000139-ICS-40730-v1.0.pdf

I think it would be good to contact Walter, WMXZ, the author of the uSDFS lib in order to resolve the problem with the lib. I do not think it is wise to directly delete / alter the uSDFS files or other files in the Teensyduino installation.
 
I found two "problems" uSDFS has been updated tan this gives error of missing ff_utils.h, I used the older library I had stored and it worked right away.

I repeat, what I said earlier, do NOT use uSDFS together with SD and if you only need the tm2seconds or seconds2tm functions it is better to copy the function from ff_utils.h
 
Hi,

I repeat, what I said earlier, do NOT use uSDFS together with SD and if you only need the tm2seconds or seconds2tm functions it is better to copy the function from ff_utils.h

I do not think that the original source of Frank DD4WH was only using tm2seconds from uSDFS. That error raised when people where trying to ommit using the SD for recording, but that is not really the functionality we are building towards. From what I understand (based on a mail from Edwin), the 1.0.6 version was working fine and things went wrong with the latest version(s). Its a bit unclear - I looked at the commits - what can cause this behaviour from uSDFS.

This is probably also a pure windows/arduino problem. The sourcecode in my github uses seconds2tm from your ff_utils.h library and I have (programming in visual code under linux) no problems. I think the arduino uses libraries different. Question is where the link to uSDFS comes into the play and how to prevent it. This is the codepart that sets up the initial interaction with SD and additional libraries. As you see no reference to uSDFS.

Code:
#ifdef USESD1
  //#define USESD
  #include <SD.h>
  #include "ff.h"       // uSDFS lib
  #include "ff_utils.h" // uSDFS lib
  File root;
  FRESULT rc;        /* Result code */
  FATFS fatfs;      /* File system object */
  FIL fil;        /* File object */
#endif


regards
Cor
 
Last edited:
When compile the #159 post with Arduino 1.8.7 and Teensyduino 1.44 and the latest uSDFS library I get this error.

Code:
C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Toshiba\Documents\Arduino\libraries -fqbn=teensy:avr:teensy36:usb=serial,speed=180,opt=o2std,keys=en-us -ide-version=10807 -build-path C:\Users\Toshiba\AppData\Local\Temp\arduino_build_671532 -warnings=all -build-cache C:\Users\Toshiba\AppData\Local\Temp\arduino_cache_784013 -verbose C:\Users\Toshiba\Documents\Arduino\teensybatpost159\teensybatpost159.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Toshiba\Documents\Arduino\libraries -fqbn=teensy:avr:teensy36:usb=serial,speed=180,opt=o2std,keys=en-us -ide-version=10807 -build-path C:\Users\Toshiba\AppData\Local\Temp\arduino_build_671532 -warnings=all -build-cache C:\Users\Toshiba\AppData\Local\Temp\arduino_cache_784013 -verbose C:\Users\Toshiba\Documents\Arduino\teensybatpost159\teensybatpost159.ino
Using board 'teensy36' from platform in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr
Using core 'teensy3' from platform in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr
Detecting libraries used...
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -fno-exceptions -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -D__MK66FX1M0__ -DTEENSYDUINO=144 -DARDUINO=10807 -DF_CPU=180000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\cores\\teensy3" "C:\\Users\\Toshiba\\AppData\\Local\\Temp\\arduino_build_671532\\sketch\\teensybatpost159.ino.cpp" -o nul
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -fno-exceptions -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -D__MK66FX1M0__ -DTEENSYDUINO=144 -DARDUINO=10807 -DF_CPU=180000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\cores\\teensy3" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\SD" "C:\\Users\\Toshiba\\AppData\\Local\\Temp\\arduino_build_671532\\sketch\\teensybatpost159.ino.cpp" -o nul
"C:\\Program Files (x86)\\Arduino\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -fno-exceptions -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -D__MK66FX1M0__ -DTEENSYDUINO=144 -DARDUINO=10807 -DF_CPU=180000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\cores\\teensy3" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\SD" "-IC:\\Program Files (x86)\\Arduino\\hardware\\teensy\\avr\\libraries\\uSDFS-master\\src" "C:\\Users\\Toshiba\\AppData\\Local\\Temp\\arduino_build_671532\\sketch\\teensybatpost159.ino.cpp" -o nul
C:\Users\Toshiba\Documents\Arduino\teensybatpost159\teensybatpost159.ino:115:37: fatal error: ff_utils.h: No such file or directory

compilation terminated.

Using library SD at version 1.2.2 in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD 
Using library uSDFS-master at version 1.1.2 in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\uSDFS-master 
Error compiling for board Teensy 3.6.

It seems the file ff_utils.h is missing, but maybe that is not the real issue here.

I see a lot of files are moved from the src folder. I tried to put the old ff_utils.h back into the src folder but end up with a new missing file.

Code:
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\uSDFS-master\src\utility\sd_msc.cpp:41:18: fatal error: msc.h: No such file or directory

When the #include ff_utils.h is commented out I get this error:

Code:
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\uSDFS-master\src\utility\sd_msc.cpp:41:18: fatal error: msc.h: No such file or directory


I did not yet see what calls for msc.h but it is late enough here already so I get some sleep first.

Edwin
 
Hi,

I an attempt to solve the problems in the windows environment I have split the function seconds2tm away from dependencies related to uSDFS. To do this I have copied/changed the ff_utils(.c/.h) file and renamed the function to seconds2time and removed other functions from the ff_utils library. This is all available on the github repository, you need to download the new main.cpp and ff_utils_copy(.c/.h). I hope this clears the problems with the uSDFS library for windows users. Since I dont have a working setup to test the windows environment I cannot guarantee this will work. In my linux setup this did compile and work,

regards
Cor
 
Hi,

I an attempt to solve the problems in the windows environment I have split the function seconds2tm away from dependencies related to uSDFS. To do this I have copied/changed the ff_utils(.c/.h) file and renamed the function to seconds2time. This is all available on the github repository, you need to download the new main.cpp and ff_utils_copy(.c/.h). I hope this clears the problems with the uSDFS library for windows users. Since I dont have a working setup to test the windows environment I cannot guarantee this will work. In my linux setup this did compile and work,

regards
Cor

it should, obviously you remove all includes ff.h and ff_itils.h
OK, I see you did not.

I wiil later suggest mods to use bat detector with uSDFS (USESD1)
 
Last edited:
Did I miss one then ? In the ff_utils_copy library I have no references to ff_utils or ff anymore ... and also not in the main code. A reference to ff is needed for other functions
 
Just saw that Edwin (pe1wf) has tried to use the new code (0.85) but still got compilation errors using a windows setup. It seems the whole structure of reading/writing to SDcards needs to be reconstructed to untangle dependencies that have to do with the SD and uSDFS libraries. Not sure how easy that is ...

Cor
 
I made some changes to the code View attachment teensy_batdetector.zip
I combined the SD routines together
I also changes the granular effect class to coexist with stock library
The ff_utils files are not used and should be removed
Have no HW to test it, but it compiled under Arduino/TD
edit: uSDFS/utility/sd_conf.h must ne edited to remove msc (if not installed as library)
 
Hi,

Thanks very much for trying to get this working, I will wait until people that have the hardware and the windows-setup report back without compiler issues. In the mean time I will set this up in my environment also.

regards
Cor
 
Hi,

In my setup I got errors with the new way to call granular, could easy switch back by commenting line 275 #include "effect_granular.h" and then renaming
mAudioEffectGranular granular1;
back to AudioEffectGranular granular1;

Then got the expected error for msc, saw in message 273 that something needs to change in utility/sd_config.h ... but what ?
Simply changing #define USE_MSC 1 to #define USE_MSC 0
did not work and resulted in series of alike errors:

Code:
.pioenvs/teensy36/lib54f/libuSDFS_ID2957.a(ff.c.o): In function `f_mount':
ff.c:(.text.f_mount+0x0): multiple definition of `f_mount'

Could it be due to an older version of the uSDFS library, I installed it directly using platformio and on the top of uSDFS.h I see
#define uSDFS_VER "03_Jun_19_21_40"
 
Last edited:
I just commented out this line in sd_config.h

#define USE_MSC 1 // will be used in sd_msc.cpp

Now the output looks like this...
Code:
C:\Users\Toshiba\AppData\Local\Temp\arduino_build_330571\sketch\effect_granular.cpp: In member function 'void mAudioEffectGranular::begin(int16_t*, int16_t)':

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

      ^

teensy_batdetectorwmxz:1085: error: 'FRESULT' has not been declared
   void die(char *str, FRESULT rc)

                     ^

Using library Time at version 1.5 in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Time 
Using library Audio at version 1.3 in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Audio 
Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SPI 
Using library SD at version 1.2.2 in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD 
Using library SerialFlash at version 0.5 in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SerialFlash 
Using library Bounce in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Bounce (legacy)
Using library ILI9341_t3 at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\ILI9341_t3 
Using library Encoder at version 1.4.1 in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Encoder 
Using library uSDFS-master at version 1.1.2 in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\uSDFS-master 
Using library Wire at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire 
'FRESULT' has not been declared
 
Back
Top