Hey,
So i've been poking about this forum for the last week but haven't found quite the answer i am looking for so i figured i would just ask. Apologies if this seems like a double post, but i really swear i have searched extensively for my answer on here and have come up empty handed.
So i have some RGB LED strip lights, they are 12 VDC and take about 200 mA of current per channel. They are common cathode, so i need a high side driver IC.
At first i tried building one, but after blowing up an arduino chip i decided to just buy an IC LED driver.
Now the only LED driver chip that works for common cathode that i could find is this one: UDN 2981.
(it is my first post so i can't post a link apparently, but if you google that you will find the datasheet as the first result.)
The chip works fantastic except for one small problem. The chip takes ANY input signal from 128 to 255 and outputs a HIGH to the LEDs. And similarly takes any output signal from 0 to 128 and ourputs a LOW.
So my problem is that i can't dim the LEDs at all, they are just ON or OFF, no middle ground.
Is there a better chip that has more analog behavior, or do i have to build my own high side constant current source driver with PNPs? If so could you point me at a decent design to start with? As i understand driving high power LEDs is a bit more complicated than just using one transistor because you need a constant current source.
AWOL:
typo, i meant that 0 to 127 is outputs a LOW.
My code does not show my attempting to output anything below 255 anymore, i gave up on trying to make the fading for for the show last night, but it does show how i adress the pins...
const int analogInPin0 = 0; // audio in 1
const int analogInPin1 = 1; // audio in 2
const int yellowbutton1 = 2;
const int yellowbutton2 = 3;
const int greenbutton1 = 4;
const int greenbutton2 = 5;
const int redbutton1 = 6;
const int redbutton2 = 7;
const int blue1 = 21; // Analog output pin that the LED is attached to
const int blue2 = 19; // Analog output pin that the LED is attached to
const int blue3 = 20; // Analog output pin that the LED is attached to
const int red1 = 6; // Analog output pin that the LED is attached to
const int red2 = 1; // Analog output pin that the LED is attached to
const int red3 = 5; // Analog output pin that the LED is attached to
const int green1 = 23; // Analog output pin that the LED is attached to
const int green3 = 18; // Analog output pin that the LED is attached to
const int green2 = 0; // Analog output pin that the LED is attached to
const int WhiteLED = 22;
int sensorValue0 = 0; // value read from the audio signal left
int sensorValue1 = 0; // value read from the audio signal right
int greenb1 = 0;
int greenb2 = 0;
int yellowb1 = 0;
int yellowb2 = 0;
int redb1 = 0;
int redb2 = 0;
int sensorValueTotal = 0; // total audio signal
int outputValue = 0; //
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
const int blue1 = 21; // Analog output pin that the LED is attached to
const int blue2 = 19; // Analog output pin that the LED is attached to
const int blue3 = 20; // Analog output pin that the LED is attached to
const int red1 = 6; // Analog output pin that the LED is attached to
const int red2 = 1; // Analog output pin that the LED is attached to
const int red3 = 5; // Analog output pin that the LED is attached to
const int green1 = 23; // Analog output pin that the LED is attached to
const int green3 = 18; // Analog output pin that the LED is attached to
const int green2 = 0; // Analog output pin that the LED is attached to
const int WhiteLED = 22;
only the pins D3, D4, D12, D13, D14, D15 are analog outputs (pwm). The other pins are only digital out. It is logical that you can only switch the led on or off on this digital pins.
It's perfectly fine using the analog inputs as digital I/O pins, referencing them as digital pin 14-19. But you must set them as outputs (or inputs) first!
pinMode(Pin, OUTPUT);
The chip works fantastic except for one small problem. The chip takes ANY input signal from 128 to 255 and outputs a HIGH to the LEDs. And similarly takes any output signal from 0 to 128 and ourputs a LOW.
Huh? It's a source driver, taking digital signals for input.
Ah I get it, you use analogWrite on non-PWM output pins (you cannot use analog INPUT pins for this, not on the atmega 168/328 at least).
It's a big difference between analog inputs and "analog" (PWM) outputs. Not even on the same pins. There are only a few special PWM output pins that analogWrite works on. You can read a little about PWM here: http://www.arduino.cc/en/Tutorial/PWM
And the source driver should work fine with that.
Is there a better chip that has more analog behavior, or do i have to build my own high side constant current source driver with PNPs?
Yes, and depending on what you mean by your own PNP driver, maybe.
If you mean for dimming, then no. LED's are not dimmed in an analog way (diode characterestics, slightly varying specs becomes important), but with the aforementioned PWM method for consistency.
If you ment like a switch, and you (most likely) have a common ground for your LED's and arduino, you'd better off switching the LEDs on and off with an NPN at "the bottom", near ground, not PNP. Exchange the "load" with a LED in this schematics and take a look: Transistor Circuits
It's a nice page about bipolar transistors btw.
There are probably many chips that have PWM outputs, but any of those are probably overkill for your project right now. A popular one seems to be the TLC 5940, 16-channel PWM LED driver. I've never used one so I cant say anything about it really.
I think there is a software-PWM library somewhere, extending PWM to other pins as well. Or you could write your own, its only about toggling a pin on and off with certain intervals.
Multiplexing the PWM outputs is a bad idea, unless you can synchronize the multiplexing with the PWM... not easy.