1
\$\begingroup\$

I'm trying to make a persistence of vision display (Example: https://www.youtube.com/watch?v=QAGnpKz7zvY) that will display images and videos. I have purchased an LED strip that has 72 LEDs that communicate over I2C. The goal is to implement a polar coordinate grid and light the LEDs up to the appropriate colors as it passes over the image. Upon my research for the project I've seen others saying I2C is a slow protocol. My question is I2C appropriate for this application of high frequency color changes to 72 LEDs?

\$\endgroup\$
8
  • 1
    \$\begingroup\$ Depending on the devices, you can communicate over I2C at up to 3.4Mbit/sec. \$\endgroup\$
    – Ron Beyer
    Mar 2 '21 at 4:54
  • 1
    \$\begingroup\$ @RonBeyer That seems like quite a bit for just LEDs color and brightness. Unfortunately I'm not that knowledgeable in this area though. This is the strip rb.gy/1yanep I plan to use half of it for my project. Do you think it would work and provide a high enough refresh rate? \$\endgroup\$ Mar 2 '21 at 5:06
  • 1
    \$\begingroup\$ @tlfong01 Thank you for the reference. I think I will shorten my wire run as much as possible for the build. If I can get anywhere near 800kHz then that should be more than enough for controlling the LEDs in "flight"...I think \$\endgroup\$ Mar 2 '21 at 5:13
  • 3
    \$\begingroup\$ Which LED strip? If we don't have the LED strip data, we can't answer how fast it can be updated. It is possible the strip only goes up to 100 kHz. \$\endgroup\$
    – Justme
    Mar 2 '21 at 5:35
  • 2
    \$\begingroup\$ That doesn't seem to have anything to do with I2C?! Ws2812 uses the infamous "neopixel" pwm protocol. \$\endgroup\$
    – mmmm
    Mar 2 '21 at 7:49
6
\$\begingroup\$

It seems that you have got a useful answer, but to the wrong question.

This isn't really an answer to what you should have asked, but it's too long for a comment and it does help you (and future readers) by explaining what you should be researching.

You asked about the I2C interface:

is I2C appropriate for this application of high frequency color changes to 72 LEDs?

However the Amazon product page for your LED strip, which you later mentioned in a comment, shows that this LED strip is a very common type which does not use I2C!

As kindly pointed out by "mmmm" in their comment, this is a WS2812B-based LED strip (see below image from that Amazon page, where I have highlighted the relevant text):

Image from Amazon page, with mention of WS2812B highlighted

These (and similar addressable LEDs) use the "NeoPixel" protocol, which is different to I2C and has different timing requirements.

This is an example of an XY-problem. You asked about what you thought was the problem (I2C bus speed) but didn't reveal enough information, until later on, about the real device. Then we saw that I2C wasn't involved at all :-(

You can research terms like WS2812 protocol, or NeoPixel protocol, or WS2812 library (to see examples of other people's code). (Note that the WS2812B datasheet shows slightly timing to the WS2812 timing.)

\$\endgroup\$
3
  • 2
    \$\begingroup\$ Yes. WS2812 LEDs are really cool, I use them a lot, but they are no where near fast enough for Persistence Of Vision. electronics.stackexchange.com/questions/479803/… \$\endgroup\$
    – Mattman944
    Mar 2 '21 at 11:14
  • 2
    \$\begingroup\$ LOL at least I wrote an informing answer about I2C bandwidth :D \$\endgroup\$ Mar 2 '21 at 12:55
  • 1
    \$\begingroup\$ Thanks you so much SamGibson and @LorenzoMarcantonio. I have since ordered a Sk9822 based strip. I was hoping to get what is apparently is the holy grail for this application an "high resolution" APA102c strip but I couldn't find one. Thank you for the help everyone! Sorry about the confusion. \$\endgroup\$ Mar 4 '21 at 18:36
1
\$\begingroup\$

OK, first of all there are at least three standard I2C speeds:

  • Classic 100kHz (10µs bit time)
  • Fast 400kHz (2.5µs bit time)
  • High speed 3.4MHz (only the data phase is high speed, for simplicity 300ns bit time)

these works as normal bidirectional I2C buses (the high speed has a negotiation trick for compatibility and the transceiver is different but the capabilities are more or less the same)

There is altro another kind of I2C called Ultra Fast Mode which is I2C only in name since it's simplex (it can only send master to slave, there's not even an acknowledge slot). Ultra fast mode is actually designed for LED control and is pumped at 5 MHz (200ns bit time).

High speed and ultra fast mode are really niche protocols, there's only an handful of ICs supporting them. The bulk of I2C peripheral these days is fast mode.

Now, regardless on the protocol used (which is relevant for cabling, as commented), you can estimate your refresh rate. Of course it depends on the kind of protocol used, so the part number will be useful*!

Let's assume the absolutely best case, when the strip only requires one address bit and one byte for each LED (technically the extreme case would be one bit for led, but do not oversimplify).

Each byte on I2C takes 9 bit times: 8 data and one acknowledge slot. There's also a one-and-half-bit overhead for the start-stop-restart condition but let's ignore these.

So, one address plus 72 data bits would be 657 bit times, assuming you can pump the I2C controller fast enough (with DMA, for example). At fast speed (the most common these days) this would take slightly less than 16.5ms; it's hardly fast enough for a polar display; assuming a minimum of 24Hz of refresh rate (24 RPM) you would have… 2.5 polar strips for scan.

It will get better with greater bit packing and faster transmit modes, just redo the computations.

\$\endgroup\$
2
  • \$\begingroup\$ There's also Fast Mode Plus which is getting increasingly popular, the same as Fast but at 1 MHz \$\endgroup\$ Mar 2 '21 at 10:15
  • \$\begingroup\$ right, I forgot about Fm+… the evil brother of fast mode \$\endgroup\$ Mar 2 '21 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.