Shop OBEX P1 Docs P2 Docs Learn Events
Ws2811/2812 Programming Help Needed - Page 2 — Parallax Forums

Ws2811/2812 Programming Help Needed

2

Comments

  • JonnyMacJonnyMac Posts: 8,963
    edited 2015-01-31 01:06
    You need budget (for safety) 60mA per LED. If you don't, you'll be sorry. Find a 2A wall-wart or bigger.

    For my big projects I order the 5V/10A power supplies from Adafruit. Will be helping friends with a display that will use three of them to safely power everything.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-01-31 01:13
    That explains why a 650ma runs 10. So, In a pinch, since it is DC power can I connect multiple 5V supplies to obtain more amps?
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-01-31 01:30
    I found a 2.4 amp so will try that. If it is dead I can revert to the Tenergy power pack I just bought as it says it pushes 5V 2.1Amp. Thanks for the help all. I will try to remember and get a video of everything before game time. Go Seahawks!!
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-01-31 07:27
    NWCCTV wrote: »
    In a pinch, since it is DC power can I connect multiple 5V supplies to obtain more amps?

    Sort of. It's not a good idea to link the 5V lines together since they're unlikely to exactly match and some regulators get hot when their output is higher than the voltage they produce.
    You could use multiple supplies if you isolate the 5V side of connection. You could have different supply and ten or so LEDs. I'm not positive this is okay. The WS2811 can pass current through it's I/O pins and I don't know is using multiple supplies will cause a problem the logic levels (it shouldn't). The grounds all need to be connected together.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-01-31 08:46
    Here are a couple more methods.
    pub chaseSingleAlternate(color1, color2, ms1, ms2, count) | ch, maxIndex
    
      maxIndex := strip.num_pixels - 1
      repeat count
        repeat ch from 0 to maxIndex                  
          strip.set(ch, color1)
          pause(ms2)
          if ch > 0       
            strip.set(ch - 1, color2)
          pause(ms1)    
          strip.set(ch, 0)
                                                           
    pub chaseWithBackground(foreground, background, ms, count, size) | maxLed, maxIndex, head, tail  
    
      maxLed := strip.num_pixels - 1
      maxIndex := maxLed + size
      
      strip.set_all(background)
      
      repeat count
        repeat head from 0 to maxIndex
          tail := head - size
          if head =< maxLed
            strip.set(head, foreground)
          if tail => 0
            strip.set(tail, background)
          pause(ms)
              
    

    The method "chaseSingleAlternate" sets the LED which had just been blue to green. Make sure and try out different timing values to find a look you like.

    The "chaseWithBackground" keeps the background LEDs a second color rather than off.

    Again, I haven't tested these. I often end up posting bad code when it's untested.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-01-31 11:43
    I will test a bit later. Even with a 2.4Amp 5V Wall Wart when the Blue/Green are on together only 10 LED's light up. I am at 14 right now and all 14 work except when it gets to the Blue/Green together. Any suggestions? I am thinking of maybe splitting the power up after 10.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-01-31 11:46
    Which part of the code runs the Blue/Green together? I am thinking of maybe eliminating that part for now as I am running out of time.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-01-31 12:17
    NWCCTV wrote: »
    I will test a bit later. Even with a 2.4Amp 5V Wall Wart when the Blue/Green are on together only 10 LED's light up. I am at 14 right now and all 14 work except when it gets to the Blue/Green together. Any suggestions? I am thinking of maybe splitting the power up after 10.

    You can try reducing the brightness.

    I set the "BRIGHTNESS" constant to 128 ($80 in hex). Jon's original code didn't include an overall brightness constant but the values he used was equivalent to having the brightness set to 32. You can try reducing the brightness to 32 or even lower and see if that helps.

    I'm almost afraid to ask. Do you have decoupling capacitors on the LEDs? My little boards and all the other WS2812 boards I've used or seen have a 0.1uF cap either next each LED or sometimes shared between two LEDs (the NeoPixel rings share caps between two LEDs). These caps aren't optional.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-01-31 12:19
    Each LED has a resistor and cap on them. That is how they arrived.

    So where is that code located? I am not seeing it and am sure I am just half blind right now!!! I only need it for the specific code that mixes Blue/Green.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-01-31 12:24
    Line 46 of the last version I posted.
    con
    
      STRIP_LEN = 10'21
      [b]BRIGHTNESS[/b] = $80              '' How bright should LEDs get?
                                    '' The value of BRIGHTNESS
                                    '' should be between zero and
                                    '' 255 ($FF).          
      BLUE_ = $FF_00_00
      GREEN_ = $00_FF_00
      
    

    You can use ctrl+f to "find" words in a program. I often use this to find where a constant is defined or where all instances of a variable occur.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-01-31 12:25
    Make sure you have the "STRIP_LEN" constant set to the number of LEDs you're trying to use.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-01-31 12:30
    Yea, I am changing STRIP_LEN as I attach each LED. I like the brightness of the of the LED's so would rather just remove the Blue/Green merging if at all possible, unless there is a way to just dim that portion.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-01-31 12:43
    Changing to 32 did not work.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-01-31 12:54
    You can either comment out the calls to methods using both colors at once or use zero as one of the color parameters to have the method use a single color.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-01-31 12:57
    OK. Where do I do that one? I think I will try the zero idea.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-01-31 13:08
    NWCCTV wrote: »
    OK. Where do I do that one? I think I will try the zero idea.

    In the first method "main".

    Here's an example of using zero as the background in one of the methods I added. Starting at line 90.
    chaseWithBackground(blue, 0, 167, 1, 6)
        chaseWithBackground(green, 0, 167, 1, 6)
        strip.set_all(0)
        pause(100)
    

    The "extra_from_duane" method doesn't use colors as parameters when called. There are a couple of constants which set the limits of the which colors are blended but it would probably just be easier to comment out the last three lines of the method "main" to remove the call to the "extra_from_duane" method with it's accompanying pause and LED clearing.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-01-31 13:21
    When I try it like this I get an error. And how do I post code now???

    [//code//] extra_from_duane(20_000) ' max allowed time is 26_500 longer intervals will cause rollover
    strip.off
    pause(100)
    ' chaseSingle(blue, green, 167, 167, 2)
    ' strip.set_all(0)
    ' pause(1)
    chaseWithBackground(blue, 0, 167, 1, 6)
    chaseWithBackground(green, 0, 167, 1, 6)
    strip.set_all(0)
    pause(100)
    [//code//]
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-01-31 13:26
    Is it possible to use a higher voltage wall wart or will that fry my LED's?
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-01-31 13:28
    NWCCTV wrote: »
    how do I post code now?

    If you click on "Reply With Quote" to a post with code, you can see the code tags used.

    What was the error message?
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-01-31 13:29
    NWCCTV wrote: »
    Is it possible to use a higher voltage wall wart or will that fry my LED's?

    I haven't used those particular LEDs. In general 5V devices will tolerate up to 5.5V.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-01-31 13:34
    Expected an instruction or variable
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-01-31 13:35
    extra_from_duane(20_000) ' max allowed time is 26_500 longer intervals will cause rollover
        strip.off
        pause(100)
       ' chaseSingle(blue, green, 167, 167, 2)
        'strip.set_all(0)
       ' pause(1)
        chaseWithBackground(blue, 0, 167, 1, 6)
        chaseWithBackground(green, 0, 167, 1, 6)
        strip.set_all(0)
        pause(100)
    
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-01-31 13:37
    I am still confused as to why a 5V 2.4 Amp Wall Wart will only push 10 LED's when color mixing.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-01-31 13:42
    Here is the archived version of what I am using. I commented out the 3 lines. It will not Archive with the code you posted since there is an error.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-01-31 14:11
    NWCCTV wrote: »
    It will not Archive with the code you posted since there is an error.

    Does the code you're using have the "chaseWithBackground" method?

    The original code ("modified_tm1803_seahawks_swappedC.spin") had:
        chaseWithBackground(blue, green, 167, 1, 6)
        chaseWithBackground(green, blue, 167, 1, 6)
        strip.set_all(0)
        pause(100)
    
    

    I changed it to:
        chaseWithBackground(blue, 0, 167, 1, 6)
        chaseWithBackground(green, 0, 167, 1, 6)
        strip.set_all(0)
        pause(100)
    
    

    Using zero instead of the color shouldn't cause a problem.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-01-31 14:17
    I'm using the same code that I posted in the Archive. I tried the tm version last night and it made all LED's on and white. I am OK with the code that is in the Archive if I can just change the Blue/Green to one color at a time.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-01-31 16:47
    NWCCTV wrote: »
    I'm using the same code that I posted in the Archive. I tried the tm version last night and it made all LED's on and white. I am OK with the code that is in the Archive if I can just change the Blue/Green to one color at a time.

    I'm guessing the LEDs you tried the code on were WS2812 LEDs?

    The two drivers are pretty similar. Jon has a few more methods in his WS2812 driver than the "tm" driver has. Rather than change the "tm" driver, I just copied Jon's WS2812 methods into the parent object for the "tm" demo. I think the methods in the "tm" demo should work in the WS2812 demo.

    Any method which has two color parameters should work with one of the colors set to zero (though it might not look great).
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-01-31 17:08
    Since I am getting short on time what code do I need to comment out to keep the colors from merging? I think that will be fine for the time being. I can mess with it more after the game.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-01-31 19:48
    I am having a tough time figuring out what to comment out so the Green/Blue does not merge.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-01-31 20:27
    Well, Not sure what the heck I did but the merge colors is gone now and everything is working just how I want it. Thanks for all the help and enjoy the game if you are a football fan!!!
Sign In or Register to comment.