Shop OBEX P1 Docs P2 Docs Learn Events
Simple RGB LED strip control in Spin or C on Propeller Activity Board — Parallax Forums

Simple RGB LED strip control in Spin or C on Propeller Activity Board

dmagnusdmagnus Posts: 271
edited 2014-09-12 08:20 in General Discussion
I'm putting this in the General Discussion forum for now because it isn't actually a project - yet.
Somewhat inspired by xanadu's "Propeller RGB VU Meter" project, I decided to embark on a small project to learn about RGB LEDs.
Eventually, I would like to help a friend make some light displays for his three piece band that are relatively inexpensive, yet somewhat interesting in that they produce random flashing colors in response to each individual instrument.

But that's a long way off. I have been looking at Brilldea's Instructable for his panels and that is similar to what I want to do. First, I have to crawl before I walk.


I'm a total novice at this stuff, have some understanding of C and Spin. I plan to use a Propeller Activity Board initially to learn on.


I bought a reel of 150 RGB LEDs on Amazon for $20 and they seem to be adequate for what I want to do. They came from LED Wholesalers. Unfortunately, they didn't include a spec sheet or anything. Some of the specs on the package:
LED: 150 x 5050 SMD
Input voltage: 12v DC
Power: 36 watt
5M roll, 2086RGB
They have four leads marked +12V, B, R, G. I think this means it is a "Common Anode" string?


I have tried them with a 12v wall wart and they work fine. Plugging the +12v into the positive side of the supply and one or more of the other three provides whatever color or combination is plugged in.


What I want to do initially is hook them up to my PAB and control them with Spin (or C).


I plan to cut 10 or 15 off of the string so I have something that is easy to work with and doesn't require a lot of power. Which brings up my first question:
The full string has a connector on the end that looks like a female connector for stringing more LEDs, But, is there some kind of termination in there? I doubt it because I think the three color leads are the "ground" for the circuit - right?

The big question is can I hook the + lead to +5 on the PAB and then the other three to, say p0, p1, p2 on the breadboard through resistors?
What value of resistors should I use?
If the whole string of 150 LEDs uses 36 watts (3 amps?), then each LED should use about .02 amps (20 milliamps?). If I use 15 in a short string, that would be .3A or 1/10th of the total. Is my math right?
Not sure how to calculate the resistor value or what the pins on the PAB can handle.


Then I need to figure out how to control them. If someone could steer me to a thread or something with some simple code I would appreciate it. I have looked around on the Forum and everything seems to be way more than what I am looking for right now. I'll keep looking.

The main thing I am looking for now is the electrical stuff - can I hook this thing to a PAB and, if so, how to do it safely.
Thanks in advance

Comments

  • dmagnusdmagnus Posts: 271
    edited 2014-04-04 12:15
    I gave up on the strip for now, got some Radio shack RGB's (26-0028) and I've got them so I can turn them on. Now trying to figure out how to send PWM or something to them to control the brightness of each color so I can get mixtures.
    I've got pulse_out in C lighting them up, but that's not working for varying anything. I just get full on for all three colors...
  • xanaduxanadu Posts: 3,347
    edited 2014-04-04 12:33
    Those strips are basically series parallel circuits. Usually 3 LEDs in series w/ resistor, parallel'd along the strip. The end termination is just to add more strips.

    Can you post a picture of the strip showing at least 6 LEDs?

    You're going to need a bunch of power to do this. No way you can connect it to any microcontroller directly.

    The best thing to do is to get an accurate reading on how much power each color on the strip uses at full brightness. To do that I use my bench power supply, if you have a multimeter with current reading in the AMP range you can put it in series with the strip.

    Once you know what each color draws at max intensity, add another 33% (per color, not the entire strip) to that and we should be able to find you a good FET to power them with.
  • xanaduxanadu Posts: 3,347
    edited 2014-04-04 12:35
    dmagnus wrote: »
    I gave up on the strip for now, got some Radio shack RGB's (26-0028) and I've got them so I can turn them on. Now trying to figure out how to send PWM or something to them to control the brightness of each color so I can get mixtures.
    I've got pulse_out in C lighting them up, but that's not working for varying anything. I just get full on for all three colors...

    That's a great way to start, make sure you use a transistor to power the LED. It doesn't matter how little current one LED draws, it's not worth toasting an IO pin over adding a resistor and transistor.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-04-04 12:44
    I'm not quite sure of exactly what you're trying to do but do proceed with caution (as it appears you are). You can't drive strands of LEDs directly from the Activity Board. You need some sort of circuit to take care of the high current stuff for you.

    You don't want to sink current directly with a Propeller I/O pin from these LEDs running off of 5V or higher.

    You could use extenal ICs to control LEDs. In my RGB LED array project, I'm using additional chips to both drive the anodes and control the cathodes. The Prop just controls the logic to these chips it doesn't provide or sink the LED current directly.

    IMO, the easiest way to deal with RGB LEDs is to use the specialty chips available to drive RGB LEDs. I've used both the WS2801 chips and the WS2811 chip (which is built in to the LED) to drive RGB LEDs. The LEDs with the WS2811 chip built in are called WS2812 LEDs aka NeoPixel.

    Another way to add RGB LEDs to a project is to hack the RGB Christmas lights (LEDS).

    I'll add links to these various projects in a bit.

    Edit: I hadn't seen Xanadu's warnings about driving the LEDs directly. I see we agree about this.
  • xanaduxanadu Posts: 3,347
    edited 2014-04-04 12:48
    BLEDi = variable for repeat loop
    BLED = LED pin

    Don't forget to define and init the IO pin for the LED
        repeat until BLEDi == 100
          CTRA := %0_0110<<26 + 2 ' 2 can be any number the higher it is the faster the transition
          FRQA := $7FFF_FFFF/50 * BLEDi 
          BLEDi := BLEDi + 1
          waitcnt(clkfreq / 15 + cnt)
    
  • xanaduxanadu Posts: 3,347
    edited 2014-04-04 13:41
    Pending confirmation on common anode/cathode and current consumption, a P or N channel MOSFET should be able to handle each individual channel. Let us know more about the strip.
  • dmagnusdmagnus Posts: 271
    edited 2014-04-04 13:49
    Found J-Mac's jm_bam_rgb in spin and it works fine. I'm varying the intensity of each of the three colors,etc. I'm in learning mode, so this stuff is going to take awhile.
  • dmagnusdmagnus Posts: 271
    edited 2014-04-04 14:29
    I put all the information in the first post about the strip. It is 5m long and contains 150 LEDs. I never intended to use the whole thing, but I thought it was an inexpensive way to get a whole bunch of LED's to work with. I cut a dozen off of the main strip for experimentation. The strip requires 12v to the Anode (I think - it's marked +12v) Obviously, I can't run it from the Propeller Activity Board, so I will need some kind of controller - I've learned that much so far. That's why I went over to my local RS today and bought 3 or 4 of their single RGB LED's, one of which I have working in spin with JMac's spin object.
    I have Brilldea's LED Painter II-8 on order, which I think I'll use as a driver for the "big" project - probably need a couple of them eventually but, as I said, that's a ways off. They will be controlled with the Propeller.
    I put some pictures of the short length of the strip in my Albums under RGB Strip.
    I'm not up on the MOSFETs, etc. so I will probably wait now for the Brilldea stuff.
    Meanwhile, I'm going to continue to experiment with my RS LEDs - I'm learning as I go. I have managed to get one hooked up, resistor values calculated and turning on and off and fading from one color to the other.
  • xanaduxanadu Posts: 3,347
    edited 2014-04-04 15:20
    I recommended MOSFETs thinking the strip would stay whole. If that is not the case you should still try to figure out how much each segment draws.

    The LED Painter II-8 individual channels can only handle up to 150ma each. That is a stretch for even a single segment, 3 RGB LEDs, 3 LEDs each, that is 9 LEDs, divided by 150ma gets you 16ma per color per RGB LED. That would definitely limit you to one 3 RGB LED segment per LED Painter II-8 channel, and even then it is still a bit under powered because that doesn't add the heat dissipation of the resistors either.. I think it would shorten the life of your LED painter.

    I probably shouldn't say anything else until you say how you want to use the LEDs. PM me a diagram if needed.

    EDIT: I guess you could use one channel per one color per strip on the painter in which case that would be fine, I was thinking one channel per strip, but you could use more than one channel per strip. Maybe someone with better experience with the LED painter could chime in here...
  • dmagnusdmagnus Posts: 271
    edited 2014-04-05 05:01
    First off, thank all of you for your help. I'm not really far enough along in this project for it to be a "project" yet. Eventually, I will have some diagrams and plans for what we want to do. Right now, all we have is a basic idea.
    I hooked the short strip of 12 LEDs up to an adjustable power supply set at 12v. I used an ammeter in line with the 12v and measured each color. Green was 86mA, Blue and Red were 82mA each.
    As soon as I can find my solder station (short story - 40 something daughter moved in and my Man Cave is gone) I will reattach the short strip and check the full roll of 150.
    One thing I have learned - working with this stuff on a TV table in the living room is not optimal. I want my Man Cave back!
    I think, for the application we have in mind, we will need at least three LP II-8 and probably individual power supplies for each of the three panels.
    It will be similar to Brilldea's Demo on the Instructable.
  • xanaduxanadu Posts: 3,347
    edited 2014-04-05 17:54
    Closer to 38 watts than the advertised 36... If your bench top power supply can't put out that kind of juice you can always use a car battery.
  • atexit8atexit8 Posts: 13
    edited 2014-09-11 11:54
    dmagnus wrote: »
    First off, thank all of you for your help. I'm not really far enough along in this project for it to be a "project" yet. Eventually, I will have some diagrams and plans for what we want to do. Right now, all we have is a basic idea.
    I hooked the short strip of 12 LEDs up to an adjustable power supply set at 12v. I used an ammeter in line with the 12v and measured each color. Green was 86mA, Blue and Red were 82mA each.
    As soon as I can find my solder station (short story - 40 something daughter moved in and my Man Cave is gone) I will reattach the short strip and check the full roll of 150.
    One thing I have learned - working with this stuff on a TV table in the living room is not optimal. I want my Man Cave back!
    I think, for the application we have in mind, we will need at least three LP II-8 and probably individual power supplies for each of the three panels.
    It will be similar to Brilldea's Demo on the Instructable.

    Just wondering if you have progressed further on this?

    I bought a 5m strip RGB WS2812B controller LED strip on eBay. I cut it into 5 individual strips serially connected.
    It basically is like a 30 x 5 matrix since each 1m has 30 LEDs.
    I am writing to each RGB LED to create a scrolling message with Arduino Uno.

    Now that I have a P8X32 QuickStart board, I am hoping to do the same thing.
  • __red____red__ Posts: 470
    edited 2014-09-11 17:15
    https://github.com/redvers/dc22hack

    The code is ugly, but it runs this:

    https://www.youtube.com/watch?v=cwO17EsPX-M

    If you need any help to make sense of it, feel free to ask.
  • atexit8atexit8 Posts: 13
    edited 2014-09-12 08:20
    __red__ wrote: »
    https://github.com/redvers/dc22hack

    The code is ugly, but it runs this:

    https://www.youtube.com/watch?v=cwO17EsPX-M

    If you need any help to make sense of it, feel free to ask.


    That is pretty cool!

    Thanks!
Sign In or Register to comment.