Re: Any way to control LED strip

231 views
Skip to first unread message

Ytai Ben-Tsvi

unread,
May 15, 2013, 12:07:03 AM5/15/13
to ioio-...@googlegroups.com
Your reasoning seems OK, albeit wasteful (you're transmitting 20 bits for every bit). Also, your packets end up being more than the current maximum of 64 for SPI, but this is easy to change.
Why are you saying this approach won't work?

The way I would probably implement something like this (with custom firmware) is to use and output compare modules and change its pulse width on every cycle from within its interrupt context.


On Tue, May 14, 2013 at 7:53 PM, Kisurb Choe <kis...@gmail.com> wrote:

Hello, I recently bought this LED module to work with my IOIO OTG board.
http://www.aliexpress.com/store/product/DC12V-input-WS2811-pixel-node-100pcs-a-string-injection-molding-type/701799_722405450.html

According to this datasheet, each LED is controlled by WS 2911 which uses 400 Khz Pulse Width Modulation (PWM) signal to controll it.   So one cycle is 2.5 micro second.  0 high is 0.5 microsecond, 0 low is 2 micro second, 1 high is 1.2 microsecond, and 1 low is 1.3 microsecond One  thing about the chip is it does not have an internal clock (whatever that means?)

The max rate of SPI signal of IOIO OTG is 8Mhz, which gives 125 nano second per SPI bit. So this 8Mhz SPI signal,
1111 0000 0000 0000 0000 should give rise to 0 in 400 Khz PWM, (four 1s X 125 ns = 0.5 microsecond HIGH)
1111 1111 1100 0000 0000 should give rise to 1 in 400 Khz PWM, (ten 1s X 125 ns = around 1.2 microsecond HIGH)
 total 2.5 byte of SPI signal should give rise to one PWM (20 bits X 125 ns=2.5 us)
so if I were to control an LED strip with 60 RGB lights controlled by 24 bit PWM chips, I can control this setup by sending 2.5 byte X 24 X 60 SPI bits at 8MHz.
Turns out this reasoning is too simple, and there is a complicated solution for fixing the issue at other platform like this:
 http://bleaklow.com/2012/12/02/driving_the_ws2811_at_800khz_with_a_16mhz_avr.html

My question now is... Do you know any code, or a way to allow IOIO board to drive WS 2911 LED strip..

--
You received this message because you are subscribed to the Google Groups "ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ioio-users+...@googlegroups.com.
To post to this group, send email to ioio-...@googlegroups.com.
Visit this group at http://groups.google.com/group/ioio-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Kiran Chinnam

unread,
May 16, 2013, 6:15:52 PM5/16/13
to ioio-...@googlegroups.com
Hi Kisurb,
     I have this LED strip too. I used to have IOIOv1 board and I managed to drive this strip with ytai's Holiday IOIO app from google play:https://play.google.com/store/apps/details?id=ioio.examples.holiday&hl=en
Not sure if the app is compatible with IOIO OTG because of pin changes. However, Ytai put up some source code on github which may be of use to you for driving this LED Strip:https://github.com/ytai/ioio/blob/master/software/applications/HolidayIOIO/src/ioio/examples/holiday/HolidayIOIOActivity.java

If this works for you please reply saying so. It will be useful for others.

Kisurb Choe

unread,
May 16, 2013, 6:42:18 PM5/16/13
to ioio-...@googlegroups.com
Do you have precisely the same LED strip? Because I think the Holiday IOIO is for driving LED strip with four wires (+, ground, DATA, and Clock). The LED strip I have has only three (+, ground, DATA) without the clock line.

2013년 5월 16일 목요일 오후 6시 15분 52초 UTC-4, Kiran Chinnam 님의 말:

Kisurb Choe

unread,
May 21, 2013, 8:57:36 AM5/21/13
to ioio-...@googlegroups.com
To write this 2.5 byte X 24 X 60 SPI bits , I was going to use the following code.

byte[] request1 = new byte[] {127,64,-113,124,-128}; // {11111111, 11000000, 00001111, 11111100, 00000000} which is basically 2 PWM HIGH signals
byte[] request2 = new byte[] {112,-128,-113,-128,-128};//{11110000, 00000000, 00001111, 00000000, 00000000} which is  2 PWM HIGH signals
            try {
             
            for (int i=0;i<15;i++){ // Turn two LED lights on . 1LED Light=controlled by 15 bit of PWM signal
                spi_.writeRead(0, request1, request1.length,
                        request1.length, null, 0);
            }    
            for (int i=0;i<15*15;i++){ // Turn turn 30 LED lights off
                spi_.writeRead(0, request2, request2.length,
                        request2.length, null, 0);
            } }

But because of 0.5 ms of latency between each write, I cannot do this, right? Even ioio.openbatch() will not help I guess..

2013년 5월 16일 목요일 오후 6시 42분 18초 UTC-4, Kisurb Choe 님의 말:

Ytai Ben-Tsvi

unread,
May 22, 2013, 2:00:07 AM5/22/13
to ioio-...@googlegroups.com
You have a total of 270 bytes if I'm not mistaken. Split them into 5 SPI transactions (max is 64B). Use writeReadAsync() inside a batch and it might work.


--

Kisurb Choe

unread,
May 22, 2013, 11:55:39 PM5/22/13
to ioio-...@googlegroups.com
Hi Kiran, may I know how you powered your LED strip? I tried to power this strip with a 12V 6A laptop charger but it turns on for 0.3 second and it goes off.

2013년 5월 16일 목요일 오후 6시 15분 52초 UTC-4, Kiran Chinnam 님의 말:
Hi Kisurb,

Kisurb Choe

unread,
May 23, 2013, 12:56:13 AM5/23/13
to ioio-...@googlegroups.com
Ytai, thank you again for your help. 
Would you say there is no limit of # of bytes that can be grouped inside the batch function? (Like even up to 1000 bytes?)
Thank you.

2013년 5월 22일 수요일 오전 2시 0분 7초 UTC-4, Ytai 님의 말:

Ytai Ben-Tsvi

unread,
May 23, 2013, 1:20:45 AM5/23/13
to ioio-...@googlegroups.com

There's a buffer that eventually gets flushed when it overfills. I can't remember its size off the top of my head, but whatever it may be you could increase it if you want. IIRC, it's in IOIOProtocol.java.

Kiran Chinnam

unread,
May 24, 2013, 11:43:05 AM5/24/13
to ioio-...@googlegroups.com
This said, I'm not sure if we have the same LED strip, but mine does use the WS2811 driver. I'm powering it from the IOIO's 5V rail, But just to be on the safe side, I'd use an external 5v regulator, if you're using v1 board due to the 1.5 A limit. OTG board should be OK.

Kisurb Choe

unread,
Jun 1, 2013, 9:20:43 AM6/1/13
to ioio-...@googlegroups.com
Thank you Kiran. If you could, can you please post your code driving the WS2811 based led strip from Aliexpress?
It will be a great help. I am making this LED device for kids in a refuge camp.
Thanks.

2013년 5월 24일 금요일 오전 11시 43분 5초 UTC-4, Kiran Chinnam 님의 말:

Kiran Chinnam

unread,
Jun 3, 2013, 12:34:53 PM6/3/13
to ioio-...@googlegroups.com
I haven't written any code. I'm still learning java. I just used the  HolidayIOIO app written by Ytai. I posted a link to his source code on github earlier on in this thread. My v1 board broke, so I got an OTG board, but haven't tried the LED Strip with the OTG yet. Not sure  if it would still work. 

Kiran Chinnam

unread,
Jun 3, 2013, 12:35:56 PM6/3/13
to ioio-...@googlegroups.com
 got my LED Chain from proto-pic (SparkFun Distributor for UK)

Luis Fraguada

unread,
Oct 21, 2013, 5:39:21 PM10/21/13
to ioio-...@googlegroups.com
Hello Kisurb,
Did you ever get your strip working with IOIO?  I have been successful with LPD8806 based strips, but not the WS201* ones.  Picking up now after a few months of not playing with it...seeing if I can figure out a proper packet timing, but no luck yet.

Luis

Kisurb Choe

unread,
Oct 21, 2013, 6:15:36 PM10/21/13
to ioio-...@googlegroups.com
No I did not. I gave up on using the ws2811 based strip, and bought ws2801 based strip. IOIO OTG worked much better with ws2801 based strip because it has clock node.

So I recently made my project to completion and posted this to hack-a-day.com: http://hackaday.com/2013/10/08/led-guided-piano-instruction/
This is the instruction manual for making the device. http://trinkc.blogspot.com/2013/10/how-to-make-led-guided-piano-teaching.html

Sorry I could not be of help.

K

2013년 10월 21일 월요일 오후 5시 39분 21초 UTC-4, Luis Fraguada 님의 말:

Kiran Chinnam

unread,
Oct 6, 2014, 6:00:36 PM10/6/14
to ioio-...@googlegroups.com
I know this thread is old, but to anyone else who is interested, it turns out I actually had WS2801. WS2811 does NOT use SPI. It uses a single data line with a proprietary protocol. They are practically what adafruit calls neopixel. It basically uses a pulse of x micro seconds to represent logic low and pulse of y microseconds to represent logic HIGH. I've not tried on IOIO. It is easy to get working on chipKit and arduino, so it should be too hard. (Mostly bit-banging)

Kiran Chinnam

unread,
Oct 6, 2014, 6:02:04 PM10/6/14
to ioio-...@googlegroups.com
datasheet for similar product using same protocol can be found here: http://www.adafruit.com/datasheets/WS2812B.pdf

Ytai Ben-Tsvi

unread,
Oct 7, 2014, 12:39:11 AM10/7/14
to ioio-...@googlegroups.com
It is possible that the WS281x waveforms can be generated using SPI. I would try running at 5.33MHz sending a 0b11000000 = 0xC0 byte for a "0" bit and a 0b11110000 = 0xF0 byte for a "1" bit. Not very efficient, but may not matter. In either case, adding support for this protocol in firmware using either bit-banging or the SPI peripheral is probably not too hard.

--
You received this message because you are subscribed to the Google Groups "ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ioio-users+...@googlegroups.com.
To post to this group, send email to ioio-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages