SPI protocol to light all the LEDs

We started looking into how to implement the SPI communication between the main board and the processor PCBs with Sibille, Xavier and me.

Et each turn of the motor, we need to light up all the 78 RGB LEDs during around 100us at the same time. The motor can spin from 11 RPS to 30 RPS. We have 3 SPI buses leaving the main board, and each SPI bus gets split into at most 5 processor PCB (the top PCB can be counted as processor PCB), and each processor PCB has at most 24 colored LEDs.

SPI frame

Every SPI frame has 16 bits, and we decided to use the first 3 bits as PCB processor addresses, the following 5 bits as colored LED addresses, and the last 8 bits to encode a color. Since a SPI bus has at most 5 processor PCB, we have 3 remaining addresses and we will use them as broadcast commands.

The LED colors will be configured before they get turned on at each turn.

Broadcast commands

There are two different options for the broadcast commands:

  • We have an “ON” command, which tells the processor PCBs to turn on all the LEDs as soon as it receives the command, and the same for the “OFF” command.
  • We have a “ON at time x during duration y” command, and a common time reference between the processor PCB and the main board

We will try the first option first, and if the latency between the lighting of the first LED and the last LED is too long we will try the second option.

Coding a SPI slave

Unfortunately, there is no SPI slave API on ChibiOS, so we’re not sure yet how will we code it. We have read on the ChibiOS forums that we might be able to use the SPI master API to act as a SPI slave (since the difference between a SPI slave and a SPI master is not so big), but if that doesn’t work out we will code it from scratch.

We hope to receive the processor and petal PCBs soon, in order to quickly test the lighting of the LEDs, but meanwhile we will start coding and testing as much as we can, and will keep you updated.

Leave a Reply
