I am working on a new and exciting project using WS2812 RGB LEDs
I have done several but this one in my most ambitious..
I want to drive a matrix of 13*13 RGB WS2812 Leds using DMX data that I am receiving from a source, and I want to run this on a standard 16MHz Arduino UNO-type board
DMX data comes in over UART @ 250kbps WS2812 LEDs need to be driven at about 800KHz
Sounds easy at first, but when you look into it you find there are problems
1) DMX can arrive at a rate of 44 frames per second, one 512 byte frame can take 23ms to receive 2) DMX frames can run almost end-to-end 3) Sending 507bytes of RGB data to WS2812s takes 5ms and cannot be done between DMX frames 4) Interrupts cant be used to collect UART data as this might innterupt the WS2812 data flow 5) UART framing error must be continually monitored to stop rogue data packets getting through
13*13 pixel matrix has been chosen as this is the neatest, squarest and largest solution possible using 507 bytes out of a maximum of 512 DMX bytes, with 3 bytes required per WS2812 LED
With all this in mind I have started writing some fast assembler code which does the timing required for running the WS2812 leds (20 cycles per bit), to get the right timing (800KHz) the code has a few NOPs in it. I am going to use these NOPs to interleave the RX DMX assembler task in with the WS one.
To send each WS2812 byte at 800KHz bit rate, I need to send one byte every 10us (8 x 1.25us) One byte of DMX data will arrive every 44us (11 x 4us)
If I stretched out the sending of the WS2812 data by 10% I could send one byte every 11us. Therefore for every 4 bytes of WS2812 data I send, I could recieve ONE DMX byte (4 x 11us = 44us)
I could follow this idea through all the bytes I need to send until I finish reading byte 507, then I can carry on receiving DMX bytes until a further 55us passes by which time I can set the WriteLatch of the WS2812 devices
The data will be arriving slower than I will be outputting, so from the outset I will be writing OLD data to the WS devices, as the new data wont have arrived in time, but this is ok, I will only be ONE frame behind, and that wont be noticable
So, how am I going to drive this with DMX ?
I have found this cracking FREE program called JINX, I can create any size of LED array and send graphic animations, text, video, etc etc out of the USB port, all I need is a cheap and simple USB-DMX dongle (cheap Entec device) to convert this to DMX for my board
As usual, I will be posting updates, info and ideoa as I proceed, ultimately releasing the code when it is in a workable state