My bat project has been on the back-burner for the last few months, as I understand that bats don't venture out much during the winter.
However, the Weather Man on BBC's Winterwatch did say he had seen them flying around on a few mild evenings during January!
So maybe its time to do a bit more work on my Bat Call Logger and check if there are any out there.
Currently, my logger records the output from my Frequency Division (FD) bat detector. But I struggle with interpreting spectrograms from these recordings, as the square wave output is naturally rich in odd harmonics of the fundamental frequency.
I had this idea in my head that I could rig up my existing system with a laptop to record ultrasound, something like this;
Computer audio (sound) cards contain an analogue to digital converter to digitise the audio. This A/D converter needs to be at least twice as fast as the highest frequency of the sound you want to capture.
I had already checked my Adafruit USB sound module and found it was too slow. I don't know why I thought any of my 5 laptops would be any different, other than in the old days (when I had loads of desktops) they generally seemed to have high sample rates.
I did the usual check on each of my Linux laptops via terminal:-
pactl list short sinks
...and each one confirmed that they couldn't sample any faster than 44100Hz.
an audio card for the Pi
I seemed to remember that the Wolfson card was fast and had been a popular choice for the Pi, so went to Farnell and ordered one at the bargain price of £25 delivered. They used to be much more expensive than that, but production has now stopped as they only fit on the old Pi B rev2 boards (i.e. 26pin GPIO socket + P5 pads). However, there are a bunch of clever guys on the Element 14 forum who have worked out how to use it on a Pi 2 or 3.
To make the Wolfson compatible with the Pi 2 that I was planning to use, I needed to make a few modifications;
I modified an old 26w stacking header that I had spare (I think HobbyTronics still stock these). The pins are about 2mm longer than normal, so its easy to bend one of the pins out to isolate Pin 12 on the Wolfson from the Pi.
note that the pins are fully inserted, the gap is due to the extended pin length |
It was then just a case of soldering pin/socket jumper leads to the Wolfson. If I ever need to use the Wolfson card on an old Rev2 Pi, I just need to remove these fly leads.
software stuff
The new driver for the Wolfson has been added to the Pi build, but you need to ensure you have Linux Kernel 4.9, so type in a terminal:-
uname -a
Upgrade if necessary:-
sudo rpi-update
...then the usual:-
sudo apt update
sudo apt upgrade
..and maybe do a reboot.
Enable the driver by adding a new line to file: /boot/config.txt
dtoverlay=rpi-cirrus-wm5102
Create this configuration file: /etc/modprobe.d/cirrus.conf
Add to file:-
softdep arizona-spi pre: arizona-ldo1
(I hate instructions that include ones & ells. The last four chars are lower case L, d, o {not zero} and one).
Download the scripts from:-
http://www.horus.com/~hias/tmp/cirrus/cirrus-ng-scripts.tgz
Extract them, and then open a terminal at the scripts locations (e.g. from file manager hit F4) and then run:-
./Reset_paths.sh
...and then:-
./Record_from_Linein.sh
I only seem to need to run these scripts once, but I may build them into my Gambas program so that I'm not puzzled at some point in the future when audio stops working.
You will need to use something like alsamixer to set the IN1 & IN2 capture controls to zero. Use IN3L & IN3R to set the required inputs for acceptable recording levels.
In case these instructions don't work, or the method changes with future releases, just follow the steps detailed here.
As you don't seem to be able to record a single track (mono) from the Line-in sockets, I used the first channel for ultrasound recording and the second channel to record the divide-by-8 output.
In my Gambas program, I've just needed to select a new input pin to trigger the system when pulses are detected, and the arecord command now looks like this:-
Exec [“arecord”,
“-t”, “wav”, “-f”, “S16_LE”, “-c”, “2”, “-r”,
“192000”, “-D”, “hw0:1”, strAudioFile]
Due to the higher sample rate, the audio files are much bigger (about 750kB/second of recording) so I have upgraded from an 8MB SD card to 16MB. I may also try reducing the minimum recording time from 10s down to (say) 5 or 6s.
the circuit
I've lashed the system together and carried out some checks.
Pretty, it ain't |
The inter-connecting wiring now looks like this;
The 100k/100pF filter has a cutoff frequency of about 16kHz (this is the equivalent of 8 x 16 = 128kHz) which rounds the edges of the square wave (...but may not actually be helping with spectrogram analysis...it just seemed like a good idea!).
I recorded a 40kHz signal from a piezo-electric transducer, and then opened the file with Audacity;
from bat detector, top: 40kHz ultrasound output, bottom: divide-by-8 square wave output |
OK, I'm ready for those darn bats!
No comments:
Post a Comment