You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Readme.md
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,9 @@
1
1
# Very low part count audio compressor based on Arduino
2
2
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.
4
7
5
8
## A small bit of theory
6
9
@@ -19,7 +22,7 @@ Sounds like a perfect job for a microcontroller, right?
19
22
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,
20
23
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
21
24
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
23
26
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.
24
27
25
28
## A first basic version
@@ -42,7 +45,8 @@ the Arduino to detect the current signal level, and - remember - low signal leve
42
45
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
43
46
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:
44
47
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
46
50
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
47
51
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.
48
52
@@ -82,6 +86,6 @@ Ok, so how to get started?
82
86
83
87
## Footnotes
84
88
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
86
90
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,
87
91
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).
0 commit comments