Here is a list of previous posts
Gr0G - 03 - High-pressure system design
Gr0G - 07 - Playing with the Gertbot
Gr0G - 11 - Building the box (2)
Gr0G - 12 - Building the high-pressure system
Gr0G - 13 - Building the high-pressure system (2)
Source code available at https://github.com/ambrogio-galbusera/gr0g, https://github.com/ambrogio-galbusera/gr0g-ble-android and https://github.com/ambrogio-galbusera/gr0g-ble
Some days of testing have underlined that some improvements are required. The first improvement will be the installation of more efficient LEDs because the light provided by the LED strips is not sufficient for the plants to grow healthy
I have 5 high-efficiency LEDs (yes, one is missing... but let's start with these) from a previous project, where I made some experiments on VLC (Visual Light Communication). May you be interested, this is the link to that project: LEDRoadTestPlus - Post 1 . I will also reuse the evaluation board for the TPS92512 to drive and dim LEDs.
The TPS92512EVM-001TPS92512EVM-001 evaluation module (EVM) helps designers evaluate the operation and performance of the TPS92512HV buck switching regulator designed for high-current LED-drive applications. The TPS92512HV device is designed to control the drive of high-brightness light emitting diodes and features a wide input voltage range (12 V to 48 V), PWM dimming capability, analog dimming capability, adjustable/syncable switching frequency, and input undervoltage protection.
VIN will come directly from the 12V power supply. To dim the LEDs, I will use a PWM signal connected to the PDIM pin, which, as the evaluation kit's user manual states,
The PDIM test point connects directly to the PDIM pin of the TPS92512 device. Leave open for normal operation. If PWM dimming is used, apply a square wave with a low level of GND and a high level of between 2 V and 4.5 V. The dimming frequency range is 100 Hz to 1 kHz.
The TPS92512 incorporates a PWM dimming input pin, which directly controls the enable/disable state of the internal gate driver. When PDIM is low, the gate driver is disabled. The PDIM pin has a 1 µA pull-up current source, which creates a default ON state when the PDIM pin is floating. When PDIM goes low, the gate driver shuts off and the LED current quickly reduces to zero. A square wave of variable duty cycle should be used and should have a low level below 0.79 V and a high level of 1.45 V or above.
The TPS92512 uses a sample-and-hold switch on the error amplifier output. During the PDIM off-time the COMP voltage remains unchanged. Also, the error amplifier output is internally clamped low. These techniques help the system recover to its regulation duty cycle quickly. The dimming frequency range is 100 Hz to 1 kHz and the minimum duty cycle is only limited in cases where the BOOT capacitor can discharge below its under-voltage threshold of 2 V (VIN is within 2 V of the total output voltage).
The Raspberry Pi 4's PWM0 signal will be used. This is a 3.3V output, so it compatible with the specification for the PDIM input
I built a bracket where the LEDs will be mounted. The bracket will be joined to the bracket that I built to handle the Pimoroni Enviro board
With cardboard, I created a sort of "cube" around the frame and finally I glued the LEDs to the cardboard
Here is the LEDs installed in the Gr0G box
To enable the PWM output, the following lines have to be added to file /boot/config.txt
dtoverlay=pwm,pin=12,func=4
where
pin=12 says to the pwm overlay to use pin 12 and
func=4 says to use function 4 (which means hardware PWM)
Strangely, I was not able to drive PWM using Rpi.GPIO library. The workaround I followed is to write directly to sysfs as shown in the following code
os.system("echo 0 > /sys/class/pwm/pwmchip0/export") os.system("echo 1000000 > /sys/class/pwm/pwmchip0/pwm0/period") os.system("echo 500000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle") os.system("echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable")
period and duty_cycle are expressed in nanoseconds. So, when 1000000 (1 million) is written to period, the PWM hardware generates a square wave at 1 kHz
I added the control of the new PWM output to the LightController class. No other changes have to be done (thanks Separation of Concerns!)
Here is a video showing the new LEDs at work, simulating a day and night cycle