Pages: [1] 2   Go Down
Author Topic: Dimming an LED strip  (Read 4552 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have an RGB LED strip from Radio Shack and I am making a visualizer. I am new to circuit building (not programming) and am trying to figure out how to dim the LED strip with one of the digital or analog pins. The only issue is that the strip requires 12vDC to run properly and if I recall correctly, the max for any one of the pins is 5vDC. I have looked at JFETs, Digital POTs, or making a jerry-rigged one by combining a flat led with a photo-resistor. My question is: How can I control a 12v current (I would like to be able to control the output voltage from between 0-12 volts) using a 5v pwm signal.

Thanks
Logged

Eugene, Oregon
Offline Offline
Sr. Member
****
Karma: 9
Posts: 388
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

http://learn.adafruit.com/rgb-led-strips/usage

That will give you an idea, exactly how you do it will depend on the LED strip. My guess is that your LEDs will require a separate 12v power supply and some transistors of some sort at the very least.
Logged


Montreal
Offline Offline
Faraday Member
**
Karma: 29
Posts: 2591
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How long is your strip? 5m would require transistor, less than 1m you can do with ULN2003/ULN2803
Logged

Beijing
Offline Offline
Full Member
***
Karma: 3
Posts: 193
Skype name habib.derbyshire
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yeah you can drive it with a transistor or mosfet. I recommend the IRF540N mosfet.
Logged

What is man's best friend? The breadboard!

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The Transistor seems like a good idea. The 1 meter strip I have has the capability of lighting up individual lights instead of the whole strip being one color. It uses a TM1803 chip to control the led colors. The only problem is that if power is disconnected, the whole strip resets. Is there a way to maintain a constant power to the strip using a transistor connected to PWM?
Logged

Beijing
Offline Offline
Full Member
***
Karma: 3
Posts: 193
Skype name habib.derbyshire
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Why don't you first write the code? With the transistor the code would be the same as PWM-ing an LED.
Logged

What is man's best friend? The breadboard!

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The code is already written. Unfortunately I fried my Uno when I was testing a different idea. Do I use a capacitor in conjunction with the transistor to keep a steady,variable voltage going to the led strip? If so, how much (Again, new to circuit building).
Logged

Beijing
Offline Offline
Full Member
***
Karma: 3
Posts: 193
Skype name habib.derbyshire
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I am sorry you fried your Arduino. You don't need a capacitor; PWM is a pulse, if you add a capacitor it will absobe the pulse and there will be no dimming--full brightness.
Logged

What is man's best friend? The breadboard!

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 538
Posts: 27115
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

http://www.titanmec.com/doce/product-detail-217.html

Send the correct data to the part - it has PWM control  built in.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

alright. Ill have access to a new board tomorrow. Ill see if the PWM and led strip work together. I am thinking that if the power is off for too long, the strip will reset(uses a tm1803 led driver). Im also looking into using a mosfet as a variable resistor.

Crossroads: in reply to your post, the tm1803 has 3 output channels meaning a single ic can control 3 single color leds or 1 RGB led. In my case, its the latter of the two meaning that any change in signal needs to be applied 3 times, once for each color channel. Since Im building an audio visualizer, the brightness changes every loop and since the tm1803 is time based, the calculations to change the color is too slow for the strip to be correctly set to a color sequence (trust me because I did this just before I blew the capacitor on my Uno).
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 538
Posts: 27115
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You have to send it different data for each color.

"TM1803 adopts single wire to communicate and RZ (return to zero code) method to sent signal. On power-on resert status, when chip receive complete 24bits data from DIN, it begin transmitting data to next chip via DO. Before transmission, DO will be keep low-level.OUTR, OUTG, OUTB these 3 PWM will output different duty signal according to different data per 24bits, the cycle of signal is 4ms.If input signal is RESET, the chip will be ready to receive new data after displaying all the received data.The same when receive new 24bit data completely, it will transmit them to next chip via DO."

Read the datasheet - send it 3 bytes, 1 for each color. If you have multiple LEDs/TM1803s, then you will send it multiple groups of 3 bytes.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes but if the signal on the input is a low bit for longer than 20 microseconds it sends a reset code. This is the issue I had before. For instance if I had a color 0xFFFFFF, extracting the RGB components, multiplying them by the correct brightness scale and then concatenating them together took too long and therefore sent a reset signal to the chips.

If you have another idea on how to adjust the color, I would be more than happy to hear it.

Here is the "sendColor" function that I have in my code

void sendStrip(uint32_t data){

  int i;
  unsigned long j = 0x800000;
 
  for(i = 0; i < 24; i++)
  {
    if (data & j)
      {
      OnBit;
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");   
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      OffBit;
    }
    else
    {
      OnBit;
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");
      __asm__("nop\n\t");   
      OffBit;
    }

    j >>= 1;
  }
}


OnBit sends a high value to the analog pin
OffBit sends a low value to the analog pin

The groups of "nop"s are delay functions that send the bits to the ic.

Here is the LED strip's documentation as well:

http://www.radioshack.com/graphics/uc/rsk/Support/ProductManuals/2760249_PM_EN.pdf
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 538
Posts: 27115
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, so it looks like you have to continuously send data to these parts.
One way to do that is with SPI.transfer( )s
http://arduino.cc/en/Reference/SPI

Set the SPI divisor to 1/16 for 1 Mbps data rate, and send out the three bytes of data
Code:
void loop(){
currentmicros = micros();  // time elemets are all unsigned long
if ( (currentmicros-previousmicros) >= interval) // interval at 20 ? (microseconds) = 320 clock cycles
   {
   previousmicros = previousmicros + interval; // set up next time period
   SPI.transfer(green_byte); // or whatever order is needed
   SPI.transfer(red_byte);
   SPI.transfer(blue_byte);
   }
// update color codes as  needed
}
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

After some more research and tinkering, I think that I will end up using an op-amp to scale the voltage from a 0-5 range to the 0-12 volt range I need.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Alright. I'm back. So I bought a generic op amp and am following one of the schematics for voltage scaling but it is making the voltage smaller instead of larger. Can anyone tell me how to scale a 0-5v signal to a 0-12v signal using an op amp?
« Last Edit: January 21, 2013, 07:26:41 pm by chaser53 » Logged

Pages: [1] 2   Go Up
Jump to: