[WIP] Lighting Board
Hardware Github link: https://github.com/lhr-solar/Controls-LightingPCB/tree/lighting2024
Software Github link: https://github.com/lhr-solar/Controls-Lighting
Clickup link: https://app.clickup.com/t/868e8q4ev
Description
This board handles control over all external lights and takes commands from Controls LSOM. It also publishes power consumption telemetry and error messages on controls peripheral CAN.
Design Spec
Hardware
Supply power to all connected lights
Connect up to 2 lights at a time (1 addr, 1 normal or 2 normal)
Be able to support 1 addressable LED strip (3 pin conn)
Be able to support up to 2 normal lights (bps strobe and a backup for addr light)
Be able to monitor power consumption of each light
Connect to Controls peripheral CAN
INPUTS:
CAN (for receiving commands from Controls LSOM)
24V Power from Controls leader
PSOM
OUTPUTS:
CAN (for daisy chaining + sending CAN msgs)
2 GPIO for each normal light (so x2)
3 GPIO for each addr LED strip (so x1)
Location:
Board 1: will be at the front and will control 1 long addr LED strip
front headlights, front L/R turn indicator
Board 2: will be near left-middleish extreme of car and control a 4ish inch addr LED strip
L side turn indicator
Board 3: will be near right-middleish extreme of car and control a 4ish inch addr LED strip
R side turn indicator
Board 4: will be in canopy and control 1 6ish inch addr LED strip and a strobe light
brake light, BPS strobe
Board 5: will be in the rear and control 1 long addr LED strip
brake light, read L/R turn indicator
OLD:
Front headlights are always on
Connect up to 6 lights at a time
Board 1: front headlights, front turn indicators, side turn indicators
Board 2: canopy brakelight, BPS strobe
Board 3: rear turn indicator/ brakelight combo
2 GPIO connections per light (x6 lights),
Software
LSOM sends when to turn each light on/ off
Read and act on CAN MSG: lighting msg (left ind, right ind, bps strobe, brake)
Issue commands for addressable LEDs
Periodically publish power consumption of each connected light as well as to check for possible disconnections
Design Decisions
Opted for less complex boards in order to <…>
Questions to answer:
What chips will be used?
What dimensions constraints are there?
Which lights will we use?
likely these for addressable LEDs: https://www.amazon.com/BTF-LIGHTING-Flexible-Density-Chasing-Controller/dp/B0DRJZFRCV?s=hi
Software Notes
Current State (10/25/2025): Software has been written to test on the TPS test board with WS2812B lights. This software currently compiles but doesn’t work. If we don’t have LED strips, then the next step would likely be to get the SMD LEDs working on the test board. If we do have WS2814 LEDs, the recommendation might be to test using those instead.
Last test: attempted running gamer_LEDs_test.c on the TPS test board, but nothing happened. I think the timer isn’t running since I’m not seeming to see it start nor change values, but I could be very wrong.
Code attempt can be found on Embedded Sharepoint on the branch addressable_led_driver
Software for this driver entails
High-level function calls (input desired color and LEDs)
Not written
Low-level function calls (translate color to PWM values)
Not written
HAL MSP and initialization calls
Added to file but not fully tested
I’d recommend starting by reading this tutorial implementing the same thing: https://www.thevfdcollective.com/blog/stm32-and-sk6812-rgbw-led
Once adapted to use the STM32L4 and WS2814 lights, this code could be used for our board (though we’d need to support more pins). Some of the code is already pasted in Gamer_LEDs.c for reference.
Here is another good article that uses timers on the STM32: https://deepbluembedded.com/stm32-timer-interrupt-hal-example-timer-mode-lab/
This project uses the following files:
Gamer_LEDs.c
Driver
Already has STMcube functions (not sure if they are correct, though)
Still needs code to go from a color array to sending a buffer to the DMA start function
Has some reference code for this
Has a #define to differentiate between running this on the Lighting PSOM and the TPS test board.
Gamer_LEDs.h
Still pretty incomplete
gamer_LEDs_test.c doesn’t do much, but it does exist as a test file
Flashing
To flash to the Lighting PSOM, use make TEST=<test_name> PROJECT_TARGET=stm32l431cbt
To flash to the TPS Board, use make TEST=<test_name> PROJECT_TARGET=stm32l432kcu
Pin Configuration and hardware
On the Lighting PSOM, the pins used are
PA0 (TIM2_CH1)
PA2 (TIM2_CH3)
PA11 (TIM1_CH4)
This board uses an STM32L431CBT microcontroller, and our LED strips use WS2814 ICs.
On the TPS Test Board, the pin used is
PA8 (TIM1_CH1)
This board uses an STM32L432KCU microcontroller, and the SMD LEDs use WS2812B IC leds.
Software Flowchart
WS2814 LED Driver
This is the LED type on the Lighting PSOM. It is different from the WS2812B on the test board which only has RGB (no W), and therefore has 24 bits per light instead of 32 bits per light. The WS2814 also has different timing requirements than the WS2812B.
Background
https://www.superlightingled.com/PDF/SPEC/WS2814-RGBW-Datasheet.pdf
Data encoded as pulses of set lengths (NZR protocol)
32 bits per light (RGBW)
Each light takes the first 32 bits it receives and passes the rest of the data on
Estimated Current Draw
The link for the above lights don’t give a power draw, so using a different LED of the same type (https://www.superlightingled.com/24v-fcob-spi-rgbw-ic-led-strip-light-ws2814-addressable-576-leds-m-p-6339.html ) for reference…
Given:
18 W/m, 90W/16.4 ft.
576 LEDs/m
Calculating current draw for one LED:
18W / 576 LED/m = 0.0313 W/LED
0.0313 W/LED / 24V = 0.0013 A/LED
For our LED strip:
784 LED/m
0.0013 * 784 = 1.0192 A / m
1.0192 A / m * 1 m / 3.28084 ft -> 1.0192 A / 3.28084 ft = 0.31065 A / ft
Assuming the requirement of a maximum of 1 light per board and a maximum of 4 ft for one light:
0.31065 A/ft * 4 ft = 1.2426 A
For BPS Strobe (https://www.amazon.com/Raryloy-Vehicles-Emergency-Warning-Surface/dp/B0CH9KNGL6?th=1 )
Given:
1 W/LED * 4 LEDs
Current: 4 W / 24 V = 0.167 A
Power Draw: I^2 (Rshunt) = 0.167^2 (0.090ohm) = 0.00251 w
NOTE:
When buying INA241A, ensure to buy automotive version -Q1.