On my desk i have a headphone amplifier for my AKG K702’s headphones, below it i have my self built Onixia integrated amplifier for my bookshelf speakers. I have been thinking about making a global volume control for both devices for quite some time… here is the results of my efforts.
Although you may think a rotary encoder is just a rotary encoder, when selecting one for a specific purpose such as a volume knob, the feel and quality can play a large part in your design decision. You only have to look at the vast part numbers in any given range to appreciate this. The different manufacturers cater for detent or no detent, the number of detents or the amount of pulses. Even how much torque it takes to either turn the shaft or depress it for the shaft button. Where quality is concerned, this is really down to build and electrical contact quality and how much de bouncing you will end up doing in your design. It really can be a minefield…
On my first prototype PCB, I initially mounted a cheap Chinese rotary encoder. Following some hardware de bouncing, using capacitors, it was fine for most tasks. However, I always got the feeling there were missed steps on the audio volume scale. I did not go into much testing of the Chinese encoder as I soon switched to a Bourns PEC11 rotary encoder, after installing the Bourne’s encoder. I noticed the volume scale to be much smoother than before, but with a tiny amount of what felt like lag when rotating quickly. After more experimentation, by rotating the shaft very quickly, the volume scale would shoot to 100% as if by itself!
After some thought, it occurred to me that in order to reach 100% volume scale it took 2 full rotations of the shaft. The perceived lag, at speed, was actually the Microcontroller just catching up! This in turn meant that it was also counting every single step from the encoder, whereas, the cheaper quality encoder halted the scale quicker through missing steps.
Update to the lag issue:
After further investigation it turns out that the lag was actually caused by Microsoft IntelliType Pro keyboard software. I was initially using the Microsoft keyboard software for the volume scale overlay, but after uninstalling the software the global lag was no longer present!
I will touch on the phenomenon of de bouncing for the layman, this usually occurs with mechanical switches. If you imagine you have a simple circuit with a battery, an on/off switch and a light bulb… you press the switch and the light bulb turns on. This could be described as a simple analog interaction. Now if you imagine a switch with dirty contact points, and the contacts arc, the light bulb will flicker a lot due to being turned on and off many times a second similar to a bad connection on a plug.
This can be used to explain how a microcontroller sees the physical world, especially concerning 2 pieces of metal touching each other in an imprecise way, as in the case of a mechanical switch. This is a concern as the Microcontroller will sense the switch thousands of times a second for a change in state, usually High (1) or Low (0) e.g. on/off .
Read More: Attiny2313 & Attiny84 V-USB Media Volume Control