Arduino ADSR Digital Envelope Generator Module - Version 2
by baritonomarchetto in Circuits > Audio
3385 Views, 10 Favorites, 0 Comments
Arduino ADSR Digital Envelope Generator Module - Version 2
No more than two months ago I have published an Instructable on how to realize a simple but effective ADSR Digital Envelope Generator based on m0xpd's previous work.
In this time lapse I had the time to toy with it in my modular synthesizer, to develop new modules for it (see the list below) and even to laydown both blank and pre-drilled panels that helped a lot speeding up the module realization process.
Now that I have gained some more experience, It was the time to lay down a new version of the Envelope Generator, with some addition I am sure most of us will find useful.
In this instructables I will show you how to realize a simple Arduino based ADSR Envelope Generator. I will share with you both the code to upload into your arduino and the Gerber files to have the PCB manufactured by professionals at low cost.
Let's go!
Other Instructables in this series:
3340 Voltage Controlled Oscillator Module
Arduino Wavetable Voltage Controlled Oscillator
Voltage Controlled Multimode Resonant Filter
Discrete Voltage Controlled Amplifier
Arduino ADSR Digital Envelope Generator
Variable Waveshape Low Frequency Oscillator
DIY Linear Regulated Eurorack Power Supply (and Power Bus Bar)
Features
As said, this project is based on a previous work by m0xpd. You should take a look at his blog: it's full of useful informations and exciting projects!
This is not a mere copy of that, anyway, and I modified it towards my needs.
First of all, with respect to the m0xpd's original project, I made some pins swapping to have the shield compatible with a 492X DAC library so that we can change the envelope firmware with two different approaches: by modifying the original source code, or eventually relying on such library.
More interesting is the extention of envelope curves. The original project outputs a classic ADSR envelope, in two different modes: "normal" or looped (a.k.a. retrigger). In addition to this, since version 1 of this envelope generator I coded two new operation modes: a "biased semi-invertion" mode and a "biased quasi-invertion". These where my answers to the need of inverted envelopes at the time, but still a real invertion was lacking (and not possible without a hardware modification).
So, in this new version of ADSR envelope generator I have added this possibility.
In addition to this, the first version of this envelope generator was not a full module but a circuit. This time, instead, I also draw a dedicated faceplate to speed up the whole module realization.
Circuit: What's New
Apart from a noticeble layout change, this new version of the Envelope Generator module features two circuit improvements with respect to my first project version.
The first one relates to the digital nature of the envelope: output was in the range 0 to +5V, and a full invertion was not possible by only toying with the code.
This limit could only be overcome with an hardware modification. This is why I ended adding a simple circuit built around a common dual operational amplifier in inverter configuration (TL072).
In this configuration, the output is fed back to the inverting input through a resistor. The input signal is applied to the inverting pin through another resistor. The positive pin is connected to ground. The relationship between the two resistors determines the voltage gain. If, like in this case, they are the same value, the gain is unity and the amplifier configuration is called unity gain inverting circuit.
The second improvement concerns the voltage protection. The DAC cannot exceed it's own voltage so there's nothing to worry about, but what happens if you connect to it's output a negative voltage or a voltage higher than it's maximum rating (+5V)? Short answer: you will kill it. This is why we need a over/inverse voltage protection in a form or another.
Again, every time you connect the ADSR output to the input of another module, the ouptut is grounded for a short time. What if there's nothing limiting the current to ground?
The first version of this ADSR was passively protected agains inverse voltage and over voltage via a simple circuit made of two zener diodes and a series resistor for overcurrent protection.
In this case, being that I had one half of the operational amplifier unused, I could adapt at no cost an active measure against over/inverse voltage and overcurrent. The protection circuit is the first half of the attached schematics and is mainly built around a resistor in series to the output but still in the feedback loop.
Notice that those two non polarized capactiors are optional and you must use them only if the amp self oscillate.
Code and Envelope Modes
The original code is well documented both in m0xpd dedicated page but expecially in the sketch itself. It's verbose (in a good way!) and you should read it: it's great value.
In my fork, I kept additions as verbose as possible, just to simplify future mods.
You can get a classical inverted envelope directly from the inverted output of the module, but there are also two additional modes acting differently on the ADSR shape: a "biased semi-invertion" and a "biased quasi-invertion".
Biased semi-invertion
- Attack phase starts at maxium positive value (+5V) and goes down to "zero" according to user defined velocity
- Decay starts at zero and drives to sustain level (not an inverted sustain level!)
- Decay starts from sustain leven and drives toward zero (not +5V).
Biased quasi-invertion
- Attack phase starts at maxium positive value (+5V) and goes down to "zero" according to user defined velocity
- Decay starts at zero and drives to sustain level (not an inverted sustain level!)
- Decay starts from sustain leven and drives toward +5V.
All levels/times are set by acting on dedicated potentiometers. Modes are "biased" since out of the "regular" output, voltage is always in the 0 - 5V ballpark and doesn't go negative.
Attached images are actual non-inverted, semi-inverted biased, quasi-inverted biased envelopes from the direct output (yellow curves) and inverted output (blue curves).
Here is the LINK to all my "modified" sketches for this project (github). Files "ProgEnvGen_V1a" and "ProgEnvGen_V1b" are sketches for the first version of this envelope generator (I kept them for reference only). The sketch compatible with the new PCB is "ProgEnvGen_V2". Upload it to your arduino NANO the usual way.
I also made a simple sketch to check DAC functionality (DAC_test.ino): it loops the DAC output to 0V, then 2V, then 5V at a frequency of 1Hz. This comes handy if you have the suspect your DAC is malfunctioning. You will find this sketch at the previous link too.
PCB, BOM and Faceplate Notes
The project is made up of two boards: main PCB and faceplate.
Main PCB
All components values are silkscreened on the PCB to make assembly easier.
The board is intended to be mounted perpendicular to the front panel. If your case is not deep enought, you can lock the board on the case bottom and use wires to gain electrical connection with elements (potentiometers, buttons, jacks and so on) on the front panel.
Here is the list of components required to populate the PCB:
Microcontroller, DAC, Op-Amp
- 1x Arduino nano 328p
- 1x MCP4921 12 bit DAC
- 1x TL072
Capacitors
- 1x 0.10 nF non polarized
- 1x 0.47 nF non polarized
- 3x 100 nF non polarized
- 2x 10uF electrolitic
Resistors, Potentiometers
- 4x 10K ohm ressitors (up to 100K ohm should work)
- 1x 100K ohm resistor
- 1x 10K ohm resistor
- 1x 220K ohm resistor
- 1x 330K ohm resistor
- 1x 4.7K ohm resistor
- 3x 1K ohm resistor
Diodes
- 2x BAT43 Schottky
- 1x 1N4004
Others
- 1x IDC connector female 8x2
- 2x 8 pin IC narrow socket
FacePlate
Faceplate in pictures is made of aluminum. Aluminum is a not-so-common material for PCBs (or at least I am not used to it), but it's a godsend for our application. This with the fact that PCB manufacturers offer 1.6 mm thick aluminum as base material at the cost of fiberglass makes it a no brainer for our faceplates!
The faceplate gerber files can be downloaded at the same link as before (Github). Please notice that I use 1/4" female connectors, not the standard 1/8" eurorack connectors. This means that faceplate holes of my faceplate file are too big for 1/8" connectors. As an alternative, you can download my blank panels files (Github), modify the included panel source file (".brd") and have it manufactured. Eventually, you can have the blank panel manufactured and drill your holes afterneath, but I would not recommend it (pre-drilled panels with custom silkscreens and blank panels cost the same!).
My projects are free and for everybody. You are anyway welcome if you want to donate some change to help me cover components costs and push the development of new projects.
>>HERE<< is my paypal donation page, just in case you would like to contribute ;)
Acknowledgments
Both main PCB and aluminum front plate pictured in this Instructables where sponsored by JLCPCB, a high-tech manufacturer specializing in the production of high-reliable and cost-effective PCBs.
Their customer service is very good and PCBs a great value for the money!
Please, let me stress out that this type of sponsorship is essential to experiment new solutions and share good quality and full working circuits and layouts.
It allows testing a first prototype and then share a second (or third, or fourth...), improved and corrected revision of the board.
This mechanism has a very positive impact in the quality and reliability of shared projects.
Many thanks!