How does this works ?
It uses the LM386 based preamp electret from the peak detector (refer to theÂ mainboardÂ to have the whole base schematic). Since it converts sound into voltage, it can be directly wired to the PIC 16F88 (I hope/think so…).
include sb_config include sb_protocol include sb_mainboard -- configure ADC const ADC_hardware_Nchan = 3 ;number of selected channels const ADC_hardware_NVref = 0 ;number of external references const ADC_hardware_Rsource = 10_000 ;maximum source resistance const ADC_hardware_high_resolution = false;true = high resolution = 10 bits include adc_hardware ADC_init pin_a0_direction = input ; electret mic is connected to... forever loop var byte res = ADC_read_low_res(0) echo(res) end loop
For now, only one ADC channel is used, but soon there’ll be at least two to localize sound in space (see later). NoÂ VrefÂ is used, so +5V/0V will be used. It’s ok since the preamp electret microphone output ranges betweenÂ those.
I’ve tested the whole in “real” condition, that is recordingÂ my birds. The result is quite nice: the sound sensor is able to detect when birds sing “like a big fat pig”. There may be problems to detect when they just “twitter in the fresh air of the morning”, though…
My first idea was to set two thresholds: one above which birds are considered to twitter, another where they sing like a bit fat pig… By this way, when the bot simulates sings, I would have been able to know when birds are responsive the correct way or not. There probably needs to have a better amplification for this.
Anyway, this sound sensor seems to be the most usable:
- few components are required
- no need to adjust sensitivity: everything can be configure through software
- result is far richer than a binary response (got sound or not)
- this is a first step to actually record sound, and play them back from the PC