Skip to content

Commit 35ad4cc

Browse files
committed
We still depend on the body diode voltage drop, of course.
Also, some small corrections and additions to the readme.
1 parent c336998 commit 35ad4cc

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

Readme.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Very low part count audio compressor based on Arduino
22

3-
This project aims to provide a simple to build audio-compressor based on an arduino / genuino.
3+
This project aims to provide a simple to build audio-compressor based on an Arduino / Genuino.
4+
5+
Note that we are assuming an **ATMega328 or ATMega168** based board, here (such as Arduino Uno, Nano, or Pro Mini),
6+
running at **16 MHz** and **5V**. Circuit and code can clearly be adjusted to other boards, but you'll have to do that, yourself.
47

58
## A small bit of theory
69

@@ -19,7 +22,7 @@ Sounds like a perfect job for a microcontroller, right?
1922
Beyond the logic and timing, however, there are two main technical difficulties: First, we need to sense the signal level to work on. Ok, not terribly difficult,
2023
but does require some tricks to achieve with an acceptable sampling rate on a microcontroller. Second, we need to modify (or output) the signal, accordingly. Typical
2124
approaches involve voltage controlled amplifiers (VCAs), J-FETs, or some other technique to transform a voltage signal into a variable resistance. Well-established,
22-
but not quite trivial, if you read up on it. Instead of these, I decided to capitalize on the main advantage of a microprocessor: Doing simple things _fast_. In this
25+
but not quite trivial, if you read up on it. Instead of these, I decided to capitalize on the main advantage of a microprocessor: Doing simple digital things _fast_. In this
2326
case this means switch the audio signal on and off at a rate much higher than audible sounds, in order to achieve a variable resistance very easily.
2427

2528
## A first basic version
@@ -42,7 +45,8 @@ the Arduino to detect the current signal level, and - remember - low signal leve
4245
The more interesting part of the circuit is the upper half. Two N-FETs are connected back to back (drain of the first connected to source of the second and vice versa), which are both controlled
4346
synchronously from Arduino pin D3. These two FETs simply function as a _simple_ analog switch. The good news is that you are pretty likely to have those N-FETs in your part-collection already:
4447
A pair of 2N7000 or any other common small signal N-FET will do ok. Importantly, the FET should be _far_ inside the on-region at 4-5 Volts. Also, of course, if should be able to handle whatever current
45-
will be flowing. A somewhat better choice than 2N7000 would be IRLML2502, and an even better choice will be to use a dedicated analog switch (in this particular schematic
48+
will be flowing. However, also, it should have a rather high bdoy diode forward voltage drop, as that will limit how large voltages we can switch off, reliably.
49+
A somewhat better choice than the 2N7000 would be the IRLML2502, and an even better choice will be to use a dedicated analog switch (in this particular schematic
4650
you'd want one supporting negative voltage swings!), but again, the 2N7000 will perform ok-ish, and is enough for connecting a headphone, so try that, first. Also, again, the exact resistor values will
4751
not matter. The 220 Ohms is for limiting the gate (dis-)charge current, to what the Arduino can safely handle. The 470 Ohms is to provide a bit of isolation from noise in the power supply.
4852

@@ -82,6 +86,6 @@ Ok, so how to get started?
8286

8387
## Footnotes
8488

85-
[1] Originally, I was switch the audio signal line, instead of audio ground. Switching on the ground connection has two advantages: First, the N-FETs gate-to-source potential will be independent of the
89+
[1] Originally, I was switching the audio signal line, instead of audio ground. Switching on the ground connection has two advantages: First, the N-FETs gate-to-source potential will be (mostly) independent of the
8690
current signal level, allowing for more linearity. Second, this way subject to some caveats you can switch on and off a stereo signal with a single N-FET pair (but alternatively, connect a second pair in parallel,
8791
also connected to pin D3). Of course, if your next stage is e.g. a high impedance amp, rather than a speaker coil, you should bias "Audio Ground Out" to ground via a largish resistor (some k Ohms).

compressor.ino

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ const int duty_min = 10; // ceiling value for attenuation (lower values = more
3939
const int duty_warn = 2 * duty_min; // See above. At attenuation beyond this (i.e. smaller numbers), warning LED will flash.
4040
// Reaching this point on occasion is quite benign. Reaching this point much of the time means too strong
4141
// signal, too low threshold setting, or too aggressive inv_ratio.
42-
const int signal_warn = 500; // A warning LED will flash for signals exceeding this amplitude (5mv per unit, peak-to-peak) as
43-
// it is probably (almost) too much for the circuit too handle (default value corresponds to about +-1250mV
44-
// in order to stay below the 1.7V signal swing (centered at 3.3V) that the Arduino can handle.
42+
const int signal_warn = 300; // A warning LED will flash for signals exceeding this amplitude (5mv per unit, peak-to-peak) as
43+
// it is probably (almost) too much for the circuit too handle (default value corresponds to about +-750mV
44+
// in order to stay below the .8V typical 2N7000 body diode forward voltage, as well as below
45+
// the 1.7V signal swing (centered at 3.3V) that the Arduino can handle).
4546

4647
//// Adjustable pin assignments
4748
const int pin_led_warn = 13;

0 commit comments

Comments
 (0)