After having lots of fun with the breadboard version of my Teensy Hearing Aid, I decided that it was much too bulky and fragile to be of much use. So, with some help, we designed and built or own custom audio interface for the Teensy 3.6. This new audio interface would take all of the elements of my breadboard system and bring them together into one unified board. Stick a Teensy 3.6 on top and it's good to go!
As you can see, it's a lot smaller than my breadboard system. Most importantly, there are no loose wires flying around to get caught on things or to pick up noise. It's much more robust, thereby enabling you to be mobile. And being mobile is the best way to trying out your new audio processing algorithms. Being mobile is where things get fun.
On of my favorite features is that the board has two tiny little microphones built into the board itself. So, for quick trials, all you need to do is plug in some headphones and you're ready-to-go. I even put a hole in the PCB so that you can clip in a lanyard thing and wear it around the neck. Sure, it's pretty nerdy to have raw, unenclosed electronics dangling around one's neck but, hey, I'm not afraid to show my geek pride.
When our new board is combined with the built-in capabilities of the Teensy, you've got a nice and compact little system for developing new audio processing algorithms. It's got a lot of really useful features!
Now that I've got this cool little piece of hardware, I've got some colleagues who are going to start working with it, too. As more folks work with it, we figured that it needed a name. After trying out a bunch of names on friends, colleagues, and in the open-source community (and seeing what was available for handles at sites like GitHub), we chose the name Tympan. As an open-source hearing aid device, that name seems pretty decent to me!
Follow-Up: If you're interested in the schematic and BOM, we've put them on Tympan's GitHub. The original "Rev A" design is here. The first hardware that is for sale ("Rev C") is here.
Follow-Up: I measured the self-noise and dynamic range of the Tympan board. It's pretty good! You can check it out here.
Follow-Up: We designed an enclosure for the Tympan. You can check it out here.
Showing posts with label Hearing Aid. Show all posts
Showing posts with label Hearing Aid. Show all posts
Friday, March 3, 2017
Saturday, November 26, 2016
Reducing Current Draw
My previous post introduced my Teensy-based hearing aid. While my primary goal was to make a platform for developing audio processing algorithms, I am interested in exploring its performance as an actual hearing assistive device. From this viewpoint, battery life is important. In assembling my device, however, I gave no thought to minimizing power consumption. Does it draw too much current? Will it have a usable battery life? Let's find out!
Initial Measurements: With my baseline Teensy Hearing Aid, I measuring the current being drawn from the battery during normal operation. At this early stage of development, the Teensy isn't doing very much -- it is simply applying digital gain to the audio stream. Because it is doing so little, I am hoping that we'll see the lowest power consumption. My results are below. Note that I measured the power consumption across a range of processor speeds. You can set the speed of the processor via the Arduino IDE when you compile the sketch.
That's A Lot of Current! I was surprised to find that at its normal speed (180 MHz) the system was drawing almost 91 mA of current. That's a lot of current. My battery has a capacity of 350 mA-hours, so my battery life will only be about (350 mA-hrs / 91 mA) = 3.8 hours. For a "hearing aid", this is pretty short. Yes, I could slow down the processor to reduce my power consumption, but this is an inelegant solution that requires me (the programmer) to ensure that my software will always live happily within the limits of the slower speed. I'd prefer a more dynamic approach, where the code itself will switch between low-power and high-performance modes as the workload demands. I don't know how to do that.
Sleep During Idle: Luckily, I have a friend who is experienced with low power embedded systems. He suggested that I could save a lot of power by putting the processor to sleep during idle periods. Knowing that I'm working with an ARM processor (the heart of the Teensy board), he suggested that I insert the ARM-specific command asm(" WFI") into my main loop (yes, you do need the space before the W). When the processor hits this command, it'll go to sleep and consume less power. It'll stay asleep and "Wait For Interrupt" (hence "WFI") before waking to resume its work.
Wait for Interrupt: Since I don't want it to sleep forever, I need to make sure that there is an interrupt (such as a timer) that'll wake the system periodically so that it can do its work. As I don't know how to do this, I have a problem. Luckily, I know that the Teensy Audio Library already uses interrupts to do its work. I know that it fires at least one interrupt every 128 audio samples. As any interrupt will trigger the WFI to wake up, I don't need to do anything more. I can just add the WFI command and rely upon the Audio Library to wake the system. The system will automatically go back and forth between sleep and wake. One line of code -- what a simple solution.
It Works! After adding the WFI command (my code is here), I measured the current draw again. The WFI command works! At the default speed of 180 MHz, the system now draws only 57 mA, instead of 91 mA as seen before. That's a 34 mA savings with no impact on system performance. Fantastic.
Battery Life: By adding the WFI command, power consumption has dropped to 2/3 of its original value. My system will now have 50% more battery life. Using my 350 mA-hr battery, I'll now get 6 hours of life instead of 4 hours. That's a great improvement for adding just a single line of code.
More Power Savings? While increasing my battery life by 50% is great, I went back to my friend asking if more savings could be had so easily. He said that I could save more power, but not nearly as easily. He said that the next step would be to identify and disable peripherals that I don't need. But, to do this, I'd have to read through and understand my processor's datasheet, which is not an easy task for a newbie such as myself. So, for now, I think that I'll be content with the easy savings provided by the WFI command.
For Fellow Nerds...My Raw Data: For anyone who is really interested, my raw data is in the table below (or here). It is interesting that, even at very slow processor speeds, I still see power savings when using the WFI command. Clearly, my "Gain Only" audio processing algorithm requires very little effort from the processor. That Teensy 3.6 sure is fast!
Initial Measurements: With my baseline Teensy Hearing Aid, I measuring the current being drawn from the battery during normal operation. At this early stage of development, the Teensy isn't doing very much -- it is simply applying digital gain to the audio stream. Because it is doing so little, I am hoping that we'll see the lowest power consumption. My results are below. Note that I measured the power consumption across a range of processor speeds. You can set the speed of the processor via the Arduino IDE when you compile the sketch.
Sleep During Idle: Luckily, I have a friend who is experienced with low power embedded systems. He suggested that I could save a lot of power by putting the processor to sleep during idle periods. Knowing that I'm working with an ARM processor (the heart of the Teensy board), he suggested that I insert the ARM-specific command asm(" WFI") into my main loop (yes, you do need the space before the W). When the processor hits this command, it'll go to sleep and consume less power. It'll stay asleep and "Wait For Interrupt" (hence "WFI") before waking to resume its work.
Wait for Interrupt: Since I don't want it to sleep forever, I need to make sure that there is an interrupt (such as a timer) that'll wake the system periodically so that it can do its work. As I don't know how to do this, I have a problem. Luckily, I know that the Teensy Audio Library already uses interrupts to do its work. I know that it fires at least one interrupt every 128 audio samples. As any interrupt will trigger the WFI to wake up, I don't need to do anything more. I can just add the WFI command and rely upon the Audio Library to wake the system. The system will automatically go back and forth between sleep and wake. One line of code -- what a simple solution.
It Works! After adding the WFI command (my code is here), I measured the current draw again. The WFI command works! At the default speed of 180 MHz, the system now draws only 57 mA, instead of 91 mA as seen before. That's a 34 mA savings with no impact on system performance. Fantastic.
Battery Life: By adding the WFI command, power consumption has dropped to 2/3 of its original value. My system will now have 50% more battery life. Using my 350 mA-hr battery, I'll now get 6 hours of life instead of 4 hours. That's a great improvement for adding just a single line of code.
More Power Savings? While increasing my battery life by 50% is great, I went back to my friend asking if more savings could be had so easily. He said that I could save more power, but not nearly as easily. He said that the next step would be to identify and disable peripherals that I don't need. But, to do this, I'd have to read through and understand my processor's datasheet, which is not an easy task for a newbie such as myself. So, for now, I think that I'll be content with the easy savings provided by the WFI command.
For Fellow Nerds...My Raw Data: For anyone who is really interested, my raw data is in the table below (or here). It is interesting that, even at very slow processor speeds, I still see power savings when using the WFI command. Clearly, my "Gain Only" audio processing algorithm requires very little effort from the processor. That Teensy 3.6 sure is fast!
Sunday, November 20, 2016
A Teensy Hearing Aid
Hearing aids are totally closed devices -- their inner workings are hidden. Access is limited to only those who work for the hearing aid companies. But if innovation is to accelerate, we need more ideas iterated more quickly. We need more people to participate in hearing aid development. But if the devices are closed, there is no way to try new ideas. So, let's consider the alternative. Let's try to build an open-source hearing aid. Yes, at first, an open-source hearing aid will be absurdly big and ugly. But, you have to start somewhere. I'm going to start here: take one Teensy microcontroller, add some supporting electronics, and VOILA! A Teensy Hearing Aid!
Basic Hearing Aid Elements: While it is unfortunate that they are closed devices, real hearing aids are absolutely amazing pieces of technology. Their minuscule packages are absolutely stuffed with functionality. I, though, am going to start more simply. I will start with some microphones, analog and digital converts, a digital audio processor, some speakers, and a battery. Once this works, I can always add more features later.
Choosing a Processor: For me, the biggest challenge is always with the software. Therefore, I need to choose a digital audio processor that it is easy to program. For me, that means choosing a processor that can be programmed from the hobbyist-friendly Arduino programming environment. Within that universe of processors, I've chosen to use the Teensy 3.6 because it's fast and because it has a nice audio processing library to make it even easier to program for audio.
Supporting Elements: To get audio signals into and out of the processor, the Teensy folks offer an inexpensive Audio Adapter Board that mates directly to the Teensy 3.6. It has the audio ADC and DAC that I need. For the microphones, I'm using a pair of mic breakout boards from Adafruit. For speakers, I'm using whatever headphones or earbuds that I might have on-hand. Finally, for the battery, I'm using a Li-Po battery and Li-Po charger from Adafruit.
Wiring It Up: The figure above gives an overview of how everything was connected together. As you can see, the Audio Board is at the center with everything else connecting to it. The only tricky part of this setup is connecting the battery and charger into the Teensy system. As indicated on the Teensy pinout diagram, you have to cut a trace on the backside of the Teensy so that you can insert the battery connections. Once cut, the Teensy's 5V USB voltage goes to the battery charger and the battery's output goes back to the Teensy's "5V" input pin. Not too bad.
Initial Software: While this post is primarily about the hardware, I did write some basic software in order to see if the hardware is working (see my GitHub repo). I used the Teensy Audio Library to configure the Audio Board to pass the "I2S" inputs (ie, my microphones) to the "I2S" outputs (ie, my headphones). In between, I wrote a simple routine that applies a user-controllable amount of gain to make things louder. I use the blue potentiometer on the Audio Board to set the amount of gain.
First Audio: Of course, the first time that I tried to compile the code, my software didn't work. Does anyone's code ever work the first time? After some iteration, I finally got it to compile and upload. Putting on my headphones, I could hear the audio being picked up by the microphones. Turning the blue pot, I could control its volume. Hardware knobs are so satisfying. My favorite part, though, is being able to use the on-board battery so that I can move around freely. Very fun.
Limitations: Sure, my home-brewed "hearing aid" is ridiculously large -- no one (including me) would ever wear this around in everyday life. But, unlike commercially-available hearing aids, my device is open. Anyone can modify it to make it better. Anyone can try out their own audio processing algorithms to try to improve one's hearing. Will any of us beat the professional hearing aid algorithm designers? Probably not. But, for me at least, I will surely learn a lot by trying a few of the standard approaches. And, I'll get to look really cool sharing pictures of myself with this (not so) Teensy Hearing Aid. Happy hacking!
Follow-Up: I measured the power consumption of my Teensy Hearing Aid. Using the "WFI" command, I found a super-easy way to increase the battery life by 50%. Wow! See my post here.
Follow-Up: I measured how the volume control affects the headphone ouput. See here.
Basic Hearing Aid Elements: While it is unfortunate that they are closed devices, real hearing aids are absolutely amazing pieces of technology. Their minuscule packages are absolutely stuffed with functionality. I, though, am going to start more simply. I will start with some microphones, analog and digital converts, a digital audio processor, some speakers, and a battery. Once this works, I can always add more features later.
Choosing a Processor: For me, the biggest challenge is always with the software. Therefore, I need to choose a digital audio processor that it is easy to program. For me, that means choosing a processor that can be programmed from the hobbyist-friendly Arduino programming environment. Within that universe of processors, I've chosen to use the Teensy 3.6 because it's fast and because it has a nice audio processing library to make it even easier to program for audio.
Supporting Elements: To get audio signals into and out of the processor, the Teensy folks offer an inexpensive Audio Adapter Board that mates directly to the Teensy 3.6. It has the audio ADC and DAC that I need. For the microphones, I'm using a pair of mic breakout boards from Adafruit. For speakers, I'm using whatever headphones or earbuds that I might have on-hand. Finally, for the battery, I'm using a Li-Po battery and Li-Po charger from Adafruit.
Wiring It Up: The figure above gives an overview of how everything was connected together. As you can see, the Audio Board is at the center with everything else connecting to it. The only tricky part of this setup is connecting the battery and charger into the Teensy system. As indicated on the Teensy pinout diagram, you have to cut a trace on the backside of the Teensy so that you can insert the battery connections. Once cut, the Teensy's 5V USB voltage goes to the battery charger and the battery's output goes back to the Teensy's "5V" input pin. Not too bad.
Initial Software: While this post is primarily about the hardware, I did write some basic software in order to see if the hardware is working (see my GitHub repo). I used the Teensy Audio Library to configure the Audio Board to pass the "I2S" inputs (ie, my microphones) to the "I2S" outputs (ie, my headphones). In between, I wrote a simple routine that applies a user-controllable amount of gain to make things louder. I use the blue potentiometer on the Audio Board to set the amount of gain.
First Audio: Of course, the first time that I tried to compile the code, my software didn't work. Does anyone's code ever work the first time? After some iteration, I finally got it to compile and upload. Putting on my headphones, I could hear the audio being picked up by the microphones. Turning the blue pot, I could control its volume. Hardware knobs are so satisfying. My favorite part, though, is being able to use the on-board battery so that I can move around freely. Very fun.
Limitations: Sure, my home-brewed "hearing aid" is ridiculously large -- no one (including me) would ever wear this around in everyday life. But, unlike commercially-available hearing aids, my device is open. Anyone can modify it to make it better. Anyone can try out their own audio processing algorithms to try to improve one's hearing. Will any of us beat the professional hearing aid algorithm designers? Probably not. But, for me at least, I will surely learn a lot by trying a few of the standard approaches. And, I'll get to look really cool sharing pictures of myself with this (not so) Teensy Hearing Aid. Happy hacking!
Follow-Up: I measured the power consumption of my Teensy Hearing Aid. Using the "WFI" command, I found a super-easy way to increase the battery life by 50%. Wow! See my post here.
Follow-Up: I measured how the volume control affects the headphone ouput. See here.
Subscribe to:
Posts (Atom)












