Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This information is now maintained here: https://github.com/open-ephys/rhythm/blob/master/README.md

The LED controller is implemented in LED_controller.v

The WS2812 LEDs are driven by a single data line using a timing code: WS2812.pdf
The code consists of different patterns for 1s and 0s. After 24bit (8*3 brightness levels) are received  by an LED, it passes on all subsequent codes to the next LED in the chain. Once a reset code (gap of >50us) is sent, the first LED will receive data again, repeating the cycle.
We therefore want to send 24*8 codes, then wait a bit, and repeat that.

Here's a quick description of the state machine used to generate the data driving the 8 LEDs:

We're gonna be running this of a nested loop off the 100MHz master clock
An inner loop bit_state checks the led_bit reg. and goes through 125 states, each clk cycle lasting 0.01us, it sets the out either to the 1 pattern, 0 pattern ,or all zeros for reset
The GRB_state (there are green-red-blue) state loops every time the bit_state is 0 and itself loops 24 times.
It sets led_bit to a value from GRB_reg.
A third loop increases LED_state every time GRB_state is 0, and loops 8+2 times for 8 leds and 2 led cycles of 30us each to get the required >50us of zeros for the reset. It sets LED_reg to a 24 bit color from sone source value, or 0 for reset in the last 2 states.