This is a Raspberry Pi B+ HAT that supports four high power LEDs. Each LED output uses a resistor configurable constant current driver with PWM support to control light intensity. A fourth LED channel was added to support color LEDs that have an extra Green or White LED. This HAT also supports Common-Anode LED configurations. The component selection as shown in the BOM is for a 50W RGB LED light that uses a constant current of 550mA at 24V-16.8V. The Design section discusses this in detail.
Order the parts from Mouser using this Shared BOM.
The Green LED failed on one of my lights. The board is working as it should. This is most likely a LED module problem or incorrect output current. Replaced the module, changed the current from 550mA to 500mA and added a scale factor on the green output which currently limits the duty cycle to a maximum of 75%. Green output is higher in intensity anyways.
Board Preview
Design
Input Power
Input power is 36VDC nominal with a range of 30V-37V. Input current is a maximum of 2A. This limit is due to the maximum current of the reverse input protection bridge rectifier (D1) which also serves to reduce the voltage on the 5V DC-DC converter (U3). If higher current is needed remove D1 and make the maximum input voltage 35VDC.
The Raspberry Pi can be safely back-powered by this HAT because the Ideal Diode circuit provides protection to both the Raspberry Pi and this HAT when the Raspberry Pi is powered by another source. Maximum Raspberry Pi power is 1.5A. Usually the Raspberry Pi will take substantially less than 1.5A when it is used with no external connections.
Example power budget...Powering a 50W RGB LED light purchased on eBay. The RGB LEDs of this light are wired with four wires in a common-anode configuration. For this light the White LED section is left unpopulated.
Current
Voltage
Power
Red
550mA
16.8V
9.24W
Green
550mA
24V
13.2W
Blue
550mA
24V
13.2W
LED Power
35.6W
LED Power @ 80% Efficiency
44.6W
Raspberry Pi
10.0W
Total System Power
54.6W
A 60W 36VDC power supply will drive the Raspberry Pi, RGBW LED Controller HAT, and the High Power LEDs. This power supply (part number HLG-60) from Mean Well will drive the 50W RGB light nicely.
Power Reality Check
In my testing I placed a Raspberry Pi, RGBW LED Controller HAT, and a 60W Power Supply in an enclosure to check temperatures. When I ran a rainbow sweep test the power consumption was around 18W and the HAT had a temperature rise of about 20C - 25C over room temperature. A static purple color test (both read and blue at full power) with power consumption around 35W the HAT temperature rise was 30C - 35C. Clearly this HAT will need better cooling to run higher power LED configurations.
LED driver
The LM3414 from TI is a 1-A, 60-W Common Anode-Capable Constant Current Buck LED Driver. Most constant current LED drivers have a current sense resistor in the high-side path which prevents common anode connections. The LM3414 puts the current sense resistor on the low side. This leaves the high side connected directly to the 36V of the input power. The positive side of all four LED outputs are connected together on the board forcing a common-anode topology. You must not connect the low side to ground.
The LM3414 average LED current (IL) is set by the RIADJ (R7, R9, R11, R13). Set LED average current to 550mA using the equation below.
Using the standard 1% resistor value the average LED current is
Choose a standard switching frequency (fSW) of 500kHz using equation below. Switching frequency (fSW) is set by RFS (R6, R8, R10, R12).
Using the standard 1% resistor value the switching frequency is
Determine minimum inductor value from maximum peak-to-peak LED current ripple (ΔILPP) using equation below. Set ΔILPP to 200mA.
Using the standard inductor value the peak-to-peak LED current ripple is
Determine peak LED current (ILP) using selected components using equation below. ILP is also the peak current through the inductor.
Compute the operating duty cycle (D) using equation below.
Determine minimum CIN (C7, C9, C11, C13) for 200mV or less voltage ripple (ΔVIN) using equation below.
PWM Controller
A Raspberry Pi has only one hardware capable PWM pin (GPIO18). With up to four PWM outputs needed for this HAT I decided to use a PCA9685 from NXP alleviate the load on the Raspberry Pi. The PCA9685 from NXP is a 16-Channel, 12-bit, I2C PWM controller. It supports independent LED on and off times so the LED outputs can be adjusted in phase along with pulse width. However, when phase is changed from 0 the next PWM cycle will reset the output. For frequent updates this causes the output light to flicker.
There are few settings that are important to using the PCA9685 on this HAT. First the EXTCLK bit in the MODE1 register must be set to 0. In the MODE2 register the INVRT bit must be set to 0 and the OUTDRV bit must be set to 1. Luckily this is the default state for all of these bits.
Raspberry Pi Setup
This setup makes two key assumptions. First you are using Raspbian. Second, Python3 is the target programming environment. Install or update Python3 and necessary libraries by performing the following...
Now is a good time to clone this repository on your Raspberry Pi. Clearly the KiCad files are not needed to configure and run this code on your Raspberry Pi so you pick and choose the files needed but these instructions will clone the entire repository.
mkdir ~/projects
cd ~/projects
git clone https://github.com/mikelawrence/RPi-HAT-RGBW-LED-Controller
Configure ID EEPROM
Raspberry Pi HATs require an ID EEPROM with data that uniquely identifies every hat ever made. Start by cloning this repository on your Raspberry Pi, building the EEPROM tools, and make the the eeprom_settings.eep file.
cd ~/projects/RPi-HAT-RGBW-LED-Controller/eeprom/
make all
./eepmake eeprom_settings.txt eeprom_settings.eep
The next command writes the freshly generated and unique eeprom_settings.eep file to the EEPROM but you must push and hold the write switch on the HAT before executing this command. By default the EEPROM on the HAT is write protected. Pushing the write switch allows writes to occur.
You will see the following if writing to the EEPROM was successful.
This will attempt to talk to an eeprom at i2c address 0x50. Make sure there is an eeprom at this address.
This script comes with ABSOLUTELY no warranty. Continue only if you know what you are doing.
Do you wish to continue? (yes/no): yes
Writing...
0+1 records in
0+1 records out
117 bytes (117 B) copied, 2.31931 s, 0.1 kB/s
Done.
This is what you will see if there is a problem communicating with the EEPROM.
This will attempt to talk to an eeprom at i2c address 0x50. Make sure there is an eeprom at this address.
This script comes with ABSOLUTELY no warranty. Continue only if you know what you are doing.
Do you wish to continue? (yes/no): yes
Writing...
dd: error writing ‘/sys/class/i2c-adapter/i2c-3/3-0050/eeprom’: Connection timed out
0+1 records in
0+0 records out
0 bytes (0 B) copied, 0.0539977 s, 0.0 kB/s
Error doing I/O operation.
Setup Interfaces
For this HAT you will need to enable the I2C and 1-Wire interfaces. From the command line type sudo raspi-config and follow the prompts to install I2C support in the kernel.
Now follow the same actions but enabling the 1-Wire interface.
It's time to reboot your Raspberry Pi with sudo reboot.
Test PCA9685 12-bit PWM Controller
Now let's see if the PWM Controller is present on the I2C bus by running sudo i2cdetect -y 1. Looking at the output of the i2cdetect command you will see 40 and 70 in a field of -- when the PCA9685 is detected on the bus. If you don't see the 40 something is wrong with the HAT or the bus is disabled. i2cdetect was installed when you installed the i2c-tools package in the Raspberry Pi Setup section.
Python3-w1thermsensor is a nice 1-Wire python library that also supports command line reading of temperatures from 1-Wire devices. You should have already installed this package in the Raspberry Pi Setup section.
Now test the RGBW LED Controller HAT's DS18B20 temperature sensor using w1thermsensor all.
[email protected]:~ $ w1thermsensor all
Got temperatures of 1 sensors:
Sensor 1 (00000991f822) measured temperature: 25.69 celsius
RGBW LED Controller HAT Test
See code-test section README.md for code that fires up the RGBW LED Controller HAT by blending between the primary colors and monitoring temperatures.
mikelawrence/RPi-HAT-RGBW-LED-Controller
Raspberry Pi RGBW LED Controller HAT
This is a Raspberry Pi B+ HAT that supports four high power LEDs. Each LED output uses a resistor configurable constant current driver with PWM support to control light intensity. A fourth LED channel was added to support color LEDs that have an extra Green or White LED. This HAT also supports Common-Anode LED configurations. The component selection as shown in the BOM is for a 50W RGB LED light that uses a constant current of 550mA at 24V-16.8V. The Design section discusses this in detail.
This PCB is designed using KiCad 5.0.0. This HAT is based on RPi_Hat_Template by XESS Corp.
Note: The LM3414 parts have an exposed pad on the bottom which requires either a reflow oven or hot air to solder properly.
Note: This HAT does not have the camera flex slot or the display flex cutout so technically cannot be called a HAT.
Status
Board Preview
Design
Input Power
Input power is 36VDC nominal with a range of 30V-37V. Input current is a maximum of 2A. This limit is due to the maximum current of the reverse input protection bridge rectifier (D1) which also serves to reduce the voltage on the 5V DC-DC converter (U3). If higher current is needed remove D1 and make the maximum input voltage 35VDC.
The Raspberry Pi can be safely back-powered by this HAT because the Ideal Diode circuit provides protection to both the Raspberry Pi and this HAT when the Raspberry Pi is powered by another source. Maximum Raspberry Pi power is 1.5A. Usually the Raspberry Pi will take substantially less than 1.5A when it is used with no external connections.
Example power budget...Powering a 50W RGB LED light purchased on eBay. The RGB LEDs of this light are wired with four wires in a common-anode configuration. For this light the White LED section is left unpopulated.
A 60W 36VDC power supply will drive the Raspberry Pi, RGBW LED Controller HAT, and the High Power LEDs. This power supply (part number HLG-60) from Mean Well will drive the 50W RGB light nicely.
Power Reality Check
In my testing I placed a Raspberry Pi, RGBW LED Controller HAT, and a 60W Power Supply in an enclosure to check temperatures. When I ran a rainbow sweep test the power consumption was around 18W and the HAT had a temperature rise of about 20C - 25C over room temperature. A static purple color test (both read and blue at full power) with power consumption around 35W the HAT temperature rise was 30C - 35C. Clearly this HAT will need better cooling to run higher power LED configurations.
LED driver
The LM3414 from TI is a 1-A, 60-W Common Anode-Capable Constant Current Buck LED Driver. Most constant current LED drivers have a current sense resistor in the high-side path which prevents common anode connections. The LM3414 puts the current sense resistor on the low side. This leaves the high side connected directly to the 36V of the input power. The positive side of all four LED outputs are connected together on the board forcing a common-anode topology. You must not connect the low side to ground.
The LM3414 average LED current (IL) is set by the RIADJ (R7, R9, R11, R13). Set LED average current to 550mA using the equation below.
Using the standard 1% resistor value the average LED current is
Choose a standard switching frequency (fSW) of 500kHz using equation below. Switching frequency (fSW) is set by RFS (R6, R8, R10, R12).
Using the standard 1% resistor value the switching frequency is
Determine minimum inductor value from maximum peak-to-peak LED current ripple (ΔILPP) using equation below. Set ΔILPP to 200mA.
Using the standard inductor value the peak-to-peak LED current ripple is
Determine peak LED current (ILP) using selected components using equation below. ILP is also the peak current through the inductor.
Compute the operating duty cycle (D) using equation below.
Determine minimum CIN (C7, C9, C11, C13) for 200mV or less voltage ripple (ΔVIN) using equation below.
PWM Controller
A Raspberry Pi has only one hardware capable PWM pin (GPIO18). With up to four PWM outputs needed for this HAT I decided to use a PCA9685 from NXP alleviate the load on the Raspberry Pi. The PCA9685 from NXP is a 16-Channel, 12-bit, I2C PWM controller. It supports independent LED on and off times so the LED outputs can be adjusted in phase along with pulse width. However, when phase is changed from 0 the next PWM cycle will reset the output. For frequent updates this causes the output light to flicker.
There are few settings that are important to using the PCA9685 on this HAT. First the EXTCLK bit in the MODE1 register must be set to 0. In the MODE2 register the INVRT bit must be set to 0 and the OUTDRV bit must be set to 1. Luckily this is the default state for all of these bits.
Raspberry Pi Setup
This setup makes two key assumptions. First you are using Raspbian. Second, Python3 is the target programming environment. Install or update Python3 and necessary libraries by performing the following...
Clone this Repository
Now is a good time to clone this repository on your Raspberry Pi. Clearly the KiCad files are not needed to configure and run this code on your Raspberry Pi so you pick and choose the files needed but these instructions will clone the entire repository.
Configure ID EEPROM
Raspberry Pi HATs require an ID EEPROM with data that uniquely identifies every hat ever made. Start by cloning this repository on your Raspberry Pi, building the EEPROM tools, and make the the
eeprom_settings.eep
file.The next command writes the freshly generated and unique
eeprom_settings.eep
file to the EEPROM but you must push and hold the write switch on the HAT before executing this command. By default the EEPROM on the HAT is write protected. Pushing the write switch allows writes to occur.You will see the following if writing to the EEPROM was successful.
This is what you will see if there is a problem communicating with the EEPROM.
Setup Interfaces
For this HAT you will need to enable the I2C and 1-Wire interfaces. From the command line type
sudo raspi-config
and follow the prompts to install I2C support in the kernel.Now follow the same actions but enabling the 1-Wire interface.
It's time to reboot your Raspberry Pi with
sudo reboot
.Test PCA9685 12-bit PWM Controller
Now let's see if the PWM Controller is present on the I2C bus by running
sudo i2cdetect -y 1
. Looking at the output of thei2cdetect
command you will see40
and70
in a field of--
when the PCA9685 is detected on the bus. If you don't see the40
something is wrong with the HAT or the bus is disabled.i2cdetect
was installed when you installed the i2c-tools package in the Raspberry Pi Setup section.Test the DS18B20 1-Wire Thermometer
Python3-w1thermsensor is a nice 1-Wire python library that also supports command line reading of temperatures from 1-Wire devices. You should have already installed this package in the Raspberry Pi Setup section.
Now test the RGBW LED Controller HAT's DS18B20 temperature sensor using
w1thermsensor all
.RGBW LED Controller HAT Test
See code-test section README.md for code that fires up the RGBW LED Controller HAT by blending between the primary colors and monitoring temperatures.