Addressable RGB LED's & LED strips


Closed Thread
Results 1 to 25 of 25

Hybrid View

  1. #1
    Join Date
    Apr 2007
    Location
    Pennsylvania, USA
    Posts
    158

    Default Addressable RGB LED's & LED strips

    Has anyone messed with the addressable RGB LED strips based on the WS2812 5050 led's?

    https://www.sparkfun.com/products/12027

    I am interested in trying one of these, if anyone has any tips to get started on driving these things it is much appreciated. Looks like timing is critical to controlling these things.

    The data transfer protocol use single NZR communication mode. After the pixel power-on reset, the DIN port receive data from controller, the first pixel collect initial 24bit data then sent to the internal data latch, the other data which reshaping by the internal signal reshaping amplification circuit sent to the next cascade pixel through the DO port. After transmission for each pixel,the signal to reduce 24bit. pixel adopt auto reshaping transmit technology, making the pixel cascade number is not limited the signal transmission, only depend on the speed of signal transmission.
    Shawn

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default Re: Addressable RGB LED's & LED strips

    Hello Shawn

    I have done a project using similar led chains. These, however, are done using a relative of the WS2812 you mention. The IC controller I worked with is the SM16716. These leds are pretty easy to control. If you search a bit, you will find a bit of code for each type of IC. Timing is not critical.

    This is how the leds are controlled. (arduino code)
    Code:
    static void show() {
      digitalWriteFast(DATA_PIN, LOW);
      for (int i = 0; i < 50; i++) {
        toggle_clock();
      }
      for (int i = 0; i < LIGHT_COUNT; ++i) {
        write_pixel(i);
      }
      write_blank_pixel();
      delay(1);
    }

  3. #3
    Join Date
    Apr 2007
    Location
    Pennsylvania, USA
    Posts
    158


    Did you find this post helpful? Yes | No

    Default Re: Addressable RGB LED's & LED strips

    As far as I can tell the SM16716 has 2 wires for communication, where the WS2812 only has one. To send a 0 bit you must drive the data pin high for 0.35us and then low for 0.8us. For a 1 bit you drive the data pin high for 0.7us then low for 0.6us. If the data line is low for longer then 50us the strip will reset. I am going to get one and play with it, I will post some code when I get one working

    Datasheet
    Shawn

  4. #4
    Join Date
    Jun 2006
    Location
    California
    Posts
    33


    Did you find this post helpful? Yes | No

    Default Re: Addressable RGB LED's & LED strips

    The translation for the data sheet is a little difficult to follow, it would be nice if there was a better explanation.

  5. #5
    Join Date
    Apr 2007
    Location
    Pennsylvania, USA
    Posts
    158


    Did you find this post helpful? Yes | No

    Default Re: Addressable RGB LED's & LED strips

    Quote Originally Posted by DavidK View Post
    The translation for the data sheet is a little difficult to follow, it would be nice if there was a better explanation.
    Agreed! I will have a string on Friday to play with.
    Shawn

  6. #6


    Did you find this post helpful? Yes | No

    Default Re: Addressable RGB LED's & LED strips

    SPCW pointed this thread out to me on mine, so, i'll fetch what i've got over here...

    I purchased 10 of the little chips off ebay. Becarefull with the chips when soldering them as they are extremely sensitive to heat... I think i've killed 4 out of the 10

    The constant current chip is the WS2811. The chip itself has two speeds, 400KHz or 800KHz. the WS2812 runs at 400KHz and the WS2812B runs at 800KHz.
    Communication to these devices is via a daisy chain with a NRZ type wave form. Each chip has 3 channels with 8 bit PWM.
    So, at 800KHz to send a 1 bit you send a high pulse of duration 0.8uS and the a low of 0.45uS.
    To send a 0 bit you send a high pulse of durations 0.4uS and then a low of 0.85uS.
    Total bit lenght is 1.25uS +-300nS
    The timing tolerances are +-150nS

    Now, the arduino's run entire strings of these things with the MCU running at 8MHz so one would think a 64MHz 18F46K22 would not have an issue...

    However, when i kick out a sequence manually like this...

    Code:
        LATD.0 = 1
    ASM
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
    ;10
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
    ;20
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
    ;30
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
    ;38
    
    
    ENDASM    
        LATD.0 = 0
    ASM
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
    ;10
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
    ;20
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
    ;29
    
    ENDASM
    Everything works fine. Even using GOSUB's to the on and off bit subroutines works without an issue after a little trimming by trial and error (as above).
    However, as soon as i use any sort of IF statement to read from an array, all the timings seem to go out the window and i can not adjust it enough to compensate.

    My calcs say that the 46K22 @ 64MHz makes 64 instructions per uS.
    Even if i cut off all the NOP's from the off time trailing sequence the pic still can not make the calculations (IF condition) within the required time.

    I have tried everything i can think of so far...

    I look forward to people's responses.

  7. #7


    Did you find this post helpful? Yes | No

    Default Re: Addressable RGB LED's & LED strips

    Happy New Year to everybody... I buy a 240 leds strips of ws2812b, waiting for the controllers, that had a big delay from asia y buy a arduino to put this lights in action, but I think that I preffer use this lights with PICs, this is the reason why I am here. How is this program doing? Update? Thanks...

  8. #8
    ainsley's Avatar
    ainsley Guest


    Did you find this post helpful? Yes | No

    Default Re: Addressable RGB LED's & LED strips

    You did not say what the pic voltage was , but assuming it at 5v i would connect the one side of the probe to the 5v and then to a resistor to ground and connect the joined point o the AN0 anaolog port

  9. #9
    Join Date
    Aug 2010
    Posts
    11


    Did you find this post helpful? Yes | No

    Default Re: Addressable RGB LED's & LED strips

    I ebay'd a couple of 60 led/m strips as I am interested in making a "wearable" safety vest for when I am biking. I played with a trinket - which worked fine in its limited capacity - but I wanted more and didnt want to learn another language. I hooked up an oscilloscope and tried getting the code in to light up a single led but PBP and a 16F819 @ 20mHZ coding was not fast enough for the WS2811 timing requirements. I tried using an asm subroutine within PBP for writing to the WS2811's and voila - but no time left for calculations. So, I started reading, more reading, finally ran across a thread with this link to an ASM file which uses the SPI in a 16F767 for a single LED:

    http://wiki.hacdc.org/index.php?titl...asm&oldid=8964

    This guy (credits to David Kaufman) did a great job - I just adjusted config and pic# to my chip and was running in a couple minutes. Few minutes later I had the entire strand running. So I guess my plan is to try and go back to PBP and try to write my calculations out and then call his ASM subroutine for addressing to the led's. Thats the plan anyways - I am a horrible programmer - so if anyone else goes this route and wants to post some code so I can learn more efficient coding and tricks I would be most grateful!!

  10. #10
    Join Date
    Apr 2007
    Location
    Pennsylvania, USA
    Posts
    158


    Did you find this post helpful? Yes | No

    Default Re: Addressable RGB LED's & LED strips

    If you get something working please share it I had zero luck controlling these things.
    Shawn

  11. #11
    Join Date
    Aug 2010
    Posts
    11


    Did you find this post helpful? Yes | No

    Default Re: Addressable RGB LED's & LED strips

    This file is entirely in assembly (I'm not sure how to call assembly subroutines from PBP). The author taught how to light a single RGB, my progress to date is the start of a chaser so it will light 60 rgb's sequentially and do some color shifting (Still lots to learn here). Should load right up in MPLAB (v8.9 used) The changes you may need to make for it to run:

    your chip (must have SPI and 20Mhz)
    your chip config settings
    change nLED for your length of string (60)
    scroll down to delay subroutines to speed up, slow down ...

    The original author taught how to light a single LED. You will easily detect my coding as the extent of my assembly knowledge when I opened his program was nop!ColorStripTest_819.txt

  12. #12
    Join Date
    Feb 2008
    Location
    Michigan, USA
    Posts
    231


    Did you find this post helpful? Yes | No

    Default Re: Addressable RGB LED's & LED strips

    Any one had any luck yet? I just picked up a 8x string and want to play with them. The SPI sounds like and interesting approach.
    Bo

  13. #13
    Join Date
    Dec 2017
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Re: Addressable RGB LED's & LED strips

    you can use the digital strips with the built-in programs,
    most digital led controllers can support the ws2812,sk6812 led,
    or the Remote controller with program inside,it is much easy,
    also the T-1000s,t300k controller are available too,use the lededit software to create the color changing effect,

  14. #14
    Join Date
    Mar 2005
    Location
    CROATIA
    Posts
    38


    Did you find this post helpful? Yes | No

    Default Re: Addressable RGB LED's & LED strips

    Hi,
    best HW driven solution, which i use for years, is that you use SPI internal hw,
    you can make SPI2NRZ circuit with few external parts, digital way (74xxx) or
    analog https://hackaday.com/2014/02/04/ws28...-and-passives/
    like this, i had to tune resistors, for better voltage variation tolerance, but work like this to.

    so, when you have hardware helper, and internal hardware, then you can paly in interrupt later.

    for first step you have to initialise MSSP hardvare on 800kbs with propper flags and registers
    based on your clock and device datasheet. (yes you have to read it few time until get proper setings)
    i actualy deal with 2 mssp paralell in interrupt, so i have time in main loop to play with other things.


    Code:
    for WS_CNT = 0 to number_of_ws
        SSP2BUF = R1[WS_CNT]
        SSP1BUF = R2[WS_CNT]
        SSP1IF  = 0
    ' something litle can feet here if interrupt... i have serial receive routine..
      WHILE SSP1IF = 0 : WEND
        SSP2BUF = G1[WS_CNT]
        SSP1BUF = G2[WS_CNT]
        SSP1IF  = 0
    ' something litle can feet here if interrupt... i have serial receive routine..
      WHILE SSP1IF = 0 : WEND
        SSP2BUF = B1[WS_CNT]
        SSP1BUF = B2[WS_CNT]
        SSP1IF  = 0
    ' something litle can feet here if interrupt... i have serial receive routine..
      WHILE SSP1IF = 0 : WEND
    next WS_CNT
    pauseus 60 ' for latch....
    i hope you will understund directions, i have large code which i optimise for my work, so i
    don't want to share it, but trust me this part i shared is core, all other is playing with it...

    acrually , on slower pic, you can expirience for/next too slow, you can use goto instead, and
    of course, today pic speed is 32mhz+ with internal rc osc+pll, already on .5$ parts, so forget
    old 16f84 parts for this, use kind of 18f46k22 or 16f1827 or part like this....

Similar Threads

  1. RGB led driver ic lpd6803
    By m_flfl in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 4th July 2012, 20:35
  2. RGB led driver ic lpd6803
    By m_flfl in forum General
    Replies: 0
    Last Post: - 29th May 2012, 19:49
  3. Free LED lights and LED strips
    By mistrip in forum Adverts
    Replies: 0
    Last Post: - 18th May 2012, 04:44
  4. RGB LED driver, Any comments?
    By paxmowa in forum Schematics
    Replies: 31
    Last Post: - 7th March 2012, 21:52
  5. RGB LED Matrix
    By ERIK in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 28th June 2008, 07:01

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts