PIC to WS2812B / WS2811 IC


Closed Thread
Results 1 to 7 of 7
  1. #1

    Default PIC to WS2812B / WS2811 IC

    Im sure people have seen the WS2812 and WS2812B's on youtube and ebay.
    They are a tri colour LED with built in constant current controller chip.

    The arduino community is all over them but I've found nothing for pic's, so, i've tried to do it my self and i'm now a little stuck and could do with some help.

    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 was wondering if anyone had any other suggestions?

    Thanks

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


    Did you find this post helpful? Yes | No

    Default Re: PIC to WS2812B / WS2811 IC

    I am also going to be playing with these, but won't have it until the end of the week. Hopefully we can make these things work! Link to my thread
    Shawn

  3. #3
    Join Date
    Apr 2011
    Location
    Welches, Oregon
    Posts
    198


    Did you find this post helpful? Yes | No

    Default Re: PIC to WS2812B / WS2811 IC

    Somewhere here, I looked... I cannot find it... are some code examples for timing execution of code segments; they might be of value to you. Even without, it should be reasonably straightforward to initialize/ start a timer and read the value after to determine exact timing of the If [] Then statements. I have not used the WS LED strings, but I think you don't need help with what is required to do so - only to determine how long what you have takes.

    My understanding of such things is limited, but I can "grok" the frustration of timing routines that are written in Basic, but executed in Assembler. I can think of no simpler way than to have your program do it for you.

    Ah HA! Here: http://www.picbasic.co.uk/forum/showthread.php?t=9350

    One last ting... Have you any numbers for amperage required to run a string of these things? I suspect it could run into the 10's of amps for applications like Christmas lights?
    Last edited by Amoque; - 24th October 2013 at 02:57. Reason: Added link

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: PIC to WS2812B / WS2811 IC

    Each chip is current limited to ~19mA per channel... and there is 3 channels...

  5. #5
    Join Date
    Mar 2014
    Location
    Los Angeles, CA
    Posts
    1


    Did you find this post helpful? Yes | No

    Default Re: PIC to WS2812B / WS2811 IC

    Hello forum! I've got example code working to control a WS2812B LED strip. I used SPI at 15MHz to get the WS2812B to pay attention and work with the 150ns timing. Works well but I'm not savvy enough at squirrel to really get this code running efficiently.

    The full example code is here: https://gist.github.com/nseidle/66d8...-gistfile1-txt

  6. #6
    Join Date
    Dec 2017
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Re: PIC to WS2812B / WS2811 IC

    it seems the sk6812 is faster PWM frequency than the ws2812b,
    and can use the same code as the ws2811,ws2812b

  7. #7
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,796


    Did you find this post helpful? Yes | No

    Default Re: PIC to WS2812B / WS2811 IC

    Why not use APA101 that is more easy to handle?

    Ioannis

Similar Threads

  1. High Speed Serial Comm PC - PIC and PIC - PIC
    By manumenzella in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 16th January 2007, 22:55

Members who have read this thread : 3

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

Tags for this Thread

Posting Permissions

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