Animating 3600 neopixels with RPi is slow

I have SPI RGB led strip with three wires connection:
– TX1818 driver (manufacturer says “it’s compatible with TM1812, UCS1903, SM16703, WS2811–2815”)
– 12V, 9.3 W/m, 5060, 60/metre
– 3600 pixels, 60 lines, each 1 metre long with 60 pixels
– each 4 lines connected to power supply, 20 line per power supplier
– each line in section connected to power supply in parallel
– all lines have common ground and connected with common data cable
– length of data cable is about 2 metres between controller and matrix

Data cable and common ground connected to RPi 4b (21 GPIO). RPi has Raspberry Pi OS on the board, any software is up to date.

Connection schema
enter image description here

The problem:
show() method takes like more than 0.2s to execute (using adafruit-circuitpython-neopixel & rpi_ws281x python libraries, calling after matrix values are updated)

import numpy as np
from PIL import Image, ImageSequence
import time
import board
import neopixel

PIN = board.D21
NUM_PIXELS = 3600
MATRIX_SIZE = 60
ORDER = neopixel.RGB

pixels = neopixel.NeoPixel(
    PIN, NUM_PIXELS, auto_write=False, pixel_order=ORDER
)

# USING rpi_ws281x
# from rpi_ws281x import *
# LED_FREQ_HZ    = 800000
# LED_DMA        = 10
# LED_BRIGHTNESS = 100
# LED_INVERT     = False
# LED_CHANNEL    = 0
# LED_STRIP      = ws.WS2811_STRIP_GRB
# pixels = Adafruit_NeoPixel(NUM_PIXELS, PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL, LED_STRIP)
# pixels.begin()


def readImage(path = ‘./some.gif’):    
    return np.array([np.array(frame.copy().convert('RGB').getdata(),dtype=np.uint8).reshape(frame.size[0] * frame.size[1],3) for frame in ImageSequence.Iterator(Image.open(path))])
image = readImage()

def printFrame(pixels, frame):
    for rowIdx in range(NUM_PIXELS):
        pixels[rowIdx] = frame[rowIdx]

def animate(pixels, frames):
    for frame in frames:
        start = time.time()
        printFrame(pixels, frame)
        pixels.show()
        print(time.time() - start) # 0.3+ for adafruit-circuitpython-neopixel
                                   # 0.2+ for rpi_ws281x
        time.sleep(1/60)

while True:
    animate(pixels, image)

I also have Arduino Mega Rev3, but it’s not enough memory for 3600 pixel . I assume that frame rate will be also slow because of bandwidth of SPI channel.
I thought about splitting matrix by three sections 60x20 (1200 pixels), each connected to separate SPI GPIO but couldn’t find libraries that can handle multiple channels as one.
May be there is something I’m missing? Some hidden settings? Or for RPi some extension should be used for this case, like hat?

Do you have a datasheet of the TX1818?

The frame rate is more that likely low because updating a pixel takes time. For a WS2812B (one that I'm familiar with) it takes 1.25 microseconds per bit and a pixel is 24 bits so the full strip will be updated in roughly 100 milliseconds.

Why did you post a question about the Raspberry Pi on the Arduino forum? Just curious.

Are you familiar with the interface of this type of smart LEDs? From the WS2815 data sheet
'When the refresh rate is 30fps, cascade numbers is at least 1024 pixels.
Data transmitting at speeds of up to 800Kbps.'

i.e. for 3600 LEDs you will need about 0.106 seconds just to send the data to all the LEDs like @sterretje says. Even if you split them into separate groups, you won't get a higher speed. Maybe if you make your own library that works with multiple groups and passes the data SIMULTANEOUSLY. I can't think of any other option.

https://www.pjrc.com/teensy/td_libs_OctoWS2811.html

It's an Arduino library, might be quite difficult to adapt to Pi, I don't know.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.