The challenge
The system had to keep a sensor platform at a set distance from a moving object. That required the whole chain from analog sensor and noise filtering, through communication between two microcontrollers, to control of a linear actuator, built and tested on real hardware.
The solution
A sensor node reads an infrared distance sensor, filters the signal in analog and digital stages, calibrates the measurement to millimetres and sends it over a differential RS422 link. A control node computes the deviation from the target distance and drives the actuator with PWM and a direction signal. A Python application on the PC is used for logging and monitoring.
How it was built
The project was developed in a three-person team. I contributed across hardware and PCB work, embedded firmware and control, integration and testing. The team designed a custom KiCad circuit board with voltage regulation, analog amplification, an 8th-order switched-capacitor low-pass filter clocked from the microcontroller, and RS422 transceivers. The firmware is written in C for the STM32F303, with ADC acquisition, exponential smoothing, serial communication and timer-driven PWM. P, PI, PD and PID control were tested with Ziegler–Nichols tuning; full PID was unstable, so the final solution uses proportional control with a deadband and saturation.
Result
The system worked end to end, from sensor to actuator. It regulated stably with little overshoot and a steady-state deviation of about 3 mm. The requirement was ±2 mm, so it was not fully met, and the response time was not measured precisely.
Context
The control node waits for new measurements without a timeout, so a communication dropout can leave the actuator running on its last command, a missing failsafe identified in the evaluation. The circuit board had to be reworked after pin-mapping errors.