# Representing AC sine wave with common anode/cathode RGB LED

I have a AC sine/triangle wave I want to represent with single red/green LED. When positive side goes up then green light increases and opposite for negative/red light. This is pretty simple with two separate LED's, but I'm not sure at all how to go about this with RGB LED that has common anode/cathode. There are two big issues to solve:

1. There is dead zone area where voltage is too low to trigger the LED.
2. Perceived brightness curve is not linear, it takes more power to make it brighter each step. So it probably needs some kind of linear to exponential response.

I managed to make this with separate LED's:

• tinyurl.com/y2p88reg – dandavis Feb 12 at 14:49
• Thank you for the schematic. I guess I didn't make it clear enough that I want the LED to dim. – somerandomusername Feb 12 at 14:52
• it needs resistors anyway, and it will dim once built, that was just the basic idea... – dandavis Feb 12 at 14:53
• Oh ok, I think I get it. Thou your schematic has two wire signal. But I have one wire that oscillates from - to +. – somerandomusername Feb 12 at 14:59
• A problem you might consider: our eyes sense "intensity" in a non-linear way. That is, the impression of "bright" -to- "very bright" requires a much larger LED current increase than going from "very dim" -to- "dim". So translating a bipolar input voltage to LED intensity requires a non-linear transfer function. – glen_geek Feb 12 at 15:14

Really cool problem :)

Regarding your first question, you would need a circuit which has a kind of bend when your signal input is around 0V. You can do this by adding diodes in the feedback of an operational amplifier. Something like this:

The output function of the circuit looks like this:

Note that R1 is needed to have a proper load for the diodes. By decreasing R1 you increase the forward voltage of the diodes and therefore the "height" of the bend region. You can also add aditional diodes to increase the bend region without increasing the diode current.

Regarding your second question. You need something which transforms your linear input voltage to an exponential output current. Fortunately a BJT does exactly this. Leading to a circuit like this:

Please note I replaced the diodes with the BJTs in a diode configuration to have a similiar UBE in the amplifier feedback.

The current through the LEDs looks like this:

It seems that the exponential behaviour of the currents becomes more linear with higher input voltages. So maybe this is only suited for small input voltages.

Hope this helps :) Have fun :D

EDIT:

@somerandomusername: I just reread your problem and I totally overlooked that you wanted to use a common-anode or common-cathode LED. To solve this you can simply add an inverting amplifier with a gain of -1. And as user69795 suggested: if you only need a linear increasing LED current you can just add a resistor in the emitter of the BJT as a current feedback. The current through the LED will be roughly: $$\ I = \frac{U_{out} - U_{BE}}{R_E} \$$

This leads to a circuit like this:

• I believe somerandomusername may be incorrect in thinking he needs exponential gain. Since the brightness of a led is linear with current, your first op amp solution ( with led’s in place of the diodes) is most likely exactly what he wants. This will make the led’s brightness linear with the triangular input waveform’s voltage. – user69795 Feb 15 at 21:52
• Thank you for the effort. I will try to understand what is happening here. I came up with a solution on my own, check it out and please give me some critique – somerandomusername Feb 17 at 9:38
• @user69795 well the brightness might be linear, but from my own observations the perceived brightness is not. It is really easy to tell the difference when LED goes from 10% to 20%, but really hard to perceive change from 80% to 90% – somerandomusername Feb 17 at 9:45
• So I built the schematic and this is the result I got: i.imgur.com/gzgzhSv.png . Top and bottom is cut off, but I can fix it by increasing R1 to ~600. Is there a way to increase that dead zone? now it is -400mV to +600mV and that is not enough to start the LED. – somerandomusername Mar 1 at 10:19
• I could add a voltage divider on the signal before going in, and then 3x the output with another opamp, that could increase the "dead zone" – somerandomusername Mar 1 at 10:28

If this is a fairly low-frequency wave you want to represent, you could sample your waveform with a microcontroller ADC, then convert the waveform voltage to separate green LED and red LED PWM outputs. Then you have control over the visual effect, including doing a non-linear (gamma) mapping to improve the visualization of voltage.

Why non-linear mapping? The LED brightness (luminance) will be linear with its current (or average current if PWM is used). But the perceived brightness to the human eye will have a logarithmic relationship to current.

In broad terms, the eye is more sensitive to changes in intensity at low light levels than it is at high light levels, so gamma mapping applies an inverse curve to compensate for that.

You will also need an input circuit to level-shift and normalize the input to the ADC range.

I know this sounds complicated, but note that you could do this with a single 8-pin uC like ATTiny and a dual op-amp package. This could be made small enough to fit in a pen and cost less than a dollar.

• Thank you for the input. I came up with a solution similar to your suggestion using PWM, but without the microcontroller. And the pulse width gets wider the higher it goes, helping with the perceived brightness issue. – somerandomusername Feb 17 at 9:47

Thanks for all the help. I will definitely check out the solution @ringk89 came up with. I had idea of my own, trying to solve this using PWM. This is the solution I came up with: