Audio hardware on Pokitto, full explanation

#Digital audio generation and amplification in Pokitto
A small theory lesson turning into a massive explanation :wink:


Electric current can be comparent to water running in a pipe.

Current: Lots of water = lots of current

Voltage: High drop of height = high potential voltage difference, i.e. voltage=pressure

Resistance: Very thin pipe = high electric resistance


To turn digital signals to analog audio (DAC = digital-to-analog) Pokitto has a circuit called a resistor-ladder DAC. You can find a very good explanation of how to build one here and a more theoretical explanation with mathematics here.

The resistor ladder is a very simple way of taking 8-bits of signal and turn it into one contiguous analog signal.

However, you can not plug a speaker directly into a resistor-ladder DAC. This is because if you put an electrical load such as a speaker directly in series with a DAC, the voltage will collapse and you will get no signal out. Why? Because of a phenomenon called impedance


Remember we compared electric current to water flowing in a pipe? Now think about a ball attached to the end of a water pipe. Higher pressure inside the pipe will make the ball expand. If the pressure decreases, the ball contracts. This is exactly the idea of how a speaker works: changes in electrical “pressure” pushes and pulls the membrane of the speaker, that in turn pushes and pulls air in front of it. Our ears detect these localized pressure variations as sound.

Continue to think about this idea of voltage as “pressure” inside a water pipe.

What the resistor-ladder DAC does is that it takes a number (a byte, meaning 8 bits, with a value from 0 to 255) and turns that into a voltage. Most significant bit (bit 8) changes the voltage by a factor of 2 to the power of 7 (=128). Least significant bit (bit 1) changes the voltage by a factor of 2 to the power of 0 (=1). This means that the voltage change caused by bit 8 is 128 times bigger than bit 1.

Now, lets come back to the voltage=pressure analogy. For sound, small nuances are important. Small changes in voltage are small changes in speaker pressure. If you lose the small pressure changes, you lose the detail of what you are supposed to hear. Think about a car in a distance, driven by teenagers listening to eurodance/edm music. The only thing you are able to hear is the high-power “thump thump thump” of the bass. This is a music signal minus the lower pressure detail.

As we said earlier, the smallest change driven by bit 1 in the output of the DAC is only 1/128 part of the biggest change, driven by bit 8. If only bit 8 is on, output voltage might be for example 1.28V. If, in addition, bit 0 is on, the output voltage of the DAC would be 1.29V. As you can see, the difference would be very small.

What would happen to this tiny “pressure difference” if we attached a big big pipe to the system? A pipe that is able to carry thousands of times more water than the system is able to supply?

The answer is the current would flow right out of the system with no resistance at all. Pressure within the system would collapse, because the amount of water wouldn’t be enough to even fill the pipe to its limits.

This is the reason why we can’t just slap a speaker on the DAC. The electrical load would just “suck up” the entire supply of current, pressure (ie voltage) differences would disappear and we would have just a flat flow of current through the dac. We would have no voltage changes and no pressure differences. In other words, we would have no sound.

Continuing with the water pipe analogy:

Big fat pipe with lots of water going through with small pressure changes = low impedance

Tiny pipe with tiny amount of water going through with crazy high pressure changes = high impedance


Ok, so we’ve explained that the DAC generates voltage differences and that we want to keep even the tiny detail of these “electrical pressure” variations. And, as was just explained, if we slap a big pipe on the system (such as a speaker), it will suck up all the current and there won’t be any pressure differences to detect. So what to do? How can we save the tiny voltage changes and drive a speaker at the same time?

The trick is that we do not drive the speaker directly but indirectly from an operational amplifier aka “op amp”.

Buffering Op Amp

The buffering op amp is just a chip made of silicon semiconductors like all other chips. But, the op amp has a funny habit that can be used in many useful ways.

The op amp has 2 inputs called the inverting input (-) and the non-inverting input (+). It also has an output.

Now, the funny habit of the op amp is that it totally over-reacts to any kind of inequality. It’s a real justice warrior. If it sees any difference in what the inputs are getting, the op amp will try to output anything to correct the injustice. If the (+) input is getting 0.01V more than the (-) input, the op amp reacts by outputting almost infinite volts plus. And vice versa. Yep. You heard that right - infinte volts. The op amp goes absolutely ballistic over any difference in the service its precious inputs are getting.

This hot-headed nature of the op amp can be used for many things by connecting the output of the op amp back to its inputs. This is called feedback. In the picture above, the output of the op amp is connected back to its inverting input. If the op amp sees, that (+) is getting 1V and (-) is getting 0V, it will very quickly start pushing out higher and higher positive voltage. As this output is fed back to (-) input, the input will quickly reach the same 1V level as the (+) input. As soon as both inputs are back at the same voltage level, the op amp is satisfied.

Let’s say we connect the ouput voltage of the Pokitto DAC to the (+) input of an op amp as shown above. What will happen?

The signal coming from the DAC is a voltage varying between 0V … 3.3V. If that signal is fed into the + input of the buffering op amp, the op amp will output the same voltage on its own output, because, due to the feedback loop, this is what will drive the - terminal to the same potential.

… continued soon …


Nice write up! When I think of the question why the DAC doesn’t drive a speaker directly, I think in terms of circuits that provide precise signal levels and circuits that do work. When the DAC is plumbed into an amplifier section, the carefully constructed waveform from the DAC feeds the “aggressive” amp which will switch and shape the larger electron flows that will do the work of driving the speaker.

Yes, I am just about to come to that in the next instalment.

It took me a long time to wrap my head around the low impedance and high impedance node concepts.

In fact, it was only when I started to study hydraulics that I really “got it” the first time. The analogy of fluid flow to electrons is actually pretty complete. Some say that inductance is not part of the analogy, but I think of inductance (energy stored as a a magnetic field in a coil) as a turbine wheel that has initial resistance to flow due to angular inertia. The resistance decreases as the wheel accelerates. The turbine wheel has residual angular kinetic energy that keeps the pressure in the system after the flow decreases. This also explains the oscillation of circuits in a handy way.

Naturally, mechanical models can not explain the quantum phenomenon exhibited by electrons.

1 Like