![]() I’ve labeled it as 100 Ohm, but anything from 100 Ohm to 200 Ohm works well, and you may prefer something different depending on the volume level you need. A resistor has been added to each of the speaker outputs. Now that we have an output that is too loud, but we can limit it using one more trick. This creates an audio output from the amplifier that is incredibly loud. To use this to our advantage, we start by increasing the operating system volume to the maximum 100% volume. The noise on the PWM line is constant, and it doesn’t increase as you increase the volume of the operating system. There is a pretty simple method we can use to minimize it though. There is some unwanted noise on the PWM line, even when using the filter, and the amplifier amplifies this noise as well. The PWM audio is good, but it does have one drawback. There is one final detail related to the hardware that needs to be covered. The orange and blue pads on the right are the audio output leading to the speakers. Between them is a shared ground input, which can be any of the grounds on the Pi. The red pad is the 5v power input, which should come directly from the Pi’s power source. The yellow L and R pads on the amplifier are the positive left and right PWM audio inputs. ![]() It works from the same 5v that powers the Pi, and has the perfect design for PWM audio. This amplifier is perfect for the Raspberry Pi. We need an amplifier if we plan to do that. This is plenty if you only need to power headphones, but it really isn’t enough to power speakers. The audio coming from the PWM is very weak, and it’s made weaker by passing it through the filter. Again, this can be any GND connection from the Pi. Connect the filtered audio to the positive side of the speaker, and connect GND to the negative side. Once the left and right channel filters are built, you will have working audio. Instead of connecting to GPIO pin 13, the left channel starts from GPIO pin 18. ![]() That completes the right side, and now we have to do the same for the left side. The capacitor is now positioned before the resistor. Here is the modified schematic that makes this a correct high-pass filter. You might notice that the capacitor in this filter is positioned before the resistor, so that’s exactly what we are going to do with our’s. The low frequencies are now filtered out. Our’s consists of a 10uF Capacitor connected in line, followed by a 150 Ohm Resistor connected to ground. Moving further into the circuit, we get to the high-pass filter. The high frequencies are now filtered out. The ground is any negative pin or connection on the Pi Zero. Our’s consists of a 270 Ohm Resistor connected in line, followed by a 33nF Capacitor connected to ground. Here is a Low-Pass Filter (link to Wikipedia) for visualization. We immediately get to the first part of the circuit, which is the low-pass filter. Now we know that PWM0_OUT is coming from GPIO pin 13, so let’s move further into the schematic. Since I’m showing the right side only, let’s say that this is coming from GPIO pin 13. The PWM0_OUT is the unfiltered audio signal, and this comes directly from GPIO pin 13 or GPIO pin 18 (one for left audio and one for right audio). The schematic above shows both PWM audio channels, so let’s trim everything down and look at just one of them. ![]() The filters in the original Raspberry Pi did the exact same thing. The LPF (low-pass filter) is doing the same for frequencies above 5kHz. The HPF (high-pass filter) in this image is removing most of the frequencies under 100Hz. The Pass Band is the range of frequencies you want to reach your speaker, and you want everything else removed. Here is an image to help visualize the process. A low-pass filter removes high frequencies, and a high-pass filter removes low frequencies. To assist with removing these noises, this audio filter circuit was added to the original Raspberry Pi.Īn audio filter serves to remove unwanted frequencies. The low notes are too low and cause the speaker to rumble and sound blown, and the high notes have lots of unwanted noise. The problem is that the audio is badly distorted. The Raspberry Pi is able to create audio using a pair of GPIO pins. There is also I2S over GPIO, but that requires some software tweaks that make it a little more complicated (a guide is coming for it later this year) There is a another option, and this guide explains the the process of getting PWM audio working. That works fine, but takes up the only available USB port unless you have room in your project for a microUSB hub. The next option is to use a USB audio adapter. The easiest is just to use an HDMI display, but that’s not always an option. There are a few ways to get audio from the Pi Zero.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |