Offline
Newbie
Karma: 0
Posts: 12
|
 |
« on: January 19, 2013, 05:07:17 pm » |
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
Sr. Member
Karma: 9
Posts: 387
|
 |
« Reply #1 on: January 19, 2013, 05:17:48 pm » |
http://learn.adafruit.com/rgb-led-strips/usageThat 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
Edison Member
Karma: 18
Posts: 2230
Per aspera ad astra.
|
 |
« Reply #2 on: January 19, 2013, 07:50:16 pm » |
How long is your strip? 5m would require transistor, less than 1m you can do with ULN2003/ULN2803
|
|
|
|
|
Logged
|
|
|
|
|
Beijing
Offline
Full Member
Karma: 3
Posts: 181
Skype name habib.derbyshire
|
 |
« Reply #3 on: January 19, 2013, 08:27:30 pm » |
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
Newbie
Karma: 0
Posts: 12
|
 |
« Reply #4 on: January 19, 2013, 09:21:11 pm » |
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
Full Member
Karma: 3
Posts: 181
Skype name habib.derbyshire
|
 |
« Reply #5 on: January 19, 2013, 10:05:07 pm » |
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
Newbie
Karma: 0
Posts: 12
|
 |
« Reply #6 on: January 20, 2013, 12:20:29 am » |
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
Full Member
Karma: 3
Posts: 181
Skype name habib.derbyshire
|
 |
« Reply #7 on: January 20, 2013, 12:27:34 am » |
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
Online
Brattain Member
Karma: 270
Posts: 17052
Available for Design & Build services
|
 |
« Reply #8 on: January 20, 2013, 12:30:26 am » |
http://www.titanmec.com/doce/product-detail-217.htmlSend the correct data to the part - it has PWM control built in.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 12
|
 |
« Reply #9 on: January 20, 2013, 12:36:31 am » |
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
Online
Brattain Member
Karma: 270
Posts: 17052
Available for Design & Build services
|
 |
« Reply #10 on: January 20, 2013, 01:03:56 am » |
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
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 12
|
 |
« Reply #11 on: January 20, 2013, 01:15:02 am » |
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
Online
Brattain Member
Karma: 270
Posts: 17052
Available for Design & Build services
|
 |
« Reply #12 on: January 20, 2013, 02:54:11 pm » |
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/SPISet the SPI divisor to 1/16 for 1 Mbps data rate, and send out the three bytes of data 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
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 12
|
 |
« Reply #13 on: January 20, 2013, 08:54:45 pm » |
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
Newbie
Karma: 0
Posts: 12
|
 |
« Reply #14 on: January 21, 2013, 06:43:17 pm » |
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
|
|
|
|
|
|