PIC Powered PicoBat Picks Up Pulsed Power

In 2012, [Bruno] wanted to detect some bats. Detect bats? Some varieties of bat (primarily the descriptively named “microbats”) locate themselves and their prey in space using echolocation, the same way your first robot probably did. The bat emits chirps from their adorably tiny larynx the same way a human uses its vocal cords to produce sound. The bat then listens for an echo of that sound and can make inferences about the location of its presumed prey in the volume around it. Bat detectors are devices which can detect these ultrasonic sounds and shift them into a range that humans can hear. So how would you build such a device? [Bruno]’s PicoBat probably sets the record for component count and code simplicity.

With no domain expertise the most conspicuous way to build a bat detector is probably to combine the glut of high performance microcontrollers with a similarly high performing analog to digital converter. With a little signal processing knowledge you sample the sounds at their native frequency, run them through a Fast Fourier transform, and look for energy in the ultrasonic frequency range, maybe about 20 kHz to 100 kHz, according to Wikipedia. With more knowledge about signal interference it turns out there are a surprisingly large number of ways to build such a device, including some which are purely analog. (Seriously, check out the Wikipedia page for the myriad ways this can be done.)

[Bruno] did use a microcontroller to build his bat detector, but not in the way we’d have expected. Instead of using a beastly high performance A/D and a similarly burly microcontroller, the PicoBat has a relatively tame PIC12 and a standard ultrasonic transducer, as well as a piezo buzzer for output. Along with a power rail, that’s the entire circuit. The code he’s running is similarly spartan. It configures a pair of GPIOs and toggles them, with no other logic. That’s it.

So how does this work? The ultrasonic transducer is designed mechanically to only receive sounds in the desired frequency range. Being piezoelectric, when enough sound pressure is applied the stress causes a small voltage. That voltage is fed into the PIC not as a GPIO but as a clock input. So the CPU only executes an instruction when ultrasonic sound with enough intensity hits the transducer. And the GPIO toggling routine takes four clock cycles to execute, yielding a 1:4 clock divider. And when the GPIOs toggle they flip the potential across the buzzer, causing it to make human-audible sound. Brilliant!

Check out [Bruno]’s video demo after the break to get a sense for how the device works. You might be able to do this same trick with other components, but we’re willing to be that you won’t beat the parts count.

15 thoughts on “PIC Powered PicoBat Picks Up Pulsed Power

  1. If he had used a 4013 and added a diode and a cap he could have harvested the required energy from the piezo, done away with the battery or power supply and entered it for a hackaday prize.

  2. Very nicely done! I think the frequency division is even more than 1/4, when flipping a pin you need two flips to count as a full wave, and the main loop consists of 4 to 5 instructions, maybe more. It would probably take 10 instructions for a full wave, and 40 clock cycles. From 20kHz-100kHz down to 0.5kHz-2.5kHz.

  3. Does this actually work to detect any bats? Those piezo transducers behave like a very narrow-band filters and they are typically tuned to resonate at either ~20kHz or around 40kHz. From my quick testing a typical transducer like you could find in a cheap distance sensor or car parking sensor has a passband of only few hundred Hz around the center frequency, then the signal is very strongly attenuated.

    While the circuit is a neat hack and it may pick-up wideband noise like those keys or strong signals from similar transducers it likely won’t pick up any bats which emit their “clicks” at higher frequencies. Bat detectors use microphones not these narrow-band piezzos for this reason.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.