Shop OBEX P1 Docs P2 Docs Learn Events
Modifying jm_ws2812 for Neopixel SK6812 RGBW — Parallax Forums

Modifying jm_ws2812 for Neopixel SK6812 RGBW

KednerpoKednerpo Posts: 46
edited 2016-03-26 15:54 in Propeller 1
Hello all,

Has anyone looked at modifying the jm_ws2812 driver to control the newer Neopixel devices that now have a white segment making them RGBW?

Like this one.
https://www.adafruit.com/products/2832

I have looked at the existing code and I know there needs to be a fourth set of numbers to control white.

'- - - - - - - - - -RR GG BB WW
MAGENTA = $FF_00_FF_00

But at this point I have now idea how to modify the processing part of the driver to handle the extra data and send it off to the strip.

Any help would be much appreciated.

Thanks!

Comments

  • I have code to drive these, but I won't be near the machine with the code until late Sunday. I'm only outputting RGB, but it should be trivial to modify it to output RGBW. The RGB only modules take a 4th byte that controls pixel brightness, so the code to send the 4th byte is there, it's just currently a fixed value.

    These chips are really easy to drive because they aren't timing sensitive at all - they're very standard SPI, so to talk to them you set the data pin, toggle the clock pin, repeat until done. It's incredibly simple, and should even work in Spin (though that would be slow).

    The code I have is a PASM driver with a C interface, done in SimpleIDE. If you need a Spin interface you may have to write it.
  • Great!

    I am really looking forward to checking it out. I think I only know Spin right now ( ?all my codes end in .spin? ), but I think this sounds like a great reason to expand my knowledge!

    Thank you so much!


  • Jason, did I miss something? You said it's standard SPI, but the ws2812 is far from SPI - the only similarity being that they're both serial protocols. I visited the Adafruit link above and checked the datasheet and it looks similar to the rgb version. No clock pin available.
  • Ohhhh... Smile - I have a DotStar driver, which is SPI. That's what I thought the original poster meant. I do not have a driver for NeoPixels with the extra white LED. Phoo. Sorry.
  • Jason, Thank you for your eagerness to help.

    David, Thank you for catching that info. You probably saved me days of testing.
  • JonnyMacJonnyMac Posts: 8,929
    edited 2016-03-27 15:15
    as anyone looked at modifying the jm_ws2812 driver to control the newer Neopixel devices that now have a white segment making them RGBW?
    Feel free to modify my code. Before posting, however YOU MUST TAKE MY NAME OFF OF IT. I will be responsible for my errors, but not for yours! :)

    If you insist on attribution (I don't), you may use "Based on code by Jon McPhalen"
  • Thank you Jon,

    I was wondering the proper etiquette and/or policy on editing and re-posting someone else's code.

    At this point I am still figuring out how the existing code works before attempting any modifications. The existing code is very well documented but I don't have a lot of experience yet. After a few evenings of attempts I thought I would ask if anyone was already working on rewriting or modifying your version.

    If I do get to the point where I can contribute something based on your work I will certainly do as you asked and remove your name.
  • I know my interface in Tachyon doesn't really care about how each byte is used as it will just transmit the array and if that array is arranged as RGB or RGBW it doesn't matter. The only difference is at the high level when the array is written is written, that's all, and that is a very easy thing to tweak.

    Whereas before where I defined WHITE as RGB now I specify it as the 4th byte so I can type WHITE 4 LED and the 4th LED will instantly be white vs say MAGENTA 4 LED.

    So hooking up these RGBW LEDs even to any standard WS2812 driver should make them light up except the colors beyond the first LED will be messed up.


  • I'm on the road a lot these days so I have little time to play. It looks really straightforward -- It shouldn't take more than 10 or 15 minutes to modify the driver. I will order parts and create a driver when things settle down for me in a few weeks.

    Kednerpo wrote: »
    Thank you Jon,

    I was wondering the proper etiquette and/or policy on editing and re-posting someone else's code.

    At this point I am still figuring out how the existing code works before attempting any modifications. The existing code is very well documented but I don't have a lot of experience yet. After a few evenings of attempts I thought I would ask if anyone was already working on rewriting or modifying your version.

    If I do get to the point where I can contribute something based on your work I will certainly do as you asked and remove your name.
  • In fact other than redefining WHITE in my Tachyon interface the only other thing I did was change a constant from 3 to 4 and it looks like it is THAT simple.

    BTW, I chuckled as I looked at the Adafruit SK6812 datasheet, it stills uses the old WS2812 3-byte RGB ordering in its diagrams.
  • Peter, Are you looking at the SK6812RGBW datasheet? It is different than the SK6812 datasheet.

    https://cdn-shop.adafruit.com/product-files/2757/p2757_SK6812RGBW_REV01.pdf
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2016-03-28 03:02
    Kednerpo wrote: »
    Peter, Are you looking at the SK6812RGBW datasheet? It is different than the SK6812 datasheet.

    https://cdn-shop.adafruit.com/product-files/2757/p2757_SK6812RGBW_REV01.pdf

    Ah, the link from tronixlabs to the WS2812RGBW datasheet is incorrect then. I went to Adafruit directly and now have the correct datasheet but looking at it they just confirm that they are using 32-bits per LED rather than the 24-bits so what I said about how simple the change is still stands. In my high level code I simply change 3 to 4 and redefine WHITE.

    P.S. The datasheet is a little confusing with it's "data structure of 32-bits" when they draw 3 rows of 12 blocks with the last 4 cells empty!!!

  • P.S. The datasheet is a little confusing with it's "data structure of 32-bits" when they draw 3 rows of 12 blocks with the last 4 cells empty!!!

    Yeah, It does look a little strange.

    The only other thing I noticed is that the data transmission time is a little different.

    WS2812
    T0H .35us
    T1H .7us
    T0L .8us
    T1L .6us
    50us Reset

    SK6412RGBW
    T0H .3us
    T1H .9us
    T0L .9us
    T1L .6us
    80us Reset
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2016-03-28 03:24
    Kednerpo wrote: »

    P.S. The datasheet is a little confusing with it's "data structure of 32-bits" when they draw 3 rows of 12 blocks with the last 4 cells empty!!!

    Yeah, It does look a little strange.

    The only other thing I noticed is that the data transmission time is a little different.

    WS2812
    T0H .35us
    T1H .7us
    T0L .8us
    T1L .6us
    50us Reset

    SK6412RGBW
    T0H .3us
    T1H .9us
    T0L .9us
    T1L .6us
    80us Reset

    Nothing in the chip itself is going to be that particular and can't know how many microseconds this or that took. I reason that this simple bit timing is based on dividing the T0L bit timing by three or multiplying the T0H by three to represent the three phases of a bit, the CLOCK, DATA, and GAP for want of a better word. This is the way I would design it, it has to be logical. I think the SK6812 datasheet at least adheres to the chip timing whereas I think the timings that were derived in the WS2812 were simply from the code that they used to test it :)

  • Good to know.

    I must admit I am not familiar with Tachyon at this point. I will take a look and do some more research.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2016-03-28 03:39
    Check this youtube link where I play with the WS2812 and Tachyon. (Actually there is a better demo video but I just have to find it!)
  • Jon, Thanks for taking a look when you get a chance.

    I have been enjoying the existing drivers for running RGB and am learning a lot from the documentation you include.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2016-03-28 03:58
    Here is that other video:
  • ErNaErNa Posts: 1,742
    Will this run on the IoT5500 too? Can't await to have it ;-)
  • -> Peter

    Nice job on the videos.

    However, I would have expected to see a slogan scrolling across the matrix, such as "Go Forth with TACHYON!" :)

    I would really be interested in seeing a video from you, where you demonstrate the versatility, ease, and power of TACHYON. C is still my language of choice, but it would be interesting to see various aspects of your creation.

    Hope all is well with you... Keep up the good work.

    Bruce
  • idbruce wrote: »
    -> Peter

    Nice job on the videos.

    However, I would have expected to see a slogan scrolling across the matrix, such as "Go Forth with TACHYON!" :)

    I would really be interested in seeing a video from you, where you demonstrate the versatility, ease, and power of TACHYON. C is still my language of choice, but it would be interesting to see various aspects of your creation.

    Hope all is well with you... Keep up the good work.

    Bruce

    Thanks, but that's just me having fun. One day I will do something serious in Forth :)

    As to demonstrating that is pretty much what I do with these videos so I guess you mean something else then. But have a look at these couple then if you haven't seen them yet. There's also a lot of early stuff too.



  • ErNaErNa Posts: 1,742
    We need a class in tachyon. Would be nice to have some boards distributed and then via telnet Peter could help ;-)
  • KednerpoKednerpo Posts: 46
    edited 2016-04-25 04:23
    So this is kind of a big moment for me. I have been playing around with Parallax Propeller for several years now. While I have done a few fun projects and experiments for myself I have never really "finished" them. I mean they work and do what they are supposed to do for the most part, but I have never got them to the point where they were documented and tested and felt they were good enough to upload and share. The attached file is the first one I have ever uploaded to share. It is just a change to an existing driver, and I know It would only have taken a few minutes for more experienced programmers to change, but for me it has taken a few weeks of trial and error and studying.

    It is my version of an updated ws2812 demo and driver.

    I named it the dp_sk6812_demo. It can be set up to run the sk6812RGBW strips or the sk6812 RGB strips. The ws_2812b uses the same protocol as the sk6812 rgb strips so you can run those as well.

    Jon, I removed your name from the programs I made changes to. As I did not make any changes to your jm_io_basic or jm_time programs the demo uses I left your name on them. Is that O.K? Please let me know if there is anything more I need to do to follow proper etiquette or policies. As I said this is my first upload. Thank you!

    [Edit] File re-uploaded 4_25_16. Please find below.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2016-04-25 03:52
    I would think you would leave his name exactly where it is but add a line to say what you've done. Even if you end up completely rewriting everything but it's based on someone else's code you should always acknowledge that fact.

    Note. Think of it this way. If you had written some original code and someone had made a tiny change to it and removed your name, how would you feel?
  • Hi Peter,

    I completely agree. I was only following Jon's instructions.
    JonnyMac wrote: »
    Feel free to modify my code. Before posting, however YOU MUST TAKE MY NAME OFF OF IT. I will be responsible for my errors, but not for yours! :)

    If you insist on attribution (I don't), you may use "Based on code by Jon McPhalen"

    I have re-uploaded the file with "Based on code by Jon McPhalen" and added "Edited by... Darren Payson"

    I also changed the name to just sk6812_demo. The initials in front of the file name is kind of Jon's thing and I felt weird about it.

    Darren
  • You're right, my bad
Sign In or Register to comment.