# Logarithmic volume control

In the last article, I remembered my old design: an audio DAC, in which I talked about a not very standard sound card, and introduced those who did not know the main parameters of the DAC. I thought it would be logical to talk about the logarithmic volume control with a display, which I developed at about the same time and for the same company.

As always, at the beginning a little educational program.

What is it, what is it used for, why develop it, is it possible to buy ready-made and do nothing (as some people like)? I will answer the first questions and the reader will answer the last one himself. But first you have to dig into physics, or even biology, I don’t know …

How do we hear?

A person perceives sound, or rather sound pressure, through the eardrum. Sound pressure is indicated on a logarithmic scale. Here’s even a GOST for this https://docs.cntd.ru/document/1200143230 and a picture from there:

It turns out that we do not have a linear perception of sound, but a logarithmic one. Never think about whether this is good or bad, you just need to take it for granted.
It’s all about sound pressure. It turns out that the linear volume control (the amplitude of the output signal at the loudspeaker) will not be linear for our ear.

How to properly regulate?

But when adjusting the volume, I would like not to catch millimeters with a potentiometer at the beginning and not turn half a turn at the maximum. Then the logarithmic potentiometer will fix the whole thing. Its linear movement will change the volume for our ears in a proportional number of times.

By the way, sound potentiometers with a logarithmic characteristic have long been invented for this, they have the letter “A” in their name. I will give an example of a manufacturer beloved by many music lovers: https://tech.alpsalpine.com/e/products/detail/RK50114A0001/
The circuit is quite simple, just resistors of different denominations are connected in such a way as to form a divider:

In the last country (USSR), amplifiers were produced that had this kind of volume controls. For example, the Corvette amplifier:

And the amplifier “Idol”:

The latter, it seems, looks more technologically advanced and cooler, but from my observation, it began to crunch as the contacts and short circuits were erased when switching neighboring ones, which was not the case with the more bulky Corvette, made on output resistors and on a biscuit switch.

I think it is now clear what these kinds of volume controls are used for.

What is required from the block?

The order was something like this (I don’t remember everything because of the prescription of years):

1) The unit will be installed in various low frequency amplifiers (no housing required).
2) The unit must be powered by the power transformer of the amplifier, which has two secondary windings connected in series.
3) The unit must have a display to display the name of the company when turned on, indication of the MUTE mode, display of the output power level of the amplifier.
4) For adjustment, an encoder with a button should be used (it was chosen for me separately, since the smoothness of the move and the buttons was of great importance).
5) The block must have 80 adjustment steps.

There was something else but I can’t remember.

Block circuitry.
Now that the i’s have been dotted, to combat scheme!

To begin with, I chose relays that were suitable for the supply voltage in a fairly wide range, since the unit could be installed in different amplifiers with different voltages of the supply transformers. As well as those that could be easily ordered.
Next, I chose and coordinated the display. Here the choice fell on what was at hand and could be launched and shown how it works the next day. LCD1602 is old school, no I2C. He arranged everything with simplicity, but at the same time satisfied all the wishes.
Next, choose the appropriate controller.
After that, I calculated the maximum power consumption of the unit and drew a power diagram. As you can see, nothing particularly complicated or tricky. Cheap and not angry.

Power supply circuit:

Understanding what the “most difficult” device was to be made, one of the most common and cheap controllers was chosen, it seems that I still had it in some kind of excess at home … Accordingly, the next piece of the circuit was born from here.

Controller Power Scheme:

Further, I very simply understood how many pins of one port (for the convenience of managing registers directly) I need to implement 80 steps. Immediately occupied half of the port with them. Even stock turned out.
I put a display and an encoder on the pins convenient for tracing.
And just in case, he also laid quartz.

Controller pinout diagram:

The encoder can be connected in different ways. Who cares what, timers, interrupts, something else?
As for the resistors. You can use internal pull-ups, and it will work fine in most cases, but I like low-resistance and my own.

Encoder connection diagram:

But with the display a little more interesting, but not much. He would like 5V levels … + 5V pull-ups and tolerant pins. Here you can also add a trimmer to adjust the brightness.

Display connection diagram:

And my favorite connector for “sewing” with a little protection.

Programming connector diagram:

And the most important thing remains, for the sake of which it was all started. Attenuator. You can always choose the required value of resistors, which only now happens in the E192th row … Or you can assemble it from the standard row, which lies in the bedside table at hand. And so it happened. For correct operation, it is necessary to configure the port outputs with a pull-up to ground. This will protect against false positives, since I did not lay external resistors from the base to the ground.

The scheme of the regulator itself:

No one limited me in dimensions, but it makes no sense to make a very large board either. More fee – more price. Companion in length to the size of tightly installed relays. The encoder set the dimensions in width, without fitting on the relay.

TOP and BOTTOM boards:

And after a short period of time, a two-sided board turned out. The board is simple, according to the standard manufacturing class, 1.6mm thick. Since I forgot to make a zone without copper around the mounting holes, that is, a feature: it is worth fixing the board either with insulating washers or plastic racks, since with metal it is possible to short circuit the grounds and in some cases (not always) the formation of a ground loop and the appearance of induced 50Hz in speakers. Well, or if you are a pro and are able to correctly implement the wiring of the lands in the amplifier, then you can also mount it with metal. Who is in the subject – he understands.

Boards in 3D:

These boards were not urgent and they were ordered in China, it seems that pcbway was just appearing then.

Fees collected:

Commissioning and operation logic.

What do we do when the boards are collected? That’s right, we call the responsible circuits for the presence of a short circuit and, if everything is OK, we apply power and blink the LED. Since there are no LEDs on the board, the first step was to launch the display and write a kind of hello to the world (actually to a comrade).

By the way, if someone is not familiar with these displays:
1) they come in different colors,
2) there are different libs for them,
3) available with support for different characters,
4) you can connect 4 or 8 bits, now there is already an I2C bus,
6) low price.

What the display looks like:

Well, in the end I implemented the work of an encoder, a regulator, and some button functions.

How the regulator works. Everything is quite simple!
1) Including 1 relay – it turns out 1db of signal attenuation.
2) The second relay turns on and the first one turns off – we get 2dB attenuation.
3) We turn on the first relay, but do not turn off the second – we get 3dB attenuation.
4) Turn on 3 relays, turn off the first two – we get 4dB attenuation.
Then we add the first to it, then the second without the first, then the first to them again, and so on… You can list 128 times (or 127, if zero is in the case 😊).

The photo shows the debugging process.

Generally speaking, if it weren’t for the display, with what pleasure I would implement it on logic (counter, registers, timer …), but the output of information to the logic on the display, sorry, but for me it’s too much …

I also met an interesting implementation of such a device, of course, also without a display, on the ADC. Like that:

The idea is quite simple: an 8-bit ADC with a parallel output is taken, a potentiometer (with a linear characteristic) is connected to its input. Relays are connected to 8 ADC outputs. And now the regulator is ready. But there is a nuance.

Many are always interested in the price of what happened. I can’t even imagine how much this device will cost now, the relays are good. Then it cost a penny. And against the general background of the amplifiers in which it was built in, it was at the price of hardware, as it seems to me.

I wonder if those who read the article have an amplifier with this block at home?