Decaying envelope when audio passes through diode

This is a basic question about passing AC (audio) signals through a diode. I'm trying to use an audio signal to power an LED (which in turn heat-shrinked to an LDR) in order to control the behaviour of a simple audio oscillator. At the moment I'm simply passing the audio input signal through a 1k resistor that's in series with the LED - this is working, but it has the annoying feature that the amplitude of the audio signal (and hence the brightness of the LED) decreases over time, over a period of several seconds.

The same thing happens when the signal passes through an ordinary diode, such as a 1N4002 - the signal starts loud, then decreases over several seconds. Here's a screenshot of the output seen when a sine wave (around 70 Hz) is passed through a 1N4002 - as expected, the output is rectified, but has a decaying envelope.

Why's this happening, and is there a way to power an LED (such that its brightness follows the amplitude of an audio signal) where this effect won't happen?

EDIT: here's an incredibly crude diagram of what I'm up to - I'm sending a sine wave from an output of my computer's soundcard to a breadboard, putting a diode in series with the signal, and recording the output from the diode back into the computer.

EDIT: Here's an image of the output waveform when a 100 ohm resistor is put between the output of the diode and ground, as per Kaz's answer below. When the output is goes directly into a pair of headphones instead of the computer, the effect is much less pronounced but still audible, suggesting that the problem lies partly with the computer's audio interface.

EDIT: There's no obvious frequency dependence - here are the recorded waveforms of:

1. A 1k sine wave without the diode in place (i.e. just recording the output back into the computer)

2. A 1k sine wave with the diode, as in the diagram above. The signal is attenuated and has the same decay envelope. The same general shape is seen for frequencies going from 50 Hz up to 8k.

• Can you provide schematic(s) of the current diode circuits? Commented Jun 28, 2016 at 20:21
• Even a crude but readable hand sketch would be OK. We need something to work with.
– user105652
Commented Jun 28, 2016 at 20:35
• I've added a diagram, apologies for the crudeness - hope this is clear Commented Jun 28, 2016 at 20:50
• Can you change the frequency, leaving the input amplitude at the same level, to see the dependance of the steady state output amplitude? That transient looks like second order to me. How long are the connections? Perhaps the circuit is expecting headphones' coils? Commented Jun 29, 2016 at 0:03
• @Sredni Vashtar There doesn't seem to be a frequency dependence. I've added two pictures showing a 1k sine wave recorded without the diode, and again with it - the signal is attenuated with the diode, and the same decay envelope is there. I tried other frequencies from 50 Hz up to 8k and the same general shape remained. Commented Jun 29, 2016 at 7:23

simulate this circuit – Schematic created using CircuitLab

Figure 1. (a) Reverse conducting diode. (b) Symmetrical LED.

The problems seem to be caused by the asymmetrical current path caused by the in-line diode. Since you are using and LED to LDR opto-isolator you can use the LED as the rectifier. Figure 1a shows the circuit with D2 providing protection for reverse voltage (since the audio signal is AC).

Figure 1b shows a pair of LEDs in back to back arrangement. This has the advantage of symmetrical loading of the AC. If you can find a package with both LEDs mounted back to back (internally) it means your LDR will be illuminated on both positive and negative audio signals. Failing that you could try to mount both LEDs on the one LDR or use circuit of Figure 2a.

simulate this circuit

Figure 2. (a) Pair of opto-isolators with parallel LDRs. (b) Bridge rectifier feeding LED.

For completeness, Figure 2b shows one LED fed by a bridge rectifier. This has the disadvantage of higher voltage drop due to two series diodes at all times.

• Solved! I'm still unsure as to what exactly was causing the envelope shape, but putting a 'reversed' diode in parallel with the LED - as per figure 1(a) has fixed the problem - a constant signal is now powering the LED at constant brightness. Commented Jun 29, 2016 at 20:58
• Good. What exactly did you end up with? My Figure 1a with a diode instead of R1 or in series with it? Commented Jun 29, 2016 at 21:01
• Exactly as in figure 1a, with a diode parallel to the LED. Kaz's suggestion below of putting resistors between signal and ground (both before and after the diode) also gave a signal that didn't decay, albeit with an initial shape to the waveform similar to those in my OP, so I assume that the original issue arises from some capacitance at the output and input stages of the audio interface. Commented Jun 30, 2016 at 12:06

it has the annoying feature that the amplitude of the audio signal decreases over time, over a period of several seconds.

Nothing that a diode can do by itself has a gradual effect of several seconds. You have a capacitance somewhere which is slowly charging through a resistance, creating a gradually changing DC offset which somehow affects the amplitude.

Maybe some DC return resistors before and after the diode would fix the problem.

A more full schematic is probably something like this:

simulate this circuit – Schematic created using CircuitLab

Note that if C1 gets charged through the diode (current flowing left to right) and builds up a voltage, it cannot discharge back through the diode. So the R2 resistor is prevented from doing its job. A resistor R3 placed between the external-facing terminal of the capacitor and ground will provide a discharge path. That resistor has to be appropriately chosen because it sets the upper bound on the input impedance of the input device. If you, say, make it only 100 ohms, then the output device is effectively driving a 100 ohm device, which may be too low.

• Kaz you are on the right track .Capacitive coulping in the computer is probably the culprit. Commented Jun 28, 2016 at 20:58
• Putting DC offset on the input cap of line-in could cause the capacitance to decrease. Commented Jun 28, 2016 at 20:59
• That's interesting Kaz, I assumed that this was just a property of AC through a diode, perhaps because the signal was too high. I'll try the circuit in your answer and put the results here. I'll also try out some other audio input sources besides the computer and see what happens. Commented Jun 28, 2016 at 21:21
• I've tried various resistor values for R3, from 100 ohm to 2.2k, but the effect remains. I've added a picture of the output waveform for 100 ohms to the question - there's still an initial peak and a decaying envelope. When the output is sent into a pair of headphones (with the 100 ohm R3 still in place), so that any capacitances arising at the computer input can be ruled out, the signal still audibly gets quieter over a few seconds, but the effect is less pronounced. The actual output from the computer (i.e. what's going into the diode) sounds fine. Very odd Commented Jun 28, 2016 at 22:02
• Also try it on the other side of the diode, in case the output stage is capacitively coupled. In my diagram, the output stage is shown DC coupled, which might not be the case.
– Kaz
Commented Jun 28, 2016 at 22:06