MCU for holiday project - Page 1
Forum section: electronics / general

author: NivagSwerdna
author_rank: Super Contributor
timestamp: December 21, 2016, 11:55:07 am
content: I've decided to start working on my Christmas lights for 2017....The project is pretty simple... I want to be able to drive up to 8 strings of addressable LEDs using WS2811 or similar chips.Now the timing for these devices is reasonably tight... so for example I need to generate pulses that are 250ns hi/1000ns lo or 650ns hi/600ns lo. i.e. a bit composed of a hi and a low part every 1.25usI think there is a bit of tolerance in these signals so I could possibly get away with a transition every 300ns at a push giving transitions around 3.3MHzTraditionally I have used PIC and clock rates (after FOSC/4) would make that quite challenging in softwarePlease could someone recommend a MCU that could do hardware(i.e. DMA) SPI on eight channels that has a relatively inexpensive development environment entry point.Thanks in advance

author: NivagSwerdna
author_rank: Super Contributor
timestamp: December 21, 2016, 12:20:36 pm
content: I really don't want to go above 64pins if I am building this myself.. PIC32MZ2048EFG064 has 4 SPI and DMA... that's a beastSo I could have 4 channels.... (and make my strings longer)

author: NivagSwerdna
author_rank: Super Contributor
timestamp: December 21, 2016, 12:27:59 pm
content: I have just stumbled across...https://www.pjrc.com/teensy/td_libs_OctoWS2811.html#techSounds like I could just use an existing SBC, Teensy 3.x, to do this... awesome!... I'm still interested in any suggestions that could do 4+ channel DMA based big banging in case I decide to build something later...

author: Wilksey
author_rank: Super Contributor
timestamp: December 21, 2016, 12:40:52 pm
content: Look at Julian Illet's channel on YT, he has been driving Neopixels (WS281x) with a PIC.

author: chris_leyson
author_rank: Super Contributor
timestamp: December 21, 2016, 12:58:57 pm
content: If you are going to use the PIC SPI peripheral to drive WS2811 make sure you use a part with Enhanced SPI or SPI with enhanced buffering, don't remember Microchips exact wording. The standard PIC SPI peripheral inserts one clock cycle delay between 8-bit packets and that is enough to completely mess up the WS2811 PWM timing and then you have to resort to bit bashing routines. The parts with enhanced SPI or enhanced buffering don't insert the extra clock cycle delay.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: December 21, 2016, 01:38:10 pm
content: Quote from: Wilksey on December 21, 2016, 12:40:52 pmJulian uses software bit-banging. I want to use hardware DMA to leave some cycles for other things.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: December 21, 2016, 01:41:27 pm
content: Quote from: chris_leyson on December 21, 2016, 12:58:57 pmThanks. I'll look out for that.

author: chris_leyson
author_rank: Super Contributor
timestamp: December 21, 2016, 02:28:51 pm
content: Hi, a while back I used PIC32MX440F256H on a Pinguino dev board to drive 64x WS2812B using the SPI peripheral. I don't think I used DMA but polled one of the SPIxCON register bits to check TX buffer empty. I don't remember how I packed the WS8212 data stream whether it was 8 or 32 bit words but I was driving the SPI at 2.5MHz and clocking out 3-bits for each '0' or '1' WS2812 bit. Timing was 400/800us or 800/400us for the PWM and worked with no problems. PIC32MX1XX/2XX parts should work as they have enhanced SPI buffering and they're available in 28-pin DIP and can be used with the Microstick dev board. Also, if using 3V3 parts you need to buffer the data to get 5V and you may have to add a series resistor, a few hundred ohms, to get the WS2812s to work properly.I also tried the same or similar code on a PIC24 and it didn't work, that's when I discovered the SPI peripheral waiting an extra clock cycle between transfers.

author: Wilksey
author_rank: Super Contributor
timestamp: December 21, 2016, 04:04:31 pm
content: Ah, sorry, should have read the post properly!Mike from Mikeselectricstuff will probably be best to answer this one, he does all kinds of weird and wonderful things with a PIC32 and LEDs!

author: Buriedcode
author_rank: Super Contributor
timestamp: December 21, 2016, 04:31:16 pm
content: Microchip have an app note using the CLC and SPI peripheral for driving these LED's. Effectively it allows you to write a byte on SPI, and it automatically converts each bit to the format required. I believe this is for 16F only, so will lack DMA and require constant hand holding, but it works rather well: As each LED/pixel requires 3 bytes, you can update a long string rather quickly, certainly quicker than bit banging.http://ww1.microchip.com/downloads/en/AppNotes/00001606A.pdfI tested this on a PIC16F1704 (got loads of these little bad boys) and it worked rather well.With PIC32, the DMA will of course be more handy. It'll map to 4 SPI bytes, or 32-bit wide frame = 1 WS2812B byte. Three writes for each pixel. A simple lookup table can be used to convert. I have no done this (yet) because many SPI peripherals do not send 'back to back' bytes/frames, as its clocked, theres no real need to make gapless transmissions, even though many datasheets show it can be done.Also, PIC32's can have I2S mode which can allow for continuous transmission. For this application its pretty much the same as SPI, the only difference is you have better control over the clock.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: December 23, 2016, 12:13:04 am
content: I discovered that I already have a PIC that supports DMA on a board I devised for another project... PIC24FJ128GC006Although this device was primarily picked for its LCD control I see it has DMA too... I might try using a spare board to generate some signals...

author: senso
author_rank: Frequent Contributor
timestamp: December 23, 2016, 02:33:02 am
content: Would you consider FadeCandy and maybe a RaspberryPi to do some fancy animations and control over network?

author: NivagSwerdna
author_rank: Super Contributor
timestamp: December 23, 2016, 09:59:33 pm
content: Quote from: senso on December 23, 2016, 02:33:02 amJust checked out FadeCandy... that's almost exactly what I intended to homebrew. I really like it.I guess this is rapidly becoming a project that makes no sense and I should stand on the shoulders of others.I like the look of Teensy/Octo community... they seem to be keen in ArtNet. But I also really like the look of FadeCandy. Thanks for the link.I should just pay some $ and put my efforts elsewhere. Thanks