OLA SPI – APA102

some time ago i contributed support for APA102 LEDs to OLA.
i based most of the things on the wounder full reverse engineering of Tim’s Blog.
while writing the code i made some tests that i documented in the Pull-Request on Github.

Now my PR is merged and i want to make some additional test about timing and so on:

I followed the Tutorial ‘OLA on Raspberry Pi’ with the ‘GIT Repo Image’ option and compiled ola with this config

[shell light=”true”]./configure –enable-python-libs –enable-rdm-tests[/shell]

.
this takes some hours – to speed up you can use

[shell light=”true”]./configure –disable-all-plugins –enable-python-libs –enable-dummy –enable-spi[/shell]

so only python dummy and spi is enabled.

My Test-Setup:

APA102 Test Aufbau

i have 25 physical Pixels connected. first the short 5pixel Strip and than the 20PixelStrip.

i have written a simple python scirpt to test things.
it generates a ‘strobe’ effect – on frame on on frame off.
you can find it on github in my ‘script collection’

the script allows two arguments: ‘TICK_INTERVAL’ and ‘pixel_count’.
copy the script to your home folder on rpi ( i used FireFTP – but there are other ways to do this..)

first start olad –> ‘olad -l 3’
then you can start the script with ‘python ./strobe.py 25 170’ the 25 is the Intervall and the 170 the pixels to send data for. the script connects to universe 5. (you can change it in the code if you like..)
to exit the script use Ctrl+C

in the ‘~/.ola/ola-spi.conf’ you can setup the spi-baudrate and other things.
mine looked like this:

[shell]base_uid = 7a70:00000100
device_prefix = spidev
enabled = true
spidev0.0-0-device-label = MyTest
spidev0.0-0-dmx-address = 1
spidev0.0-0-personality = 7
spidev0.0-0-pixel-count = 170
spidev0.0-backend = software
spidev0.0-ports = 1
spidev0.0-spi-ce-high = false
spidev0.0-spi-speed = 1000000
spidev0.0-sync-port = 0
spidev0.1-0-device-label = SPI Device – spidev0.1
spidev0.1-0-dmx-address = 1
spidev0.1-0-personality = 7
spidev0.1-0-pixel-count = 170
spidev0.1-backend = software
spidev0.1-ports = 1
spidev0.1-spi-ce-high = false
spidev0.1-spi-speed = 1000000
spidev0.1-sync-port = 0[/shell]

so in this example the spi-speed is set to 1000000Hz = 1000kHz = 1MHz

i made a series of tests / meassurements and changed this parameters:

  • spi-speed
  • pixel-count (changed this at both points – in the config and the script)
  • TICK_INTERVAL

i measured with my relative old HAMEG HM407 Analog/Digital Scope (40MHz 100MS/s)

conclusion:
with 1020 Pixel (6 full Universes) i am getting the error

[shell light=”true”]plugins/spi/SPIWriter.cpp:118: Failed to write all the SPI data: Message too long[/shell]

so i used a 1000Pixels as maximum.

with 7,7MHz its possible to use 1000Pixels and get an update rate of about 35Hz.

Here the full Table: 🙂

nr. parameters measurements
pixel-count spi-speed TICK_INTERVAL drop counter
Factor
write errors
Factor
clock pixel length Single packet
Length
update rate
1 10 10 kHz 10000 100 ms 10,0 Hz 0 0 7,7 kHz 4,7 ms 53 ms 100 ms 10,0 Hz
2 10 10 kHz 10000 25 ms 40,0 Hz 1 0 7,7 kHz 4,7 ms 53 ms 53 ms 19,0 Hz 19
3 10 10 kHz 10000 10 ms 100,0 Hz 4 0 7,7 kHz 4,7 ms 53 ms 53 ms 19,0 Hz
4 170 10 kHz 10000 100 ms 10,0 Hz 0,5 1 7,7 kHz 4,7 ms 830 ms 157 ms 6,4 Hz
5 170 10 kHz 10000 25 ms 40,0 Hz 0 1 7,7 kHz 4,7 ms 830 ms 157 ms 6,4 Hz
6 170 10 kHz 10000 10 ms 100,0 Hz 0 1 7,7 kHz 4,7 ms 830 ms 157 ms 6,4 Hz
7 340 10 kHz 10000 100 ms 10,0 Hz 0,5 1 7,7 kHz 4,7 ms 1650 ms 318 ms 3,1 Hz
8 340 10 kHz 10000 25 ms 40,0 Hz 4 1 7,7 kHz 4,7 ms 1650 ms 750 ms 1,3 Hz
9 340 10 kHz 10000 10 ms 100,0 Hz 8 1 7,7 kHz 4,7 ms 1650 ms erratic
10 1000 10 kHz 10000 100 ms 10,0 Hz 0,5 1 7,7 kHz 4,7 ms 4800 ms 310 ms 3,2 Hz
11 1000 10 kHz 10000 25 ms 40,0 Hz 0 1 7,7 kHz 4,7 ms 4800 ms erratic
12 1000 10 kHz 10000 10 ms 100,0 Hz 0 1 7,7 kHz 4,7 ms 4800 ms erratic
12 10 100 kHz 100000 100 ms 10,0 Hz 0 0 60 kHz 600 us 6,7 ms 100 ms 10,0 Hz
13 10 100 kHz 100000 25 ms 40,0 Hz 0 0 60 kHz 600 us 6,7 ms 25 ms 40,0 Hz
14 10 100 kHz 100000 10 ms 100,0 Hz 0 0 60 kHz 600 us 6,7 ms 10 ms 100,0 Hz
15 170 100 kHz 100000 100 ms 10,0 Hz 0,01 0 60 kHz 600 us 103 ms 103 ms 9,7 Hz
16 170 100 kHz 100000 25 ms 40,0 Hz 3 0 60 kHz 600 us 103 ms 103 ms 9,7 Hz
17 170 100 kHz 100000 10 ms 100,0 Hz 9 0 60 kHz 600 us 103 ms 103 ms 9,7 Hz
18 340 100 kHz 100000 100 ms 10,0 Hz 0,5 1 60 kHz 600 us 207 ms 306 ms 3,3 Hz erratic
19 340 100 kHz 100000 25 ms 40,0 Hz 7 1 60 kHz 600 us 207 ms 761 ms 1,3 Hz
20 340 100 kHz 100000 10 ms 100,0 Hz 9 1 60 kHz 600 us 207 ms erratic
21 1000 100 kHz 100000 100 ms 10,0 Hz 0,5 1 60 kHz 600 us 602 ms 309 ms 3,2 Hz
22 1000 100 kHz 100000 25 ms 40,0 Hz 2 1 60 kHz 600 us 602 ms erratic
23 1000 100 kHz 100000 10 ms 100,0 Hz 3 1 60 kHz 600 us 602 ms erratic
24 10 1 MHz 1000000 100 ms 10,0 Hz 0 0 0,97 MHz 38 us 0,42 ms 100 ms 10,0 Hz
25 10 1 MHz 1000000 25 ms 40,0 Hz 0 0 0,97 MHz 38 us 0,42 ms 25 ms 40,0 Hz
26 10 1 MHz 1000000 10 ms 100,0 Hz 0 0 0,97 MHz 38 us 0,42 ms 10 ms 100,0 Hz
27 170 1 MHz 1000000 100 ms 10,0 Hz 0 0 0,97 MHz 38 us 6,5 ms 100 ms 10,0 Hz
28 170 1 MHz 1000000 25 ms 40,0 Hz 0 0 0,97 MHz 38 us 6,5 ms 26 ms 38,5 Hz
29 170 1 MHz 1000000 10 ms 100,0 Hz 0 0 0,97 MHz 38 us 6,5 ms 11 ms 90,9 Hz
30 340 1 MHz 1000000 100 ms 10,0 Hz 0 0 0,97 MHz 38 us 12,8 ms 100 ms 10,0 Hz
31 340 1 MHz 1000000 25 ms 40,0 Hz 0 0 0,97 MHz 38 us 12,8 ms 25 ms 40,0 Hz
32 340 1 MHz 1000000 10 ms 100,0 Hz 0 0 0,97 MHz 38 us 12,8 ms 14 ms 71,4 Hz
33 1000 1 MHz 1000000 100 ms 10,0 Hz 0 0 0,97 MHz 38 us 37,7 ms 100 ms 10,0 Hz
34 1000 1 MHz 1000000 25 ms 40,0 Hz 0 0 0,97 MHz 38 us 37,7 ms 38 ms 26,3 Hz erratic
35 1000 1 MHz 1000000 10 ms 100,0 Hz 0 0 0,97 MHz 38 us 37,7 ms 38 ms 26,3 Hz erratic
36 10 10 MHz 10000000 100 ms 10,0 Hz 0 0 7,7 MHz 4,62 us 74 us 100 ms 10,0 Hz
37 10 10 MHz 10000000 25 ms 40,0 Hz 0 0 7,7 MHz 4,62 us 74 us 25 ms 40,0 Hz
38 10 10 MHz 10000000 10 ms 100,0 Hz 0 0 7,7 MHz 4,62 us 74 us 10 ms 100,0 Hz
39 170 10 MHz 10000000 100 ms 10,0 Hz 0 0 7,7 MHz 4,62 us 907 us 101 ms 9,9 Hz 870..973
40 170 10 MHz 10000000 25 ms 40,0 Hz 0 0 7,7 MHz 4,62 us 907 us 26 ms 38,5 Hz
41 170 10 MHz 10000000 10 ms 100,0 Hz 0 0 7,7 MHz 4,62 us 907 us 11 ms 90,9 Hz
42 340 10 MHz 10000000 100 ms 10,0 Hz 0 0 7,7 MHz 4,62 us 1,8 ms 99 ms 10,1 Hz 1,7..1,8
43 340 10 MHz 10000000 25 ms 40,0 Hz 0 0 7,7 MHz 4,62 us 1,8 ms 26 ms 38,5 Hz
44 340 10 MHz 10000000 10 ms 100,0 Hz 0 0 7,7 MHz 4,62 us 1,8 ms 14 ms 71,4 Hz 13..20
45 1000 10 MHz 10000000 100 ms 10,0 Hz 0 0 7,7 MHz 4,62 us 4,9 ms 101 ms 9,9 Hz
46 1000 10 MHz 10000000 25 ms 40,0 Hz 0 0 7,7 MHz 4,62 us 4,9 ms 28 ms 35,7 Hz 28 or 44
47 1000 10 MHz 10000000 10 ms 100,0 Hz 0 0 7,7 MHz 4,62 us 4,9 ms 28 ms 35,7 Hz 28 or 44