Tuesday, August 7, 2012

Machine 6: Wall-o-Tetris updating 2500 pixels via SPI

I'll update my earlier post at the end of this week. But we're progressing and I thought I'd add a little something.

Challenge #1


Take SPI addressable RGB LEDs like those in the video below and update a wall comprised of 2500 of the little sods quickly enough that it looks okay. The design goal I've set is to get to 25 frames per second, much like TV.  This is not such a big deal for Tetris, but for other animations a fast frame rate such as this is important.

A few dozen to a few hundred pixels is easily updatable from an Arduino  using a single SPI line and a cascade (think daisy chain) of WS2801s. But it doesn't scale well to 2500 pixels at 125mm dot pitch.
2500 x 125 / 1000 = 312.5 metres of daisy chained lights. Two obvious problems surface with this.
  • SPI in this application is good to 2Mhz
  • There is voltage drop over 300 metres and 5v (easily fixable)
  • Besides 2Mhz being the ceiling of device, the WS2801 spec has this to say on long runs...
The Connection and Driving of Cascading Operation The transmit of data over long distance by cascading, the WS2801 integrates push-pull output stage with strong driving capability.  This enables the data and clock to be transmitted up to 6 meters at 2MHz clock frequency. To prevent the reflection, it is necessary to connect a 50Ω resistor at the data input or output port for impedance match. So 6 metres is it, regardless of how many LEDs... I think the phrase rhymes with 'clucking bell'.
So I'm planning 32 SPI buses to keep close to or under that 6 meter ceiling.

There are a few options to achieve this:

  1. Use the Arduino's stack of digital IO pins and some serious bit banginging to emulate in software lots of SPI buses across those pins.
    The chip in the Arduino is not quick enough to do this well.

    Or
  2. Ask good old Sean to come up with a much better plan. By using the fast hardware SPI port on the  chip  (an Atmega 2560) to run at 2Mhz and multiplex that signal with a CPLD.
    The dev board has been ordered, the VDHL has been written and over a couple beers explained to me slowly. No emulation and bit twiddling required. Ace 
Assuming option two works, how many pixels can we push through SPI at 2Mhz? 
  • Each pixel drinks 24 bits, 8 each for Red, Green and Blue.
  • 2 Mhz is 2 million cycles per second. (2,000,000 / 24 bits)  / 25 frames = 3333 pixels!
  • A nice margin over 2500 right? In fact 1.5 Mhz will probably do us just fine. 
Whatho,
Mackintosh

No comments:

Post a Comment