RGB LED Strip - 32 LED/m addressable

tinyb

Member
Hi

Just wondering if anyone has the RGB LED Strip - 32 LED/m Addressable - 1m from sparkfun? They use the WS2801 IC which can individually pulse each colour on a 256 grey scale curve. This means that you need to pass 24 bytes of information for each RGB LED (8 bytes for the red led, 8 for the green and 8 for the blue led)

data sheet for the rgb strip here
data sheet for the WS2891 IC here

Been playing around with it tonight. have had the picaxe successfully send data to the first led with a modified shift register code - started to look at the spi style code but getting too late - tomorrow night.

My trouble is I think that the picaxe can't send the information down the line quick enough to update the registers on the first ic, i get some interesting clolour effects. will post some videos tomorrow night.

if anyone has seen or used this, or sent 24 bytes of data serially using 2 pins help would be greatful - i don't want to have to teach the students the coding for the other controller that there is sample code for.

thanks
richard
 
Last edited:

westaust55

Moderator
Did not locate any other posts covering the WS2891 IC.

Might be worthwhile your indicating:
1. Which PICAXE chip you are using
2. Posting your code if you seek help - Are you using bit bashed SPI, the inbuilt SHIFTOUT command with an X1 and X2 part, or other methods.

If you have an X1 or X2 part the inbuilt SHIFTOUT command is much faster than bit-bashed code and can send multiple bytes in one command (also whole or part bytes)

EDIT: that should be WS2801 not WS2891
 
Last edited:

geoff07

Senior Member
In case of interest, IKEA do a product ('DIODER') with 4 multicolour led strips (9 leds on each) that together are about 10 in long, and are controlled by a PIC and three mosfets. The program allows for gradual fade one colour to the next, and other patterns. Obviously nothing as complex as the WS2891, but perhaps a useful basis for a Picaxe project.
 

tinyb

Member
sorry about the jumble last night - westaus - i should know better

First some background:
I have a group of students proto typing retro fitting emergancy lights that could be used in houses, schools officers etc. They would like to use colour and movement as the indicator for the project. The person taking the electrical engineers post started by building and programing a SEB with the classic traffic lights program, from there she investigated a number of options - 1) have a whole series of single colour LEDs and using multiple picaxes, program in a chase fashion similar to the chase clock produced a number of years ago (my students are still mesmerised by it today) then expand to using shift registers etc to get a whole lot working. 2) investigate using various colours to aid a persons exit from the room - RGB LEDs, we have some RGB LEDs in the lab and a copy of the very simple PWM example given in a silicon chip circuit notebook september 05, this is then interfaced with the RGB LED Strip from spark fun. this is nice but all 30 rgb leds are the sam colour. The student enjoyed the processes learning how and playing around with the PWM and then the tranistor circuit to control the 12V RGB LED Strip but while looking for the RG LED Strip they came accroos the 10312-00_i_ma.jpgRGB LED Strip - 32 LED/m Addressable - 1m. A youtube clip of the strip using the sorce code from the sparkfun website in an adrunio is here.

The main problem:

the addressable RGB LED strip uses the WS2801 IC as the controller for each RGB LED. This IC requires 24 bits of data - 8 bits for each colour giving a grey scale number from 0 to 255 - not on to full on - it then uses PWM to pulse the corresponding colour to get the oppropriate brightness - this is the same process the students were doing with the individual RGB LED and the 08m.

it uses a 2 wire system similar to the others but not the same. you set the clock high - send in a bit - set the clock low and repeat. The second file below is the timing required it is from page 12 of the dtat sheet. from the data sheet it says: " To control the strip, you clock in data continually. Each IC automatically passes the data onto the next IC. Once you pause for more than 500us, each IC 'posts' or begins to output the color data you just clocked in. So, clock in (24bits * 32LEDs = ) 768 bits, then pause for 500us. Then repeat if you wish to display something new."

My problem is - i haven't had any experience with shift register type devices (use i2c regularly and spi once). below is the code i tried last night, knowing that it wasn't completely correct. i was able to talk to the first IC and it moved the data through the 24 bits to give an interesting display. I am currently using a 18m2 but have access to 28x1 and I think an x2? The main problem i see is that the commands are not going fast enough and the IC is premitully posting to the LEDs, give nice effects but not doing what I want it to do.

Code:
'Display various brightnesses of red on the RGB Strip
#picaxe 18m2

let dirsB = 255 ; set all portB pins as output

symbol dataout = b.4		'Define port for data stream
symbol clk = b.3			'Define port for clock


symbol bitcounter = b1		'Define variable names
symbol outbit = b2
symbol outbyte = b3
symbol red = b4

red = 0

Main:
	
	    gosub shift595		'
		red = red + 1
	    pause 500
	 
	 goto main



'Subroutine to convert a digit to segment codes and shift them into a 74xx595, 
' the digit to be sent is in 'counter'

shift595:
	outbyte = red
	
	for bitcounter = 0 to 7		'Count to 8
	  outbit = outbyte & 1		'Isolate the bit to be sent
	  low clk
	  if outbit = 1 then		'Test the bit, if it's a 1 then
	    high dataout			'set the data out port high
	    else				'otherwise
	    low dataout			'set the data out port low.
	  endif 
	 high clk
 	  outbyte = outbyte / 2		'Shift right to position the next bit for output
	next bitcounter	
	return
I ubderstand the that code above is only sending 8bits of data and not the required 24bits.

Been reading the manuals, looking at the spiout (shift out) commands and the bit bang version for other parts, still getting my head around these.

Now for my questions:
1) i can access the first 32 bits with the bitxx command, without doing 24 if statements in a row with the clocking wrap around them, can you increment them for a loop function? (every thing is doing it in bytes)
2) what is the time lage of the above, next week when school is back i will get out the cro and look at the traces - 500us is not much time.
3) do i give up and go with the working and ge the kids to scroll through the C++ confusion (for entry level students) that is ardunio?

could use the shift brite that I have - they use good old i2c.

Will continue to post more info as i get it, it is getting late again and I need my sleep - big wiggles concert tomorrow - the young one is excited

thanks
tiny
 

Attachments

Last edited:

hippy

Technical Support
Staff member
The second file below is the timing required it is from page 12 of the dtat sheet. from the data sheet it says: " To control the strip, you clock in data continually. Each IC automatically passes the data onto the next IC. Once you pause for more than 500us, each IC 'posts' or begins to output the color data you just clocked in. So, clock in (24bits * 32LEDs = ) 768 bits, then pause for 500us. Then repeat if you wish to display something new."
Thanks for that which I didn't see in the manual on a quick read and wondered how it worked.

So basically you need to throw all 768 bits at the strip without there ever being a 500us or greater gap, otherwise each LED thinks it has its latest data and puts up whatever that was prematurely.

The key then is fastest operation, running at 32 or 64MHz, 'optimised for speed' bit-banging or SHIFTOUT and HSPIOUT probably being even better candidates. Actually sending the data isn't likely going to be a problem but the speed of getting the next byte to send probably will be. Something like the following would likely be best -

ptr = 0
HSpiOut ( @ptrInc, @ptrInc ... @ptrInc, @ptrInc )

Unfortunately neither SHIFTOUT nor HSPIOUT is available for the 18M2 so bit-banging is the only option.

Do you have a scope or logic analyser to look at the speed of data being transferred to the LED strip ?
 

westaust55

Moderator
2) investigate using various colours to aid a persons exit from the room - RGB LEDs, we have some RGB LEDs in the lab and a copy of the very simple PWM example given in a silicon chip circuit notebook September 05, this is then interfaced with the RGB LED Strip from spark fun. this is nice but all 30 RGB leds are the same colour.
Some information:
Most emergency exist signs are green and white in colour. (In Australia to AS 2293 "Emergency Lighting" and likely similar standards for other regions)

A primary reason for this is that if a persons eyesight is impaired by for example chemicals (eg caustic solution) then green is the last colour you can still see and the first to be seen when the vision returns.
Not a good idea to verify this fact.
 
Last edited:

hippy

Technical Support
Staff member
Just re-read post 4 and see tinyb has a scope so this will no doubt be interesting. Not tested on real hardware but it should do the job required. At 32 MHz each byte is output in about 1ms, roughly 122us between bits, but - most importantly - just 330us or so between bytes, below the 500us magic value.

The LED data is stored as 32 sets of three byte data, stored in RAM at locations 160 to 255 and accessed via 'bPtr'. That means that an @bPtrInc takes btr to zero after the last LED which makes for faster testing that all data has been sent.
 

Attachments

tinyb

Member
hippy - thanks for the code. I only had time to try it tonight, the green and the blue work on led 15 and 31 respectively but not red on led 0. i will sit down in a few days on problem solve. Thanks for the code - you really are a champion. I am starting to understand the bit bang thing.

Some information:
Most emergency exist signs are green and white in colour.

A primary reason for this is that if a persons eyesight is impaired by for example chemicals (eg caustic solution) then green is the last colour you can still see and the first to be seen when the vision returns.
Not a good idea to verify this fact.
good point - i will pass it onto the students to investigate as part of their project but i don't want it to stop me (and the students) havng excuses to buy cool electronic gadgets like this light strip. I have students building rc lawn mowers, rc line markers, picaxe controlled ipod night light / night stand for students, bluetooth enabled bike helmets, phone finders - like the old whistle key ones, and interesting flavours of ice cream. many of these have been done or may not fit into regulations but fun to do. If anyone in SA wants to see these and more - the C2C expo is on Wednesday 9th November Golden Grove rec centre from 11 am to 1pm and RDHS Showcase - Thursday 17th November @ riverton community gym from 1.30 pm to 2.30pm and evening where we have a bbq of our 1st prize winning led steer from the royal adelaide show and release of our new wine as well as the UAV team - 4th in Australia.

sorry stop the ad now

thanks
tiny
 

tinyb

Member
hippy - wife is still on the phone so could fiddle with the code - changed the red led from led 0 to led 1 and the red is now working - i need to check the first led by the looks.

thenks
tiny
 

hippy

Technical Support
Staff member
You might have to check where the LED storage is placed - Is "256 minus 96" right, should it be "255 minus 96" ? It might be sending too little or, more likely, too much data. If it's not controlling the expected colour on the LEDs that would point to too much data. I must admit that I didn't check that, but did choose LED0 and LED31 to control so any mistakes should be shown up.

Added : Actually I don't think it's that. For one LED it would be locations, 253/254/255 and 253 = 256-(1x3), so for 32 LED's that's 256-(32x3).

Also, it may be worth counting the LED's just to make sure each strip does have 32 LED's !

Good news though on what it does control.
 
Last edited:

tinyb

Member
Hi finally back on this project again.
First the problems that have been identified - the first LED doesn't work due to mechanical failure - the strip is coated in a water proof sealant and this has cracked at the end where the connection wires come out, some slight pressure on the led and it works - the control ic isn't affected and passes the data on.

Second - the students did look up the issues with the colour/eye sight/etc, they did discover that green was the first colour restored and the legal colour for all emergancy exit signs but movement (of colour/objects) can also be detected (usually in a grey scale initially) and this is the effect the students were going for - as stated before this project is more about playing with toys than doing anything legal.

finally the code. we have added a simple loop that move the colours down the strip. it looks cool until the we can't suppy enough current to satisfy the current draw. Using a this breadboard adaptor from sparkfun that although the regulator can handle 1.5A there is a PTC which drops out after 250mA (get up to 700mA before issues arise) the whole strip will pull 1.8A if 32 LEDs have the colours on (spec sheet).
 

Attachments

Last edited:

boriz

Senior Member
On the sparkfun site, a comment by rmeyer says:

"Whew- I don't have the time to do it, but it seems you could mount two of these opposite each other on the shaft of a motor, then spin them to create a supersized full-color circular POV video display."

This is a similar idea to one I had a while ago. Could a dot matrix display be formed using only a spinning strip of lights?

The display perimeter would obviously be circular, and the spinner would have to be perfectly balanced, and the LEDs would have to be flashed at high current with precision timing, and the image would need to have it's pixel co-ordinates converted from rectilinear to polar. But surely it could be done?

A full low-res TV image using a strip of only (say) 32 LEDs.

Anyone care to work out the maths of how fast the processor needs to be?
 

hippy

Technical Support
Staff member
Anyone care to work out the maths of how fast the processor needs to be?
Let's say it's got to update at 50Hz ( every 20ms ) and you've got to update all spoke positions in that time so ...

20ms = 32 LED's x spokes

then ...

Time per LED = 20ms / ( spokes * 32 )

For 360 spokes ( a pixel line every degree ) that's each LED needs to be updated every 1.74us.

For 36 spokes ( every 10 degrees ) that's 17.4us

I expect the refresh rate can be slower but it's probably still a hard push. There are wheel hub lights which work this way and can show circular images and it's really only a glorified 'propeller clock' so probably worth doing a search and seeing if they offer any better figures to use.
 

topkoa

New Member
Just curious if anyone here could provide me with some more detailed information on how you got this to work with the Picaxe 18m2??

I just received mine, and I was tinkering around with submitted code I found earlier in this thread, and what I imagine was the correct wiring (there seems to be no real good information on powering/wiring these things)..

So far I have only been able to get random fast flashes of color, and only on the first 3 LED's.. Basically, I don't entirely understand how to "address" a specific LED on the strip programmatically..

Thanks..
 

tinyb

Member
if you use the code above, it was designed by hippy and modified by me to control the 32 rgb strip with the 18m2. the big problem arrises when you need to provide enough current to the strip to have all 32 LEDS on at once. I used an old computer power supply - the 5V wires (black and red - the yellow is the 12V +ve wire) that can handle upto 2 to 5 amps.

the proble you are having at the moment is what I started out with. basically you are not sending the data quick enough and so the chip is writing to the led with only parts of the data loaded. this give some interesting effects but only on the first few leds.
 

topkoa

New Member
Thank you! Its working for me now, I scavenged an old SonicWall power supply from my stash:

Output: 5V DC, 2.4A 12W

That did the trick, the one I was using I guess just didn't have the horsepower at 1.0A...

I uploaded your code and it fired to life! (Now I'm a little blinded, they are bright!)

Thanks again...
 

topkoa

New Member
Now I have it running, I am curious if you might elaborate how this code is working?

I'm a little new to the conventions to this programming language, and I think I understand it in some ways.. However, I am puzzled as to how the code works with respect to the execution sequence.

When I "simulate" the code inside the picaxe programming editor, it never seems to exit the "do" loop with the PulsOut statements in it. When I upload the program to the device it seems to cycle through the colors as if it is executing the code in the "UpdateLevels" routine..

I am trying to follow the logic, but like I said its confusing because I cannot determine the proper flow of the code...

Thanks again!
 

tinyb

Member
Now I have it running, I am curious if you might elaborate how this code is working?
That is a good question. the send levels bit i will get back to you on. i understand it but need to formulate an appropriate answer ( the teacher in me)

When I "simulate" the code inside the picaxe programming editor, it never seems to exit the "do" loop with the PulsOut statements in it. When I upload the program to the device it seems to cycle through the colors as if it is executing the code in the "UpdateLevels" routine..

I am trying to follow the logic, but like I said its confusing because I cannot determine the proper flow of the code...

Thanks again!
When simulating, remember that you have memory locations 160 to 255 that have to be writen to the strip ( on the first run only memory space 160 has a value in it of 255, the rest are blank.) by commenting out the gosub send levels, you can see the program change values in the memory locations.( I am using the decimal values here) 160 - red led 1, 161 - green led 1, 162 - blue led 1, 163 - red led 2 ......

when in simulation mode change the memory table from data to ram, scroll down to 160 anjd you should see 255, after awhile the 255 should move to 163 and 255 appear in 161 and the 255 in 163 moves to 166 and the 255 in 161 move to 164 and 255 appears in 163 ( now have a sequence of red on the 3rd led, green on the 2nd led and blue on the 1st led) all the values move up 3 spaces and more values appear between 10 and 162.

this is very poor explaination, if i have a chance i will do a screen record on post it for you.
 

topkoa

New Member
Thanks for the explanation, I'm finally getting a few moments to start tinkering with this stuff again..

On a side note, does anyone here have any idea how I might go about powering the led strip in a small portable setup? I'm having a lot of fun with this, however I would like to integrate this into something I can take with me and not have to plug it into a wall socket..

Any ideas?

Thanks again!
 

tinyb

Member
sla (sealed lead acid) batteries could put out enough grunt and be smaller enough - there are many kinds and sizes or lipos could work well. the big issue is finding a regulator that can handle the current draw. my issue when i wanted to use it in a portible situation was the reg i was using would cut out after an amp. didn't take it any further as had access ti a wall socket. you can get 6V SLA so would only need a couple of diodes to drop the voltage to just below 5V. Check the tolerences on the data sheet (i don't have it to hand at the moment.)

thanks
tiny
 

topkoa

New Member
One of my project ideas for this requires the power source to be as small and narrow as possible, I was thinking of using the following two items as a starting point... Any idea what else I would need to get this working? One of the conceptual problems I have is I am only familiar at this point with the 7805 regulator, however I think from what I read it maxes out at 1AMP.

http://www.sparkfun.com/products/551

http://www.sparkfun.com/products/335

Think you could point me in the right direction?
 

AllyCat

Senior Member
Hi,

It all rather depends on what voltage, current and (particularly) operating time your project actually requires! Does it need more than an Amp?

Those cells in that holder will give a nominal 4.8 volts, so a 7805 is not really relevant (especially as it's not a Low Drop Out type). The cells alone (without a regulator) will probably give a satisfactory voltage at (say) 2 Amps, but only for an hour at most.

Cheers, Alan.
 

2gttalon

New Member
I am glad I found this thread. I also using the 1m strip from sparkfun. I have a picaxe 08m2 and the proto board. Can anyone help with some basic strip chases on a 1m strip with picaxe 08m2 or give me a good source to understand controlling this strip better ?

Also my wires seem slighlty different. Anyone aware of color coding on this strip photo attached ?
 

Attachments

Last edited:

2gttalon

New Member

Attachments

Last edited:

ryanhl

New Member
for the ws2801 led strips i have read that ws2801 library, apart the 24 color bit , has some delays (latch time) and lower freq ...can this have some troubles using ambilight clones programs?
 

PhilDonld

New Member
For 32 LED/m addressable led strip, there are 32led/m ws2801 addressable strip,http://www.gree-leds.com/productshow.asp?ArticleID=70Y0X260SR
and 32led/m lpd8806 addressable strip.
LPD8806 are very poorly documented - adafruit managed to reverse engineer enough of how they work to make an arduino library.
WS2801 is a similar SPI device with a seperate chip. You can hook it up to a raspberry pi, a serial or parallel port on a computer, a digispark, littlewire, and arduino - pretty much anything capable of digitally writing to two wires. The WS2801 runs it's PWM off an internal clock, so you can set it and forget it - they'll hold their colour without needing your program to be interrupted thousands of times every second.
The WS2811 is a chip, like the ws2801, but instead of SPI it uses a purely timing-based serial protocol. They can be driven by an arduino or digispark running at 8 or 16 megahertz, they hold their colour (set and forget) just like the ws2801, and are basically the same, but you only need a single data wire instead of two, making them very appealing for use with digispark.
In a lot of cases, WS2811 will refresh a bit slower than LPD8806 strips.
The former use an 800 KHz datastream, the latter (if using hardware SPI) might be running at 400KHz
(it varies -- have to look at the code, see what it's doing).
So advice the http://www.gree-leds.com/productshow.asp?ArticleID=TS7X2X7VTP mostly.
 
Last edited by a moderator:

hippy

Technical Support
Staff member
The above post #26 seems to be product placement resurrecting an old thread, almost verbatim of posts to other forums, but as it is perhaps also potentially useful I have simply changed the embedded links to text URL's.
 
Top