The Sound (and Sight) of Music! Teaching Electronics with the STM32 Nucleo
By Michael Parks, P.E., Mouser Electronics
Licensed under CC BY-SA 4.0
Overview
Striving for simplicity, the circuit is very straightforward. We are taking audio from a computer or mobile device via its 3.5mm audio jack and splitting left and right audio channel so we can tweak each channel individually based on our preferences. Line level audio is very low voltage and not suitable to drive our LEDs or the Nucleo directly. That is why we are taking the audio and running it through an operational amplifier, often shortened to just “op amp”. Actually, if you look carefully at the schematic (located in the Resources Section) you will notice that each channel signal is run through two op amps. The first op amp provides amplification and the second op amp provides buffering.
Op amps are one of the workhorse components of circuit design. They can be used in wonderfully simple but also incredibly complex ways. Learning op amps is a key skill. For this project we are using the op amp in a configuration known as a “non-inverting “amplifier”. The alternative is an “inverting amplifier”. To understand the difference let’s take a quick look at the parts of analog signal.
Figure 5: Parts of an analog signal.
In a non-inverting amplifier the output will remain in phase with the input signal, in an inverting amplifier the output is 180-degrees out of phase. If you look at the schematic you will notice that the output of the first op amps feeds back into the inverting terminal via a small network of resistors. The arrangement of resistors is known as a voltage divider circuit. It allows us to control the amount of amplification or gain the op amp will perform on the input signal. Using a fixed resistor and variable resistor (the one we’re using is referred to as a trimming potentiometer or trimpot for short) will allow us to manually control the gain. By turning the trimpot we vary its resistance, and in turn the gain of the op amp which will cause the LEDs to glow more brightly or more dimly depending on how it’s adjusted.
Figure 6: Non-inverting op amp signal.
Figure 7: Inverting op amp signal.
At the output of the second op amp we are using a resistor and capacitor in parallel to create a high pass noise filter to get rid of any RF noise the circuit might pick up. Lastly the LED and resistor in series are there to provide the light show. The LED is obviously doing the blinking and the resistor provide current protection for the diode.
Lastly, some notes about 3.5mm Tip-Ring-Sleeve audio jacks. The signal ground is commonly found on the outermost conductor, which is called a sleeve. The left channel is typically on the tip, and the right channel is sent out over the ring (Think “R” for right and ring).
Figure 8: A 3.5mm Tip-Ring-Sleeve audio jack diagram (left), schematic of the jack (middle), and PC speaker input (right) to play the music using built-in PC speakers if you don’t have portable speakers. Audio jack part number: 172-2208 or 172-8362-E.
We would love to hear what you think about this project; please tell us in the comments section below.