Hi,
Just a quick update on progress.
I have been able to drive WS2801s thruogh the 74HC595 shift register. It was a little flickery (it was a breadboard setup and I was driving them very slowly - proberbly too slowly and I was using the PIs power to run the shift register and the pixels). So I have ordered a couple of humble pi proto boards and some 16A connectors ( http://shop.ciseco.co.uk/k001-humble-pi/ ) ( http://shop.ciseco.co.uk/16a-2-way-pcb-screw-terminal/ ) to give a more stable test setup.
The idea was to keep this project simple - the setup was:
74HC595--------Connection
Q0 to Q3--------Data String 1 to 4
Q4 to Q7--------Clock Strings 1 to 4
MR--------------Vcc
SHCP------------SCLK (PI)
STCP------------CE0 (PI)
OE--------------GND
DS--------------MOSI (PI)
MOSI is the PIs SPI serial data out.
SCLK is the clock that clocks the MOSI data.
CE0 is one of the PIs enable outputs, that enables the object that MOSI is writing to. By default it is normaly high and goes low just before data is sent. The best bit is, it returns high just after the last bit has been sent. Cool as the 74HC595s STCP (basicaly - output the data pin) looks for a low to high input and then outputs the data.
As for the data - I wrote to 4 strings (Q0 to Q3) and had 4 clocks (Q4 to Q7).
Each bit of data was sent twice. The first time with the clocks low and again with the clocks high (the WS2801s register data on the on the clock input - low to high).
This ment a total of 48 writes to send the 24 bits required for each pixel.
To light the first pixel of each string red at a brightness of 255.
Byte sent-----Q0--Q1--Q2--Q3--Q4--Q5--Q6--Q7-------Description
x\0f-----------1---1---1---1-----0---0---0---0--------LSB clock low
x\ff-----------1---1---1---1-----1---1---1---1--------LSB clock high
send 8 times for red element of pixel.
x\00-----------0---0---0---0-----0---0---0---0--------LSB clock low
x\f0-----------0---0---0---0-----1---1---1---1--------LSB clock high
send 8 times for green element of pixel.
x\00-----------0---0---0---0-----0---0---0---0--------LSB clock low
x\f0-----------0---0---0---0-----1---1---1---1--------LSB clock high
send 8 times for blue element of pixel.
(and yes, I could have had one clock and 7 data).
So the bit (no pun intended) I'm working on now is to, take a byte from each of 4 universes. Split the byte into bits, take the first bit from each byte and combine them with the clock to form a new byte to output.
Incomming data (or stored in memory)
Universe 1 first byte of data (a0 a1 a2 a3 a4 a5 a6 a7)
Universe 2 first byte of data (b0 b1 b2 b3 b4 b5 b6 b7)
Universe 3 first byte of data (c0 c1 c2 c3 c4 c5 c6 c7)
Universe 4 first byte of data (d0 d1 d2 d3 d4 d5 d6 d7)
Required format to output to shift reqister.
(a0 b0 c0 d0 0 0 0 0)
(a0 b0 c0 d0 1 1 1 1)
(a1 b1 c1 d1 0 0 0 0)
(a1 b1 c1 d1 1 1 1 1)
through to
(a7 b7 c7 d7 0 0 0 0)
(a7 b7 c7 d7 1 1 1 1)
Sort of easy to do with loops, but python doesn't seem to be as easy to use with bits as it is with bytes.
In general not world changing - but some nice steps forward.
The single biggest break through in the last week, was when I realised that Python 2.7.x and 3.x are totaly different! They may as well be DMX and Renard in the way that they do some stuff, mostly the stuff that I was trying to do.
On a side note: It looks like the model A is soon to be available in the model B format and $10 cheaper. Cool as we don't need the extra usb, one will do for a wifi dongle to make it wireless and if its wireless why do we need an ethernet port. $10 will buy most of the bits for the bit for this project so far.
Barnabybear wrote:
3 Wire Pixels 3001 (The ones I have).
Easy – you set the transmission speed 100KHz to 2MHz.
Then a ‘0’ is a 0 and a ‘1’ is a 1.
SPI running at 16 MHz / 1 (data bit) / 32 (strings) = 500MHz
So you could clock 32 strings of 3001’s at 500KHz (or 160 strings @ 100KHz).
How are you handling the bit encoding for the 3001? And the packet protocol seems a bit more complicated than the other pixels, eg: interleaving of different packet types, packet lengths which are not multiples of 8 bits, bit packing on non-8-bit boundaries within the packet, etc.
Zeph wrote:How are you handling the bit encoding for the 3001? And the packet protocol seems a bit mevedore complicated than the other pixels, eg: interleaving of different packet types, packet lengths which are not multiples of 8 bits, bit packing on non-8-bit boundaries within the packet, etc.
Hi Zeph, good point but it shouldnt be a problem.
The SPI can do writes of various lenghts not just 8 bits (I know 32 has been used) but I dont need to mess with that, at the moment (4 bit writes could be usefull). For the main part of this text, each SPI write to the shift register is 8 bits (1 byte).
Because of the shift register (which has 8 outputs) every 8 bits of data recieved becomes 1 bit of data for each of 8 outputs (each pixel string). That removes the 8 bit packet limitation. (A nice video about shift registers here if anyone hasent used them before).
Nothing is for free - for this to work.
I have to write to 8 strings all the time even if only one string is being used (see note 1).
I have to write to the shift register at 8 times the speed that I would write to a single string (see note 2).
So, off hand, the first section of data required by the 3001s is 15 '1's then 4 'data' - making a 19 bit write to a single string.
To do that the PI would write to the shift register:
The byte x\ff 15 times then the byte x\data 4 times to give a 19 bit write to each of 8 strings.
Hope that explains the plan.
On the down side:
To run a single 3001 pixel, I will need to write about 60 bytes consecutively via the SPI to the shift register without the processor deciding that there is something more important to do or it will mess up the timing.
This then becomes 60 bytes x the number of pixels, again without the processor deciding that there is something more important to do.
But hey - we'll sort that one later.
Note 1: If I dont need 8 strings then a 4 bit write from the SPI would be cool. Than means I only need to write at 4 X the normal string speed.
Note 2: Speed is the limiting factor with this whole project. The PI's SPI will run at 250MHz and the 74HC595 shift register will run at 100MHz but his is ideal world. DIY if we can get 16MHz we can do cool stuff.
Phil
Still following with interest.
Hadn't come across CISECO before, they've got some interesting products.
While I was searching I also came across this company who are also in your neck of the woods
http://www.pridopia.co.uk/ixx-rspi.html
They have some very interesting I2C & SPI RPI boards, some still in development!
Mike

