When I started the Rockit 8 Bit Synth design, I thought that I could implement a voltage-controlled amplifier, VCA, in 8 Bit land, saving precious hardware and everything would be easy. Well, as with many of the other things that I learned in the process of developing this project, reality would not be so kind. In this post, I’ll explain why that doesn’t work and then fill you in on how you can implement a functional Voltage-Controlled Amplifier using some fairly simple hardware.
What is a voltage-controlled amplifier?
valium 10Like it’s name suggests, it is an amplifier whose amplification, or gain, is controlled by a voltage. By varying a voltage input, we can change the amplitude of a signal, making it quieter and louder by supplying a smaller or larger voltage as a control signal. Technically, they are usually current-controlled, but when you put a current through an element like a resistor you convert a current to a voltage. The people who first made one decided to call it a voltage-controlled amplifier, so we honor them by sticking with their name.
The Problem with an 8-Bit Digital VCA
Let’s discuss the problem I encountered that led me to learning about VCAs. Hopefully, you’re familiar with the concept of bit depth, that is the number of bits used by the system to represent numbers. In my case, the bit depth is 8, meaning numbers, particularly, the audio output level are represented by 8 digit binary numbers. With 8 digits, we can represent 2^8 = 256 different numbers. In the digital world, 0 is the starting point, so the largest number we can have is 255. With digital amplitude scaling, meaning changing the amplitude of a signal, we are just multiplying the signal by a fraction. For example, if the signal is a simple square wave with amplitude of 255, a signal that is 1, half the time, and 0, the other half of the time, and we want to scale it to half of the output amplitude, we multiply the signal by 127/255 and you end up with a signal that is 127, half the time, and 0, half the time. Well, that can work to some end, particularly for square waves ,which are easy to scale. But, what happens when you have a sine wave that isn’t just two numbers but can be any number in between? Well, when you perform the same scaling you effectively end up with a 7 bit sine wave. See, instead of representing a sine wave with numbers from 0 to 255, we only have from 0 to 127. A 7 bit sin wave actually doesn’t sound miserably unlike an 8 bit sound wave but it’s incrementally noisier. What if we want to make a really small sin wave? Well, the smaller you go, the smaller the effective bit rate until you end up with a signal which sounds nothing like a sin wave. It sounds particularly terrible if you try to make a VCA which has to go from really small to full size over time. As it progresses from tiny to full-scale, you get all sorts of artifacts which are incredibly disconcerting. Believe me, I tried it. This option would certainly work much better in a 16, 24, or 32 bit system, but in the 8 bit world, we’ve got to find another way.
Off the Shelf Solutions
If you’ve got the money, you can buy a VCA in a chip and it will perform generally better than anything you could build yourself. But, what would be the fun in that? If you decided to go the easy way, you could get a DBX2150 or one of it’s modern equivalents, like the THAT 2181, or 2002. These chips are not cheap, $3.00-$5.00 per. These chips are what you’ll find in mixers tied to the faders and a large component of a large mixer’s cost.
DIY JFET VCA
One option to build your own is a JFET, junction field effect transistor, based voltage-controlled amplifier. A JFET can function like a variable resistor. With a p-channel JFET, you apply a positive voltage to turn it off. Incrementally lower voltages turn the JFET on more, lowering it’s resistance. You can think of applied voltages as blocking current flow through the device. This being the case, you can use it in the bottom of a voltage divider, like so:cheap adderall
buy clomidHigher voltages closer to the JFET pinch-off result in higher resistances which yield minimum attenuation. Lower applied voltages yield lower resistances which yield greater attenuation.
If this circuit worked ideally, we would be in business. Unfortunately, there are a few spoilers. The control relationship between applied voltage and resistance is sadly non-linear. If we sweep the control voltage from high to low, the attenuation changes very little for a large part of the range and then at the end falls suddenly. The other big problem, for me at least, is variability from JFET to JFET. The problem is so bad that JFETs are specified with wide ranges of pinch-off voltages rather than a nice specific number with a little tolerance.
There are some things that can be done to address this issue. You can apply logarithmic voltages to work out some of the non-linearity. 8 bits makes generating smooth logarithmci voltage beyond tough. A common solution is to add half of the drain-source voltage back to the gate. This has a linearizing effect. Introducing an op amp or two for the output and the feedback of the voltage is a traditional practice commonly found in guitar pedals with gain controls. For me, the variability from piece to piece is too much and I learned about a better way.
Operational Transconductance Amplifier VCA
The answer to my VCA problem is the operational transconductance amplifier, or OTA. There are many uses for an OTA and a pretty good VCA is one of them. I’ve learned some things about how to operate it though and I’ll pass my lessons on to you.
Op Amps without feedback, or open loop, have very high gain, often 100,000 and up. In this circuit, the OTA has no feedback path, so it has very high gain potential. But unlike other op amps, the OTA has an input which allows us to limit the gain. If you look at the guts of the op amp, you’ll see the “Amp Bias Input” which is a current input. We can basically starve or saturate this input with current which is a current mirror for the op amp input. This current will be exactly the current available to the input stage of the op amp. More current means more gain and less current less gain. One thing to note is that the voltage on the bias input needs to be at least twice the base-emitter turn-on voltage, meaning a voltage at least around 1.2-1.3V. Below this voltage, the OTA will output nothing because the transistors will be off and zero current will be available to the input stage to amplify the signal.
The other consideration with the high gain is that the input needs to be very small, less than about 5mV. You’ll notice in my schematic that the voltage divider on the input reduces a 5V peak signal down to a 5mV peak signal. You can exceed this voltage but you’ll encounter gain non-linearity meaning the gain will no longer increase and decrease linearly with increases and decreases in input signal level.
The control signal is a filtered PWM signal going into R36. By supplying a range of duty cycles, we generate the control voltage which is then turned into a current by R35. Increasing and decreasing the value of R35 will have a dramatic effect on the output signal level. This value can be determined experimentally by messing around measuring inputs and outputs which is what I did, or it can be calculated roughly with the formula for the gain which is:
A = Vout/Vin = (Voltage Divided Input)*19.2*Ibias*Rload
and Ibias will be equal to:
(Vcontrol – 1.2V)/R35
This is a very rough calculation because the 1.2V is not really accurate as the base emitter input voltage could be higher. The gain formula isn’t perfect either. It gets your values in the ballpark, but you’ll have to experiment to get it just where you need it.
Op Amp Output
The output of the OTA is a very small current. The maximum current output is down in the microamps. In order to make this useful, we’ll have to use a resistor, Rl, to convert it to a voltage. At the same time, we obviously can’t load down this output because any load will dramatically effect the voltage because no current is available. You’ll notice that the OTA has a built in Darlington pair transistor on the chip.
As shown in this manufacturer image, the darlington pair can be used on the output as a buffer. The darlington pair will supply the necessary current for the next stage in the signal path, sparing the OTA the load.
In my case, I can’t use the darlington buffer because of the limit it imposes on the voltage rails. The darlington pair will have a minimum voltage drop across it of 1.0V meaning that’s as close as the signal can get to the maximum circuit supply voltage before it distorts. My maximum supply voltage is 5.0V, so that would eliminate 20% of my operating range. Unacceptable.
Op Amp Buffer
The solution is use an rail-to-rail op amp as a unity gain buffer. This reduces the upper limit on the output voltage and we can get pretty close to full swing output capability.
This voltage-controlled amplifier is fully functional and tested. Things that can force changes to this circuit are many, but are mostly limited to larger and smaller input signals and higher or lower supply voltage ranges. In order to make it useful, you still have to supply the control signal with signals which allow the voltage gain to change over time. I’ll present my code for an amplitude envelope generator some other day. Cheers and happy hacking!