Arduino based ADSR

Here is a project that I found over on Github for a basic ADSR that utilizes an Arduino and an MCP4921 DAC (12-bit) to generate a very nice Curve!

It is called the “ADSRduino” (designed by mOxpd < — Blog Link)


Probably gonna give it a build myself :smiley:

11 Likes

I spent part of the weekend laying out something very similar! I’m using an ATTiny 84 and an MCP4131 digital potentiometer and it’s more of a function generator like MakeNoise Maths or Buchla 281. Sounds like I’ll want to go with a stateside PCB house (I’m thinking OSH Park.)

1 Like

JLCPCB is supposedly back to normal, but I guess that doesn’t necessarily include shipping.

Looks nice, but it seems to me if you’re going to stick a microcontroller in an envelope generator, it should have something more interesting to do than ADSR! ADSR is a decent simplified approximation of some real world envelopes, but no more than that; with a microcontroller on the job, so much more varied and interesting envelopes are possible…

1 Like

I saw that this week! I was wondering to myself if it would need something like an op amp to bring the voltages up. Still unsure whats a good voltage to send for CV. I know 12v is typical for power, but you never know with these things.

This confuses me…
Can someone maybe explain the Switch here?

Also - What is the other jack he has there on the panel (next to the switch) - it isn’t on the schematic lol.

Here is what I’ve got so far, but am not positive about the switch…

(update on the bottom section - switch is possibly wired incorrectly but I am truly unsure based on the diagram)

(yes… i spent a crapload of time on the thonkiconn jacks and pots… lol)
lol
layers… lolol

2 Likes

The switch is for the loop mode.

const int modePin = 3;
pinMode(modePin, INPUT);

It is set to high

digitalWrite(modePin,HIGH);  

but when the switch is closed, the pin is pulled to ground and therefore reads 0 in the check:

loop_mode=!digitalRead(modePin);

Why is it done like this? It seems a little bit backwards, right?
The reason is noise. When the switch contact is open it can read strange results (the state is unknown because there is nothing there), so switches usually need a kind of pull-up or pull-down resistor to work consistently. Arduino digital pins have an internal pull-up resistor that can be enabled by setting the pin to HIGH (digitalWrite(modePin,HIGH); This way you need less components :slight_smile:

While reading this page again, I noticed that the proper way to enable the internal pull-up is now to set it as pinMode(modePin, INPUT_PULLUP);. I don’t understand if that then also inverts the signal, so LOW then means true? can someone help me here?

4 Likes

From what I know of the Arduino system, I doubt that pinmode call has any effect on the interpretation of the signal. Low and high will still have their original meanings so unless the pin is pulled to ground the internal pull-up will keep it reading high. How those high and low values are interpreted by the software is up to the program logic. If you want something to happen when the switch is closed then check the pin value and perform the action if the value is low.

1 Like

That probably ought to be an interrupt, right? 3 can do it on most Arduino I think.

1 Like

No need for interrupts; he’s just polling the pin after each full ADSR cycle (note the ! which means “not”, i.e. expression is true if input is low).

As noted above,

pinMode(pin, INPUT);           // set pin to input
digitalWrite(pin, HIGH);       // turn on pullup resistors

is the pre-1.0.1 way of saying INPUT_PULLUP.

1 Like

Is the single zener to GND going to be enough protection? I know most triggers are in the +5 range but Dieter recommends a full clamp on the A-100 diy page. I like interrupts myself to get around debounce issues.

2 Likes

If you were generating audio frequency signals you’d need an interrupt service routine, and even then you’d be running close to the limit of the microcontroller’s capabilities. For generating an envelope CV or reacting to slow human switch flipping, you can get away with busy loops and polling.

2 Likes

welp… this all just went way above my head… lololol

so uh… do i have the switch right on my DIYLC pictures… lol…

1 Like

I can’t really tell, but so long as one pole is going to pin 3 (I think it was) and the other goes to ground you ought to be okay.

3 Likes

Does it do what you expect?

3 Likes

Is the single zener to GND going to be enough protection?

All Arduino inputs are rated for +VCC+0.5 V = 5.5 V which is higher than a typical 5.1 V zener’s max of 5.1+5% = 5.355 V so should be safe, as long as you don’t fry the zener. Assuming 1/4 W components, the series resistor gives you enough headroom for 10 V and a bit over that.

(the inputs do have built-in clamping diodes too – see this post – but they can only handle a milliamp or so, so you’ll need a much larger resistor if you remove the zener).

4 Likes

i am one of those people who do not build things until I get input lol
So I do not know yet. :stuck_out_tongue:

I will probably try this this upcoming week - need to replenish funds and order some parts.

Also - Any idea what Pots I should use? lol

2 Likes

10k is a good default. You can use higher values, but the analog read samples the input by very briefly charging a (tiny) capacitor, so if you go too high it may not charge up properly, and the channels may start affecting each other. The usual fix for that is to add external capacitors.

EDIT: Added input circuitry.

4 Likes

I’d go for a 4.7V zener diode to keep the inputs below 5V.

@fredrik, any reason not to use a 15K resistor to keep the current into the protection circuit below 1mA for all voltages between +12V and -12V? What’s the input impedance of the digital inputs?
You might not even need the zener then, as the builtin protection diodes would be able to handle the current even at 12V.

If you expect possible negative input voltages, and want to keep the resistor small (I’d use at least 1K) an additional schottky or germanium diode in parallel with the zener would do the trick. (Schottky and germanium diodes have a lower forward voltage than regular silicon diodes (forward voltage of zener diodes is not always on the spec sheet, but I suspect it is probably at least as high as regular silicon diodes).

4 Likes

The 5.1 V zener should be ok (unless it 's really slow) and if you expect 5 V it won’t conduct under normal operations, but a 4.7 V should work too, it may just produce a tiny amount of extra heat in the diode :slight_smile: (if you want to push it, it looks like the logic high threshold is +Vcc×0.6 = 3 V).

Agree that a 15k (or higher) and no zener is likely to be fairly robust. The digital inputs are CMOS gates with very high (“near infinite”) impedance (the Arduino docs say 100M but I suspect they mixed that up with the analog inputs, and I don’t think the AVR data sheet spells it out for the digital inputs.)

(I guess I should do some experiments some day :nerd_face:)

4 Likes