Solar Tracker
A dual-axis tracker that keeps a solar panel pointed at a light source, using a four-quadrant photodiode sensor and an STM32 PID loop to drive two stepper motors.
The panel should face the light. A four-quadrant photodiode sensor measures which way the light is off-centre, and an STM32 turns two stepper motors (pan and tilt) until the error is near zero. The system is built first on a dev board and perfboard, then moved to a custom two-layer PCB. It is currently in development.
A lamp indoors makes the tracker testable on any day; tracking the sun outdoors is a later test, where panel output power is compared with a fixed panel.
Four photodiodes sit in a quadrant behind a cross-shaped shade, so the signal depends on the angle of the light. Transimpedance amplifiers convert the photodiode currents to voltages, starting with a single gain range.
With photodiode currents ITL, ITR, IBL and IBR, the firmware computes a normalised error for each axis:
- ex = ((ITL + IBL) − (ITR + IBR)) / (ITL + ITR + IBL + IBR + ε)
- ey = ((ITL + ITR) − (IBL + IBR)) / (ITL + ITR + IBL + IBR + ε)
Normalising reduces brightness sensitivity only while the channels are linear. It does not fix saturation, low signal-to-noise indoors, mismatched channels or several competing lights, so the design adds:
- A minimum-total-light threshold: below it, the tracker holds position
- Per-channel calibration of gain and offset, stored in firmware
- Switched gain with hysteresis, only if one gain range proves insufficient
STM32 firmware reads the four signals, computes the normalised error, and steps the motors with a PID loop.
- Stepper control: hardware-timer step generation for the pan and tilt axes
- Homing and limits: homing and limit switches keep each axis in range
- Fault handling: the motors stop on a limit hit or a lost signal
- PID loop: anti-windup and output limits, tuned against the measured step response
There are no encoders, so the PID loop closes on the photodiode error rather than on motor position. The stepper position itself is open loop.
An INA226 measures panel voltage and current, using a shunt in the panel output line. Panel output power is then compared with a fixed panel to show the gain from tracking.
The prototype on a dev board and perfboard is followed by a single two-layer KiCad board holding:
- The STM32 microcontroller
- Stepper drivers (TMC2209-class, final choice subject to motor ratings)
- Photodiode transimpedance amplifiers
- The INA226 power monitor
- Limit-switch inputs and test points
The board is brought up in stages: power rails, MCU, drivers, sensor amplifiers, then the INA226. The mount is a simple 3D-printed or hobby pan-tilt frame.
Indoor and outdoor results are kept separate. A lamp has a different beam geometry, spectrum and angular size from the sun, so indoor results are not assumed to transfer outdoors.
- Indoor (lamp): sensor acquisition, loop stability, step response, and disturbance rejection, including ambient-light rejection and saturation recovery after a bright pulse
- Outdoor (sun): alignment error and panel power against a fixed panel, if weather allows
- Brushed DC azimuth with an encoder, as a second motor-control approach
- Switched gain for outdoor illumination, if one range fails
- Sun-position feed-forward using an established solar-position algorithm such as NREL SPA
- GNSS time and location from the Wireless Telemetry Platform board
- Python hardware-in-the-loop test environment with injected noise and sensor dropouts
- Outdoor tests over several hours
Coming soon.