ADSR Envelope Generator - Page 1
Forum section: electronics / beginners

author: limtte
author_rank: Newbie
timestamp: April 10, 2016, 02:19:24 pm
content: Hello fellow EE-enthusiasts!I'm currently experimenting with some simple audio-circuits... kind of. Long story short, I watched an interesting video on DIY synths/sequencers (https://www.youtube.com/watch?v=FaoJaLmZaL4) and thought I'd give it a try.By now I want to make the resulting sounds a bit more interesting by adding a voltage controlled amplifier controlled by an ADSR envelope generator. Well, the VCA right now is nothing more than a voltage divider including an LDR sitting inside a bit of shrink tubing together with an LED. ^^ But it kind of works. A bit more of a problem is: How to generate an ADSR signal? Most of the schematics I found online seemed to be rather complicated and/or used parts I don't have at hand. So I tried to design my own circuit, with reasonable success.See the attached schematics or the simulation I used to develop this.http://bit.ly/1Yn9T7cTwo of the inverters used form some kind of Flip-Flop which is set when the capacitor reaches significiant charge and reset when the input pulse goes low. When set, the "upper" part is grounded and the voltage divider on the top left sets the reference to which the cap should be discharged, the sustain-level.The problem is: In the simulation, everything works fine. In practice, prototyped on breadboard, too -- except when I try to give the next pulse too soon, the ADSR signal does not "retrigger" to the attack-phase, but seems to hold at the current level of "release". The reason is that the PNP transistor is open, so the capacitor cannot charge. This should not happen, because the 0V-input between two pulses should immediately pull the output of the right-most inverter high, hence pulling the control-signal for the transistor low (which comes from another inverter). In reality, this does not happen until the cap is almost discharged.Since I'm quite new to electronics I don't own an oscilloscope yet, so every debugging needs to be done using a multimeter, sound and LEDs. But by replacing the 470nF cap with a 10µF one, I can at least see the ADSR effecting an LED.If you have any ideas on what might be the reason for this behavior, please let me know.Oh, I almost forgot, some specs:I'm powering everything from 5V single supply. Hence the OpAmps (LM324) output is capped at ~3.5V (no rail-to-rail, sadly). The Schmitt-Trigger-Inverter are 74HC14.Edit: Removed url-tags on the yt-link. That video is not the main focus here.

author: danadak
author_rank: Super Contributor
timestamp: April 10, 2016, 03:37:09 pm
content: Here is an oscilloscope that can be used at low frequencies. Be careful about protectingyour sound card input, google that, several hits on what to do.From their web site -Signal SourcesThe signals for the oscilloscope can be internal to the computer (MP3 player, function generator etc.) or from external sources (line-in, microphone). For external sources care has to be taken, not to exceed the voltage range of the inputs. The range is usually only ±0.7V !! If higher voltage need to be analyzed, a voltage divider has to be used. Additional protection diodes are recommended in order to avoid any damage to the sound card and to the computer.https://www.zeitnitz.eu/scope_enhttps://www.zeitnitz.eu/scope/manual_scope_v140.pdfRegards, Dana.

author: limtte
author_rank: Newbie
timestamp: April 10, 2016, 04:03:44 pm
content: Thanks for the suggestion, but messing with my sound card? Seems not like a good idea to me, since I do expect to fry one chip or another. And I rather not want that to happen with my PC.I'll go for a cheap USB-oscilloscope, but that has to wait a week since it's on my wishlist and my birthday is coming soon.Until then I'm just hoping that anyone here has some experience with the quirks of the 74HC14 (I'm just guessing it has to do with those!) and might have an idea of what's happening here.Edit: A bit further into reading some articles about "how to use your sound card as an oscilloscope", this really is a neat idea, but I doubt it would help me in this special case. The ADSR-signal is intended to be triggered by an LFO, at ~1/4 Hz to maybe ~10 Hz, and during testing this it's even less. But sound cards operate at audible frequency range, which would be about 20 Hz to 20 kHz. Right?

author: limtte
author_rank: Newbie
timestamp: April 19, 2016, 06:54:11 pm
content: I'm making progress.After a bit of fiddling around with the circuit (and verifying that my flipflop-construction works as intended if isolated from the rest of my circuit) I suspected the 1M pulldown resistor to be too high. And indeed, using a lower value resulted in a bit of improvement, but I don't want the capacitor to discharge through the pulldown. Hence I just added an opamp as a voltage follower in between.After a few more problems I've got it working now (see the attached screenshot), instead of the transistor I now use a diode to pull the attack stage down when going into decay, and I also had to power my opamps with 9V since the thresholds of the 74HC14 inverter seem to be at the max value specified in the datasheet, so 3.5V opamp output were just not cutting it. I hope this doesn't sound too much gibberish.However, I've still got some problems with an even simpler circuit, which I can only properly describe since I got my first oscilloscope two days ago. A simple oscillator that's using the hysteresis of the inverter to change between charging and discharging the capacitor through a potentiometer and thus creating a square-wave of variable frequency.Problem is: The circuit just randomly (after a few seconds to sometimes minutes) stops oscillating properly and stays at about 2.5V output! I'm just guessing that the circuit gets somehow caught inside a narrow transistion area of the inverter -- but how can I possibly avoid this behaviour? :-(

author: limtte
author_rank: Newbie
timestamp: April 20, 2016, 06:52:26 pm
content: I just checked one of the inverters by varying the input voltage and measuring the output on the scope. And I really, really don't like what I see.Most of the time, there's this transition area which would explain the failure of my oscillator quite well. Then again, sometimes, for some reason I cannot imagine, everything looks fine. Please see for yourself... Channel 2 is me turning the potentiometer for the input, channel 1 is the output of the 74HC14.Any ideas?

author: limtte
author_rank: Newbie
timestamp: April 22, 2016, 09:45:58 pm
content: To continue my monologue:It seems that I've found a solution. Since I tied all unused inputs to 5V I'm unable to reproduce the problems and the oscillator is working just fine. But I still don't understand why floating pins are an issue, as they are schmitt-triggered, which should prevent excessive switching inside the chip -- shouldn't it?It'd be nice if anyone could lighten me up on what's happening here, especially what's causing this messed up characteristic curve shown in my previous post. I would understand uncontrolled switching between high and low, but I'm absolutely clueless about the flat and almost linear region.I'd really like to not only know how to fix this problem, but also what caused it.

author: nugglix
author_rank: Regular Contributor
timestamp: April 23, 2016, 07:50:03 am
content: Guten Morgen! First the standard mantra:Put a capacitor accross the supply pins of the IC, ca. 100nF directly accrossthe ICs supply pins, shortes possible lead length.This will stabilize the supply voltage of the IC considerably.Do that for/on every IC you use. Just make it a habit.On the 74HC14 oscillator:It might be that the oscillator is oscillating in the shown "flat" region butyour scope doesn't/can't show it.The 74HC14 is good for some MHz of oscillation, so the chances that it'soscillating and you simply can't see it are quite high.You can try to measure that indirectly by placing the oscillator in the flatregion deliberately and measure the current consumption of the circuit.If there is high frequency oscillation the current should be higher thanwith low frequency operation.This has to be done before the stabilization shown above is installed -of course.On reporting "strange things":Please show the complete diagrams of the used/discussed circuit.If you built something, please show a picture or two of the real thing.This will allow others to give some help w/o much assumptions and guessing. Greeting phrase in a long forgotten language once used by engineers and inventors.

author: borjam
author_rank: Unknown
timestamp: April 23, 2016, 10:33:03 am
content: You will probably enjoy this gem of a book: "New Generation of Electronic Musical Instruments" by Juan Bermúdez (1977).It was published in Spain by Marcombo, and now it's out of print. The author made a revision in 2011 andthe author himself made it publicly available.It's in Spanish, but surely the circuits will be of great help.http://aulaelectroacustica.blogspot.com.es/2015/02/ebook-nueva-generacion-de-instrumentos.html.You will find a link "enlace de descarga" at the bottom.

author: limtte
author_rank: Newbie
timestamp: April 23, 2016, 11:05:27 am
content: Moin moin! Who doesn't know the famous saying: "When in doubt,  bypass caps!"? I may not have explicitly said it, but I've totally spammed my breadboard with bypass caps of various sizes (100nF - 10µF), including a 100nF directly over the chips supply pins. Didn't fix the problem.What fixed it (as stated above) was tying all unused inputs of the 74HC14 to a well defined potential. I could even removeallbypass caps, and the oscillator would work really fine. Only when having two oscillators active at the same time, they would influence each other. But this is easily explained: Higher frequency of one oscillator results in a higher current draw and therefore in a bit of voltage drop at the IC. The hysteresis gap is dependent on the supply voltage and dropped in size, too, hence there is less charge to be transported to/from the capacitor, resulting in an overall higher frequency. Which is exactly what I could see on the scope -- including the lower hysteresis gap. And this could easily be fixed by putting the bypass caps back in.I'm sure the oscillator is oscillating in the flat region, but it does not "fully" charge/discharge the capacitor. It's just about a few millivolts up and down, around the equilibrium whereinput voltage == output voltage.The equilibrium is the "strange thing" in the characteristic curve: As there is a point at which the output if the IC equals the input, this is the point where the oscillator hangs up. But why does this flat spot exist? And why only if I leave the other input pins floating? I've attached a schematic (excluding bypass caps) of how I measured that kind of broken curve. There is really not much to it. Note that only one of six inverters is used, the others are left floating, and I tried it with and without the 1k load.I'm just baffled by this stupid behaviour of the chip,becauseit should operate well as an oscillator of up to a few MHz,becauseit is a schmitt-trigger. I'd not expect one of the inverters being influenced by what the others are doing. But obviously, that's the case.@borjam: Thanks! That looks really nice. Too bad I now have to learn spanish. But looking at the schematics I guess I might get a few ideas from this. Greeting in the same old language of engineers. A phrase used only by the most skilled in their field, true masters of immense knowledge and wisdom!

author: nugglix
author_rank: Regular Contributor
timestamp: April 23, 2016, 11:46:34 am
content: Quote from: limtte on April 23, 2016, 11:05:27 amI can only comment on I things you say/show.If you deliberately hide things you get wrong answers.Quote from: limtte on April 23, 2016, 11:05:27 amIn nearly every data-sheet is a hint that you should put unused parts of the IC into a stablestate. This holds even for TTL chips afair.For high impedance CMOS it is one of those things that has to become a habit - like thedecoupling caps.You mentioned a breadboard; I will assume you meant one of those solderless spring loadedthings.This is why I asked for a picture of the built thing. The built *does* influence the performance.This type of breadboard do have a (small) capacitance between the rows, whichmight be enough to transfer some charge into an open input, which might get triggered atsome point. So without fixed inputs the other gates on the chip might also start to oscillateand this in turn will influence the oscillator you observe.Seehttps://de.wikipedia.org/wiki/%C3%9Cbersprechen(engl.:https://en.wikipedia.org/wiki/Crosstalk)So, no stupidity on the ICs side.Quote from: limtte on April 23, 2016, 11:05:27 amHow do you tell?In other words: what is the bandwidth of the scope used?

author: limtte
author_rank: Newbie
timestamp: April 23, 2016, 12:18:49 pm
content: Quote from: nugglix on April 23, 2016, 11:46:34 amSorry, that wasn't meant to be rude in any way. I just assumed adding (more) caps to be the default fallback if anything goes wrong.Quote from: nugglix on April 23, 2016, 11:46:34 amI will certainly remember that!Quote from: nugglix on April 23, 2016, 11:46:34 amOooh, I guess I get what you're aiming at / what could be the problem. When the input of the used inverter is at about 2.5V, the influence of the neighbouring, due to floating inputs oscillating inverters, is strong enough to "transfer" this oscillation through the crappy breadboard. And if the oscillation is fast enough, I would not see it on the scope, but rather the somewhat constant 2.5V output?Quote from: nugglix on April 23, 2016, 11:46:34 am20 MHz, but only 48 MS/s. And again, Iassumedthis would be more than enough for everything that could happen, given that I'm only generating frequencies up to ~10 kHz. Well, in hindsight I agree: Way too many assumptions. Sorry for that. The datasheet for the IC gives rise/fall times of about 30ns, ... at 60ns for a cycle this would mean a maximum frequency of about 16MHz? Close.Hmmm. I'm going to configure an oscillator for higher frequencies, up into the MHz range, and check the scope to hopefully confirm the "2.5V" output. Also, would it help to solder the IC to a piece of stripboard, or is that just as bad as the breadboard version?Thanks for helping me out!