Bat detector

Getting quite confused here...
I tried to completely remove all Arduino stuff, reinstalled Arduino 1.8.9 and Teensyduino 1.46 thought I had all the right libraries and files including the suggested alterations.

I keep getting errors.

OK,
let us do it the following way: you get latest uSDFS from my github and batdetector from CorBee's github
move uSDFS into your local Arduino library (removing the "-master" from the file)
compile the batrecorder and post the whole compilation log
we will work from there.
 
Hi Seriesman, I already expected a detailed report of the last few nights...

For recording you have to set the function of the left pushbutton to record.

Turn the left encoder until you see ButtonL
Press the encoder (ButtonL and "DISPLAY" will change to white color)
Turn the encoder to select RECORD
Than press the encoder again.

In the lower left coder you should see REC OFF

Press the left pushbutton to start recording
press the left pushbutton again to stop recodring
 
Compiling finally worked,

It does display some warnings but no errors.

I went back to Arduino 1.8.7 Teensyduino can be 1.44 or 1.46

I still keep running into time errors so I used my TimeAlt escape to get things compiling.


I have all libraries that I use and are not exactly standard in C:\Users\..username..\Documents\Arduino\libraries

I have the feeling Arduino 1.8.9 does not want to work with this code on my Windows10 x64 and Windows7 x86 machines.


Code:
C:\Users\Toshiba\AppData\Local\Temp\arduino_build_320440\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;

      ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Audio\output_tdm.cpp: In static member function 'static void AudioOutputTDM::isr()':

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Audio\output_tdm.cpp:128:19: warning: variable 'dc' set but not used [-Wunused-but-set-variable]

  uint32_t *dest, *dc;

                   ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\NXP_SDHC.cpp: In function 'int SDHC_CardReadBlock(void*, uint32_t)':

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\NXP_SDHC.cpp:583:13: warning: unused variable 'pData' [-Wunused-variable]

   uint32_t* pData = (uint32_t*)buff;

             ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\NXP_SDHC.cpp: In function 'int SDHC_CardWriteBlock(const void*, uint32_t)':

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\NXP_SDHC.cpp:646:19: warning: unused variable 'pData' [-Wunused-variable]

   const uint32_t *pData = (const uint32_t *)buff;

                   ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\NXP_SDHC.cpp: In function 'void sdhc_setSdclk(uint32_t)':

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\NXP_SDHC.cpp:881:12: warning: unused variable 'm_sdClkKhz' [-Wunused-variable]

   uint32_t m_sdClkKhz = f_pll / (1000 * sdclkfs * dvs);

            ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\NXP_SDHC.cpp: At global scope:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\NXP_SDHC.cpp:428:13: warning: 'void SDHC_SetClock(uint32_t)' declared 'static' but never defined [-Wunused-function]

 static void SDHC_SetClock(uint32_t sysctl);

             ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\NXP_SDHC.cpp:430:12: warning: 'int SDHC_ReadBlock(uint32_t*)' declared 'static' but never defined [-Wunused-function]

 static int SDHC_ReadBlock(uint32_t* pData);

            ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\NXP_SDHC.cpp:431:12: warning: 'int SDHC_WriteBlock(const uint32_t*)' declared 'static' but never defined [-Wunused-function]

 static int SDHC_WriteBlock(const uint32_t* pData);

            ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\NXP_SDHC.cpp:1196:12: warning: 'int SDHC_CMD12_StopTransferWaitForBusy()' defined but not used [-Wunused-function]

 static int SDHC_CMD12_StopTransferWaitForBusy(void)

            ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\NXP_SDHC.cpp:1230:12: warning: 'int SDHC_CMD17_ReadBlock(uint32_t)' defined but not used [-Wunused-function]

 static int SDHC_CMD17_ReadBlock(uint32_t sector)

            ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\NXP_SDHC.cpp:1250:12: warning: 'int SDHC_CMD24_WriteBlock(uint32_t)' defined but not used [-Wunused-function]

 static int SDHC_CMD24_WriteBlock(uint32_t sector)

            ^

C:\Users\Toshiba\Documents\Arduino\libraries\uSDFS-master\src\utility\ff_utils.c: In function 'get_fattime':

C:\Users\Toshiba\Documents\Arduino\libraries\uSDFS-master\src\utility\ff_utils.c:68:29: warning: implicit declaration of function 'rtc_get' [-Wimplicit-function-declaration]

     struct tm tx=seconds2tm(rtc_get());

                             ^

Opening Teensy Loader...

Sketch uses 186360 bytes (17%) of program storage space. Maximum is 1048576 bytes.
Global variables use 227424 bytes (86%) of dynamic memory, leaving 34720 bytes for local variables. Maximum is 262144 bytes.
C:\Program Files (x86)\Arduino\hardware\teensy/../tools/teensy_post_compile -file=CorBee086.ino -path=C:\Users\Toshiba\AppData\Local\Temp\arduino_build_320440 -tools=C:\Program Files (x86)\Arduino\hardware\teensy/../tools -board=TEENSY36 -reboot -port=COM8 -portlabel=(null) -portprotocol=(null)
 
Detailed report

Hi Seriesman, I already expected a detailed report of the last few nights...

For recording you have to set the function of the left pushbutton to record.

Turn the left encoder until you see ButtonL
Press the encoder (ButtonL and "DISPLAY" will change to white color)
Turn the encoder to select RECORD
Than press the encoder again.

In the lower left coder you should see REC OFF

Press the left pushbutton to start recording
press the left pushbutton again to stop recodring

Hi Sorry, Long eared, pipistrelle and noctule last night, earlier nights too cold or too windy. UNit not completely boxed but very field usable. A bit of a triumph!! Thanks again
 
Hi Seriesman, I already expected a detailed report of the last few nights...

For recording you have to set the function of the left pushbutton to record.

Turn the left encoder until you see ButtonL
Press the encoder (ButtonL and "DISPLAY" will change to white color)
Turn the encoder to select RECORD
Than press the encoder again.

In the lower left coder you should see REC OFF

Press the left pushbutton to start recording
press the left pushbutton again to stop recodring

Hi Edwin

Thanks for chiming in to help new users. I was busy with other stuff. '

regards
Cor
 
Hi Cor, I'm just glad to be able to help.

The files that I got compiling under windows in Arduino 1.8.7 are saved here just in case anyone needs them.

Have you been playing with the playback function? I know you were trying to put that under the left button function. The old way was still working but I don't see it anymore now that I uploaded the latest code.

Edwin
 
Hi,

No change (at least not intentional) for the playback. It still is part of the main menu structure (position in the menu is after Sample Rate)

Cor
 
It seems I have some memoycard issues, files are not recognized and recording starts at B1 but I have files op to B55.

I will have to try again tomorrow. It looks like the 0.82 version works fine.

0.84 and 0.86 hex file hangs.

Better have some sleep first.
 
It seems I have some memoycard issues, files are not recognized and recording starts at B1 but I have files op to B55.

I will have to try again tomorrow. It looks like the 0.82 version works fine.

0.84 and 0.86 hex file hangs.

Better have some sleep first.

I thought I might have run over a maf files number but after deleting files I was not able to record or play back any files.
The 0.82 version seems to work fine but I did expect the left button function in that one.

Somewhere I am messing up files I think.
The precompiled 0.84 and 0.86 do not seem to want to function in my test unit. Selecting any recording pr playback function makes it hang or it hans already after booting.

Am I the only one experiencing this?

I don't want to try and upload to my completed unit since i don't want to mess it up before we know the solution. (if we do seem to need any solution)

Edwin
 
HI all,

It is always possible to download an older version of the code, to do this you need to go to https://github.com/CorBer/teensy_batdetector/commits/master/main.cpp
This will show all moments in time that files were changed/added. If you click on the rightmost <> button on given commit (date) you will see how the repository was looking at that date.

As I am not experiencing any issues I will wait till its clear what is going on from the tests

regards
Cor

regards
Cor
 
I have added the precompiled_082 again to the repository in the pre_compiled_hex directory
 
Last edited:
HEllo

I confirm the good result with Pe1pwf work: Windows, Arduino 1.8.7, Teensyduino 1.46
codes and libraries here:
https://drive.google.com/file/d/11BgRDCXH6Un10M2vmeA1CUw1kpG-siBx/view
I copie Librarie ( except audio) in my arduino lib ; I use the same directory with theses files: OK it compiles.

I was able to program my hardware, to record some file on SD. Some times I can also read it on teensey.

I try again under linux, and arduino 1.8.9 : Need to add #define BUILTIN_SD : it compiles but the hex file is to big after compilation !

Many Thanks!
 
Last edited:
Hi Remis,

Thanks for the info, so you managed to compile v086 using the uSDFS-master library of the 3rd of june 2019. Its important to mention that too, nice to see that testing different arduino versions also can create problems. So version 1.8.7 works as planned and 1.8.9 does not. I know edwin is also testing things, when we get a clear picture I will mention that in the description of the github page

Thanks for testing !

Cor
 
Bat recordings

Hi Sorry, Long eared, pipistrelle and noctule last night, earlier nights too cold or too windy. UNit not completely boxed but very field usable. A bit of a triumph!! Thanks again

Hi Lovely warm evening. Constant Long Eared bat activity. v0.86 recorded 6 sessions of about 2-3 minutes each on SanDisk 2Gb microsd which played back on PC via Audacity 2.3.2. Spectrogram on Audacity was good enough to identify a pipistrelle in the background that was masked by the very loud long eared bat calls. Brilliant. So grateful. This is a marvellous tool. Thank you all of you.
 
Schematic supply chek and decoupling

HEllo
Many thanks to Edwin for this document and associated work:
https://drive.google.com/file/d/1Uu2kTnleLcJJ1JrEzeiRPV7JJSGXqBRW/view
I start from this schematic page 8. I check the power supply and decoupling effect

At the input I add low drop voltage regulator (BD750L5 Rohm) to provide 5V in any case from a battery. Lowest battery voltage at his input :5.3V. With 5V R7 seem to be high in some case: must be confirmed. Go to 8 or 5 ohms : the worst case for teensy is done by one board regulator : http://www.ti.com/product/LP38691
low dropout voltage (250 mV at 500-mA load current) . Thus you need to be higher that 3.5V in any case. See also voltage drop for LTC1700-3302E:350mV worst case, thus 3.6V min at 3.3V regulator input.

I Add 220µF small tantalum directly on Audio board 3.3-GND holes. I see noise changing from 50mVpp to few mVpp.

The TFT is also one of the major noise contributor : I add SMD capacitor ( 470nF , 1µF ) soldered on the TFT pin. Same think on bottom side 3.3V and GND under teensy and audio board.
If you don’t have oscilloscope you can use the on board spectrum analyseur to check the improvement : without mic connected , with same gain configuration.
 
amplifier input check

Hello
I check also the NPN amplifier with BC847C. Less gain to begin, and not saturate. I performed simulation and measurements wich are compliants. I suppose a typical 50mVpp input signal to start the analysis. I don’t have microphone at this time, except ultrasonic transducter.We can use theses results to improve gain. After some real test. The codec input use 1.8V for voltage reference. difficult to saturate, but easy to clamp.
Any way I suggest to check the collector voltage value without mic at the input. See also attached simulation file to help
measurements with osciloscope: BC847c SMD ; R2=39k ; rb1=135k ; R3=Rc=2.13k adjusted
direct connection to 100nF input condensator to codec

test:
under 300mVpp, from 10Khz to 100Khz I measure 2320 ohms for codec input impedance
At 40khz : in 50mvpp and out 300mvppout ; G= 20log(6)=15dB

simulation : 360mVpp out.
Vc=1.6Vdc continu measured ; simulation : 1.9V

simulation done with LTCspice.

I build a second receiver. Measured confirmed:
Vout=390mVpp
Vdc adjusted to 1.6Vdc
Rc measured:2100 ohms
 

Attachments

  • ampliNPN_Batdetector.asc.zip
    1.3 KB · Views: 93
Hi!

I am new here at the forum.
I have build a Teensy Bat Detector with the help of a PCB from pe1pwf.
Must seems to work OK but I can't get turning of encoders left-right to work, nothing happens, I have tested with hex files 0.82, 0.84 an 0.86.
I push right encoder and Gain changes from yellow to white but nothing happens then I turn left or right.
All four pushbuttons are working OK.
When I load a pushbutton example program from Arduino IDE the turns are working.
How can I get turning of encoders to work?

Regards Bengt (Öckerö, Sweden)
 
Hi!

I am new here at the forum.
I have build a Teensy Bat Detector with the help of a PCB from pe1pwf.
Must seems to work OK but I can't get turning of encoders left-right to work, nothing happens, I have tested with hex files 0.82, 0.84 an 0.86.
I push right encoder and Gain changes from yellow to white but nothing happens then I turn left or right.
All four pushbuttons are working OK.
When I load a pushbutton example program from Arduino IDE the turns are working.
How can I get turning of encoders to work?

Regards Bengt (Öckerö, Sweden)

Hi,

I suggest trying to start a check of the hardware, are the lines of the encoders connected to the teensy ? You can read from the code which line of the encoder should be directly connected to which pin on the teensy. If all that seems to be OK the question is if turning the encoders changes the state of the lines. All this can be checked using a multimeter and no power on the teensy.

regards
Cor
 
Hi,

I suggest trying to start a check of the hardware, are the lines of the encoders connected to the teensy ? You can read from the code which line of the encoder should be directly connected to which pin on the teensy. If all that seems to be OK the question is if turning the encoders changes the state of the lines. All this can be checked using a multimeter and no power on the teensy.

regards
Cor

I have used this Arduino sketch and it is working fine, it must be something else I am doing wrong?

Code:
/* Pushbutton with Pullup, Teensyduino Tutorial #3
   http://www.pjrc.com/teensy/tutorial3.html

   This example code is in the public domain.
   2019-07-12 Changed for test of Teensy Bat Detector buttons. Bengt Karlsson
*/

void setup() {                
  Serial.begin(38400);
  pinMode(29, INPUT_PULLUP);
  pinMode(30, INPUT_PULLUP);
  pinMode(31, INPUT_PULLUP);
  pinMode(36, INPUT_PULLUP);
  pinMode(34, INPUT_PULLUP);
  pinMode(35, INPUT_PULLUP);
  pinMode(38, INPUT_PULLUP);
  pinMode(37, INPUT_PULLUP);
}

void loop()                     
{
  if (digitalRead(29) == LOW) Serial.println("ENC_L button pressed!!!");
  if (digitalRead(30) == LOW) Serial.println("ENC_L turned A!!!");
  if (digitalRead(31) == LOW) Serial.println("ENC_L turned B!!!");
  if (digitalRead(36) == LOW) Serial.println("ENC_R button pressed!!!");
  if (digitalRead(34) == LOW) Serial.println("ENC_R turned A!!!");
  if (digitalRead(35) == LOW) Serial.println("ENC_R turned B!!!");
  if (digitalRead(38) == LOW) Serial.println("MICROPUSH_L button pressed!!!");
  if (digitalRead(37) == LOW) Serial.println("MICROPUSH_R button pressed!!!");
  delay(250);
}
 
I have used this Arduino sketch and it is working fine, it must be something else I am doing wrong?

Code:
/* Pushbutton with Pullup, Teensyduino Tutorial #3
   http://www.pjrc.com/teensy/tutorial3.html

   This example code is in the public domain.
   2019-07-12 Changed for test of Teensy Bat Detector buttons. Bengt Karlsson
*/

void setup() {                
  Serial.begin(38400);
  pinMode(29, INPUT_PULLUP);
  pinMode(30, INPUT_PULLUP);
  pinMode(31, INPUT_PULLUP);
  pinMode(36, INPUT_PULLUP);
  pinMode(34, INPUT_PULLUP);
  pinMode(35, INPUT_PULLUP);
  pinMode(38, INPUT_PULLUP);
  pinMode(37, INPUT_PULLUP);
}

void loop()                     
{
  if (digitalRead(29) == LOW) Serial.println("ENC_L button pressed!!!");
  if (digitalRead(30) == LOW) Serial.println("ENC_L turned A!!!");
  if (digitalRead(31) == LOW) Serial.println("ENC_L turned B!!!");
  if (digitalRead(36) == LOW) Serial.println("ENC_R button pressed!!!");
  if (digitalRead(34) == LOW) Serial.println("ENC_R turned A!!!");
  if (digitalRead(35) == LOW) Serial.println("ENC_R turned B!!!");
  if (digitalRead(38) == LOW) Serial.println("MICROPUSH_L button pressed!!!");
  if (digitalRead(37) == LOW) Serial.println("MICROPUSH_R button pressed!!!");
  delay(250);
}

Thats indeed special, if you try to use the encoder library to do the same does it still work ?
THis is the library https://www.pjrc.com/teensy/td_libs_Encoder.html

regards
Cor
 
Thats indeed special, if you try to use the encoder library to do the same does it still work ?
THis is the library https://www.pjrc.com/teensy/td_libs_Encoder.html

regards
Cor

I have tried this code, not working so good, OK after I added debounce capacitors, but not working in Teensy Bat Detector, used 3,3nF, I will do some more test if I can find some more capacitors with lower values.

Code:
/* Encoder Library - TwoKnobs Example
 * http://www.pjrc.com/teensy/td_libs_Encoder.html
 *
 * This example code is in the public domain.
 */

#include <Encoder.h>

// Change these pin numbers to the pins connected to your encoder.
//   Best Performance: both pins have interrupt capability
//   Good Performance: only the first pin has interrupt capability
//   Low Performance:  neither pin has interrupt capability
Encoder knobLeft(30, 31);
Encoder knobRight(34, 35);
//   avoid using pins with LEDs attached

void setup() {
  Serial.begin(9600);
  Serial.println("TwoKnobs Encoder Test:");
}

long positionLeft  = -999;
long positionRight = -999;

void loop() {
  long newLeft, newRight;
  newLeft = knobLeft.read();
  newRight = knobRight.read();
  if (newLeft != positionLeft || newRight != positionRight) {
    Serial.print("Left = ");
    Serial.print(newLeft);
    Serial.print(", Right = ");
    Serial.print(newRight);
    Serial.println();
    positionLeft = newLeft;
    positionRight = newRight;
  }
  // if a character is sent from the serial monitor,
  // reset both back to zero.
  if (Serial.available()) {
    Serial.read();
    Serial.println("Reset both knobs to zero");
    knobLeft.write(0);
    knobRight.write(0);
  }
}
 
Be aware that the code in the bat-detector also uses
Code:
//try to avoid interrupts as they can (possibly ?) interfere during recording
#define ENCODER_DO_NOT_USE_INTERRUPTS
 
Back
Top