1
\$\begingroup\$

My Background: I have a basic understanding of electronics from undergraduate physics courses and a few high-level digital electronics courses, but basically zero knowledge of anything analog/actually building circuits. The term "coupling capacitor" was new for me not too long ago, if that helps give some perspective.

I recently saw this video and I thought it was super cool. I want to create my own version of it and instead of using an MP3 player, I'd like to use a waveform generator (specifically the AD9833) so that I can better control the light/sound emitted from several LEDs (an array 16 RGB LEDS to be exact) with an Arduino Nano. I'm assuming I can't just connect the output of the waveform generator in parallel with an LED driver (see below schematic) like the guy does with the MP3 player and battery... but I'm not really sure what I'd use instead to accomplish this.

schematic

simulate this circuit – Schematic created using CircuitLab

I'm making my question a bit more specific. I was imagining doing something like in the below schematic.

Would a summing amplifier work for this purpose? From the TI schematic, the driver tries to maintain a set current rather than a set voltage (if I've understood it correctly). Would I be safe connecting the circuit up like so?

schematic

simulate this circuit

I reread the TI schematic and it seems like the LED Driver is open-drain (please correct me if I'm mistaken). Also, I found out that Op-Amps sort of separate the inputs from the outputs (very little current flows) if there's no connection between the terminals, so it would seem the LED driver would be problematic in the above schematic where it is. My next idea is to add the signal to a 5V supply that would be the main power for the LEDs. What do you guys think?

schematic

simulate this circuit

In response to @Tony Stewart Sunnyskyguy EE75's comment about specs: I'm hoping to use RGB LEDs similar to these. For simplicity, I'd like to design something for only the red component. It has an average forward voltage of 1.9 to a max of 2.5V. The signal I'd like to superimpose on the 5V supply would ideally be within human hearing range (20Hz-20kHz), but I can live with a smaller range if I have to. The amplitude would be limited by the waveform generator (AD9833) which on the spec sheet says 0.038V to .65V. I'm not really sure how to give a spec on noise (is it just an SNR?). I built a circuit similar to the one in the video using an lm386, a solar panel and an LED. I strobed the LED with a couple note frequencies (440Hz for an A, etc) and in a dark room it sounded pretty clear. I'm not sure I fully understand what I read here, but it seems like op-amp noise frequencies only appear at high frequencies (MHz range), where a person's ear won't really be able to hear it. My target SNR would be something around 30dB, I'm not overly concerned with a little distortion as the goal is to create an instrument.

\$\endgroup\$
19
  • 1
    \$\begingroup\$ but I've read there can be issues with oscillations using op-amps Sure, if you use an opamp incorrectly! If used properly, there's no issue. Stop not using xyz because you "heard about ...", instead educate yourself on the issue so you can avoid it. \$\endgroup\$ – Bimpelrekkie Mar 20 at 22:23
  • 1
    \$\begingroup\$ @Bimpelrekkie Sorry I will revise my question a little, I didn't mean to bash op-amps I just have never used them before and wanted to know if it was even a good idea to try or if there was some obvious reason I missed. \$\endgroup\$ – wootie11 Mar 20 at 22:30
  • 1
    \$\begingroup\$ @user263983 your claim is pretty questionable. The emission intensity is pretty proportional to the current flowing through an LED. Are you maybe mixing up voltage and current? But even then, "distortion" describes the effect accurately... \$\endgroup\$ – mmmm Mar 20 at 23:24
  • 1
    \$\begingroup\$ @TonyM My knowledge level is pretty low, I've taken some introductory electronics classes in college, but it was all digital, so I am completely out of my element here. I'll update my question to include that. Thank you for the warm welcome! \$\endgroup\$ – wootie11 Mar 21 at 0:25
  • 1
    \$\begingroup\$ Your problem must be broken down into components for optocoupling. Consider a PD is 0.5uA/uW and your optical power depends on distance, size of detector, capacitance and BW. The CTR for a tightly couple optoisolator is typically <1. Your Can use Friis Loss from the gap to detector with ambient optical noise determines your CTR which depends on path loss. So you end up only sampling a very small % of radiated power. a Transimpedance amplifier with high gain and audio BW compromises your SNR. So specify the parameters needed for each stage and consider LEDs >30 times brighter for Iv @ same I \$\endgroup\$ – Tony Stewart EE75 Mar 21 at 14:20
0
\$\begingroup\$

Your choice of common-cathode red-green-blue LEDs means that an analog LED driver should drive LED current into the open LED anode. The common LED cathode would go to 0V (GND).
But most signal sources provide output relative to ground. This makes driving a cathode-grounded LED with current a bit more complex. Your AD9833 signal source is of this type. Many microphones are too.

Your LED suggests maximum current of 30mA. This means that with no AC signal, it should idle at half-current, at 15mA. Then it can swing down toward zero mA, and up toward 30mA with signal current. The LED would appear constantly bright, because your eye cannot see rapid signal swings at frequencies above 30 Hz. Average current remains at about 15 mA.

An analog driver, driving a cathode-grounded LED might look like the two-transistor circuit (below). Resistor bias is chosen so that most any LED would have roughly 15mA flowing with no input signal, provided the DC supply voltage is +5V. Input voltage to C1 would be about 0.65V peak-to-peak AC signal.
15mA LED driver

----------

Driving common-cathode LED array is simpler with a PWM signal source. You only have to calculate LED current for two cases:

  • LED OFF: 0 mA current
  • LED ON: 30 mA current

A transistor saturated switch toggles between these two cases, driven from a digital signal source. An Arduino with a Vdd supply of +5V would toggle a digital output pin between two voltages: 0V & +5V. This signal would drive a switching transistor ON or OFF.
Current from the Arduino pin is small (1.4 mA), limited by a resistor (R1, below). Another resistor (R2) is chosen to limit LED current to 30 mA, from a +5v DC supply. The transistor has ample current gain and is actually over-driven so that it acts as an ON/OFF switch. Note that the 30 mA current through transistor and LED does not flow from the microcontroller, but does flow back to the +5V supply. Many PWM outputs could drive such a switch before microcontroller current limits are exceeded.

schematic

simulate this circuit – Schematic created using CircuitLab
A PWM signal of 50% duty cycle would drive the LED ON to 30 mA half the time, and drive the LED OFF to 0 mA half the time. The average is 15 mA.

Converting an analog waveform input to PWM signal is done with software inside Arduino, which uses its analog-to-digital converter (ADC) to provide to its PWM module a digital input. The PWM module would be set for a frequency above the audio range for your application (above 20 kHz).
Most of these microcontroller ADCs use +Vdd as a reference voltage, so that input signal ranging between 0 -to- +5V gives an output value between 0 -to- 256 for an 8-bit ADC, for example.
A program might read ADC 20,000 times per second, convert this number to a range compatible with PWM range, and write to the PWM duty cycle register.


Driving multiple LEDs with one transistor switch:

schematic

simulate this circuit The MOSfet would be selected from data sheet to have less than about one ohm \$RDS_{on}\$. A "logic level" MOSfet would be preferred, especially if the microcontroller was run at a supply voltage lower than +5V. The MOSfet should not run hot with only 90mA being switched on/off.

Since the switched 90mA current is reasonably high, a DC supply bypass capacitor should be placed near the resistor common point, and MOSfet source (which is grounded). This should reduce radiated EMI interference.

When you drive multiple LEDs with ONE PWM switch like this, each LED is modulated with the SAME PWM signal. If you want each LED to have individually-controlled modulation, each LED would require its own PWM channel, and its own MOSfet. Some microcontrollers have multiple PWMs on board.

\$\endgroup\$
3
  • \$\begingroup\$ First, thank you for the detailed response, this helps immensely. I really appreciate the time you took to explain everything for a n00b like myself. As for driving an LED array, I have two questions: first, can I just place additional LEDs in parallel below the transistor? If not, what would be the basic idea for turning this into an array? And second, I haven't much experience with the ADC on an Arduino, do you think it could handle 4 separate function generators? I'm looking to emulate a guitar a bit, so I was hoping I could overlap some note frequencies on top of each other. Ty again \$\endgroup\$ – wootie11 Mar 22 at 14:28
  • \$\begingroup\$ The analog driver described above drives ONE LED only...if you add a RED LED in parallel, each LED gets roughly half the current (and generates half the light). If you add a GREEN LED or a BLUE LED in parallel with a RED LED, the red one hogs all the current, leaving none (or very very little) for the other colour. For the PWM switch driver, a single transistor can drive multiple LEDs, if each LED has its own series resistor (schematic edit pending). \$\endgroup\$ – glen_geek Mar 22 at 17:45
  • \$\begingroup\$ Sorry I should've clarified which driver I was talking about, but you fully answered me for both so thank you. I didn't even know about the red LED current hogging - that's really good to know. For some reason I thought the driver would compensate/adapt for a bigger "load" of LEDs but now I see that I was thinking a little too hard about it! Thank you again so much for taking the time to so clearly and fully answer my question. \$\endgroup\$ – wootie11 Mar 22 at 20:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.