Shop OBEX P1 Docs P2 Docs Learn Events
LED Light Strip - Individually Adressable — Parallax Forums

LED Light Strip - Individually Adressable

JBWolfJBWolf Posts: 405
edited 2015-01-24 05:30 in Propeller 1
I bought an RGB LED strip with individually adressable LED's... but did not get a controller with them because I wanted to make my own color routines with the propeller.
I am unfamiliar with exactly how these work for adressing, can someone give me a starting place? I would like to learn how to trigger each LED color independently.
Says each LED has an WS2811 IC built in.
Thanks!
J
«13

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-09-16 15:19
    I think the WS2811 and WS2812 use the same protocol.

    Here's my WS2812 "NeoPixel" project.

    There's a driver in the OBEX by JonnyMac (which I used in my project). Let me know if you need help finding it.

    BTW, I found the NeoPixels very sensitive to noisy power supplies. If I had nice clean power, I could use 3.3V logic with the NeoPixels but if I used a switching regulator I had to use a logic level shifter. Someone else in the forum had a similar issue with the switching regulator on the PropBOE.
  • JBWolfJBWolf Posts: 405
    edited 2013-09-16 15:26
    Doh, And of course now I find that JMac already wrote an OBEX :D
    had to search for WS2812
  • JBWolfJBWolf Posts: 405
    edited 2013-09-16 15:27
    cool I ll check it out, thx duane
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-09-16 15:35
    I just purchased 100 individual WS2811B (I think the "B" version is easier to solder (I think I learned that from Tubular)).

    I need to figure out how I'm going to use them.
  • JBWolfJBWolf Posts: 405
    edited 2013-09-16 16:03
    JMac's obex works great but it keeps locking up with anything over 32 led's assigned.
    Any number at all over 32 and it runs for about 3-5sec then the prop chip locks up.
    Johnny, you there by chance? :)
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-09-16 16:34
    JBWolf wrote: »
    JMac's obex works great but it keeps locking up with anything over 32 led's assigned.
    Any number at all over 32 and it runs for about 3-5sec then the prop chip locks up.
    Johnny, you there by chance? :)

    What demo are you using to test the code?

    I'll take a look at it. I'd like to help if I can to save JonnyMac the trouble (so he has time to write other cool drivers).

    I'll download a fresh copy of the driver from the OBEX incase it has the demo you're using.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-09-16 16:42
    Looking at a fresh download, I see two places where you'll need to change the code.

    First in the Demo object change:
    pub main | pos
    
      strip.start(LEDS, 3)                                          ' start led driver (72 leds)
    
    
    

    To:
    pub main | pos
    
      strip.start(LEDS, strip#MAX_LEDS)                                          ' start led driver (maximum allowed leds)
    
    
    

    or
    pub main | pos
    
      strip.start(LEDS, 72)                                          ' start led driver (3 leds)
    
    
    


    The first option will ensure you don't overflow the buffer is you forget to change MAX_LEDS. Though now that I think about it, the code limits the number of LEDs in the Start menu to MAX_LEDS so I'm not sure why you had the Prop freeze on you.

    You'll need to change the MAX_LEDS in the driver from 64 to 72.
    MAX_LEDS = 72 '64                                                 ' adjust as required
    
    

    IIRC, there isn't a limit to how many LEDs can be chained together. The update rate just keeps getting slower the more LEDs there are.
  • JonnyMacJonnyMac Posts: 9,163
    edited 2013-09-16 17:27
    JMac's obex works great but it keeps locking up with anything over 32 led's assigned.

    I am running 40 LEDs on the Adafruit 8x5 shield connected to a Propeller ASC. All 40 LEDs light up and I've written several little demos for a friend that is playing with that combo -- including a very small version of Conway's Game of Life (that changes color each time through).

    The attached photo isn't great, but clearly shows 40 lit WS2812 LEDs.
    640 x 427 - 268K
  • JBWolfJBWolf Posts: 405
    edited 2013-09-16 18:00
    it seems to be something with the 'color_chase' at the beginning.
    I'll try to post a video, but it always locks up the prop just a few sec after beginning... cannot use the reset button either.
    If I remove the color chase at the beginning, it runs fine
  • JonnyMacJonnyMac Posts: 9,163
    edited 2013-09-16 18:12
    I just updated my driver for 72 LEDs, change the demo code to 72 LEDs, and ran it on my Propeller ASC+ with the Adafruit 5x8 shield. No problems. I'm pretty confident that issue is in your hardware and not in the driver. Perhaps after 32 LEDs you're drawing enough current out of the supply to create a problem after a few seconds. Try to write some code that uses the .colorx() method with a very low power setting (32) -- see if that changes behavior.
  • JBWolfJBWolf Posts: 405
    edited 2013-09-16 18:16
    I know these are higher power led's, not sure what their draw is but I'm supplying 2A to the LM2940T and running both the prop and the leds off it
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-09-16 19:54
    JBWolf wrote: »
    I know these are higher power led's, not sure what their draw is but I'm supplying 2A to the LM2940T and running both the prop and the leds off it

    Use a separate power source for your Prop until you're sure it's not the power supply causing the trouble (which I bet it is).

    If you can't even reset the Prop, it's not software.
  • JonnyMacJonnyMac Posts: 9,163
    edited 2013-09-16 21:14
    At max current (full white) those LEDs are consuming about 60mA each. The LM2940T is a 1A regulator. I'm guessing the regulator is overheating and shutting down. Again... you can write a bit of code that turns on your LEDs using a dim color to see if they work (without stressing the regulator).

    Like this:
    pub main
    
      strip.start(LEDS, 72)
      pause(10)
    
      repeat
        strip.set_all($06_00_00)
        pause(333)
        strip.set_all($00_07_00)
        pause(333)
        strip.set_all($00_00_08)
        pause(333)
    


    BTW... I just created a WS2801 QuickStart "shield" for a client last week and used an LM1084 (5A) regulator.
  • JBWolfJBWolf Posts: 405
    edited 2013-10-07 00:00
    ok I will give the 1084 a try... makes sense to me as using a 1A supply causes dropout... but is also the limit of the 2940.
    The processor stops responding and I have tried it on 2 completely different boards.
    The lockup happens on any of the rainbow or color chase methods... only single color fading is stable.
    I suppose fading from single colors only required 1/3rd of max current draw.
    I found this LM1084IT on digikey, a bit expensive but I will give it a try :)
    I probably should put a heatsink on that!

    BTW anyone who goes through a lot of high power TO220 regulators might be interested in this:
    100x TO220 Heatsink
  • JBWolfJBWolf Posts: 405
    edited 2013-10-07 00:34
    Just bought a few L1084 on ebay... decent deal, supposed to be fast shipping.
  • JBWolfJBWolf Posts: 405
    edited 2013-10-07 03:31
    Would putting 2x LM2940 in parallel double the amperage? or dont they work that way
  • JonnyMacJonnyMac Posts: 9,163
    edited 2013-10-07 04:27
    Simpler to go with the LM1084. That's what I used in the project in this thread:
    -- http://forums.parallax.com/showthread.php/150675-For-League-of-Legend-and-Wes-Borland-(Limp-Bizkit)-Fans

    That said, I'm no exploring switching power supplies. We're drawing a lot of current in this project and went so far as to overheat things. If you watch the video very closely you'll see a small pack on the back of Wes's belt; that's the controller (QuickStart plus shield I made). The dark square you see is a muffin fan to keep the electronics cool while the LEDs are running.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-10-07 08:19
    I used one of these cheap switching regulators (LM2596) with 48 WS2812 LEDs.

    As I mentioned earlier, I had to use level shifters between the Prop and LEDs when I used the switching regulator. IMO, it's worth the bother of adding a level shifter in order to use a switching regulator. A switching regulator should not get nearly as hot as a linear regulator. Your project will run on less power with a switching regulator compared with a linear regulator which can be a big deal if you're using batteries to power the LEDs.

    How many LEDs are you planning on using?
  • JonnyMacJonnyMac Posts: 9,163
    edited 2013-10-07 09:11
    IMO, it's worth the bother of adding a level shifter in order to use a switching regulator.

    I agree, and alway use them (favorite is the TC4427) with my client projects.
  • JBWolfJBWolf Posts: 405
    edited 2013-10-07 23:46
    How many? between 140 and 300 lol.
    I'm using led strips from ebay which have either 72 or 144 leds per meter.
    Right now Im testing with a single 72/m strip, but I will need to control up to 4x that on a single prop chip.

    I believe I have that exact LM2596 board... you just dialed that to 5v, connected to LED's and bridged the ground into the prop correct?

    I dont know about level shifters yet... I see it is just a mosfet, but how are you using it?
    What does a level shifter do?
  • JBWolfJBWolf Posts: 405
    edited 2013-10-08 01:40
    I'm having a bit of trouble following the code... it jumps around so much and is creating values I cannot figure out off the top of my head.
    For example, I would like to start by learning how to edit the rainbow cycle... all I am trying to figure out is how to turn the led's off in reverse order. So the final effect would be the rainbow cycle writes colors to the end of the 'max led', then turns them off in reverse order.

    here is the rainbow cycle method:
    pub rainbow_cycle(ms) | pos, ch 
    
      repeat pos from 0 to (255 * 5)
        repeat ch from 0 to strip.num_pixels-1
          strip.set(ch, wheelx(((ch * 256 / strip.num_pixels) + pos) & $FF, 80))
          pause(ms)
    

    Here is what I tried to do:
    pub rainbow_cycle2(ms) | pos, ch
    
    repeat
      repeat pos from 0 to (255 * 5)
        repeat ch from 0 to 71
          strip.set(ch, wheelx(((ch * 256 / strip.num_pixels) + pos) & $FF, 80))
          pause(ms)
    
     waitcnt(clkfreq + cnt)
          
     ' repeat pos from (255 * 5) to 0
        repeat ch from 71 to 0
          strip.set(ch, $000000)
          pause(ms)
          
      waitcnt(clkfreq + cnt)     
    

    But it just goes through the normal rainbow cycle and sits there.. I have tried everything from using $000000 to strip.set(ch, (strip.color(0,0,0)))
    I just cannot figure this out. I thought the color values were $RRGGBB... so why cant I use strip.set(ch, $RRGGBB).
    So for example turning off the first LED: strip.set(1, $000000).... then the 2nd with strip.set(2, $000000).
  • JBWolfJBWolf Posts: 405
    edited 2013-10-08 01:53
    edited - figured it out
  • JBWolfJBWolf Posts: 405
    edited 2013-10-08 02:02
    I'm trying to break my though process into 2 areas.... identifying a particular LED in the chain, and the color value.
    For the LED adressing, it looks like this is simply counting them from 0 to maxled and storing in variable ch. so to manipulate led #10, ch would equal 10.
    but for the color values, I'm just not getting it.
    What does the "& $FF" do? I get that FF is 255, the max value for a single color, but why is it there after the rest?
  • skylightskylight Posts: 1,915
    edited 2013-10-08 03:06
    From the datasheet the leds work in a ggrrbb format and the values as explained to me in another thread I believe are the hex values for colour and intensity so $FF,$00,$00 would be full green, $FF,$FF,$FF would be full white $00,$FF,$00 would be full red .....etc
  • JBWolfJBWolf Posts: 405
    edited 2013-10-08 04:31
    But what syntax should I use for turning off an LED with "strip.set"?
    I have tried declaring a variable as byte in var, then giving it a value of 000000, but that still doesnt work.
    I have also tried strip#black, strip.color(0,0,0), strip.colorx(0,0,0,0) without results
  • skylightskylight Posts: 1,915
    edited 2013-10-08 05:50
    I havn't looked that deeply but instead of 000000 have you tried $00,$00,$00
  • JonnyMacJonnyMac Posts: 9,163
    edited 2013-10-08 08:43
    I dont know about level shifters yet... I see it is just a mosfet, but how are you using it?
    What does a level shifter do?

    Levels shifters do what their name suggests: they take a signal from one level to another. In this case, the 3.3v output from the Propeller to 5v that is used by the WS28xx. In the costume project there is about three feet of wire between the controller and the LED strings. In order to ensure a good signal at the start of the LED chain I use a TC4427. Yes, it is a dual MOSFET device; in fact, it's primarily used to drive the gate of high-power MOSFETs. I use it to provide a very stiff 5v or ground output on the clock and data lines
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-10-08 09:13
    I used this level shifter from SparkFun. (I purchased it about four years ago.)

    I'll make sure and include some TC4427 devices in my next Digi-Key order.

    Make sure and look through the various methods in Jon's object. There are methods to do a lot of the things you ask about.

    See page 164 of the Propeller manual to learn about the bitwise and operator (&). Use windows calculator in programmer mode to see what $FF is in binary.
  • JonnyMacJonnyMac Posts: 9,163
    edited 2013-10-08 09:13
    What does the "& $FF" do? I get that FF is 255, the max value for a single color, but why is it there after the rest?

    You're skipping over an important detail in that code: it creates a color using the wheel() method. The & $FF truncates a value to eight bits. The wheel method takes an 8-bit value (0..255) and converts it into a 24-bit color for the LED string.

    When your input to wheel() is 0, the color output is $FF_00_00 (pure red). When your input to wheel() is 85, the color output is $00_FF_00 (pure green). Values between 0 and 85 will be a mix of red and green. If your input to wheel() is 170, the output is $00_00_FF (pure blue). Input values between 85 and 170 will be a mix of green and blue. Finally, values between 170 and 255 will be a mix of blue and red.

    By cycling through the 256 values you get a rainbow effect.
  • JonnyMacJonnyMac Posts: 9,163
    edited 2013-10-08 09:19
    I'll make sure and include some TC4427 devices in my next Digi-Key order.

    I have found them to be really useful, especially as you can specify the output voltage with the chip's VDD pin, and it can go up to 18v. A friend of mine had to drive a couple servos on the end of a 20 foot line, and the 3.3v output from the Propeller just wasn't cutting it (I think it was mostly the capacitive load fouling the pulse). We put a TT4427 in the circuit and set its VDD to 5.5 volts -- boom!, servos worked perfectly.
Sign In or Register to comment.