All Projects

Real-Time Steer-by-Wire Control

C · STM32 · Embedded Systems · PID Control · Anti-Windup · PWM · UDP Sockets · HTTP · SVG · Git


Real-Time Steer-by-Wire Control

Overview

This semester project for "Programmable Logic Controllers and Systems" (PSR) at CTU (during my exchange) involved creating a digital motor controller for a steer-by-wire application. The system controlled the shaft position of a DC motor (Maxon RE25) based on a setpoint received via UDP from a reference motor. Key features included an interrupt-driven device driver for position sensing, a PID controller implemented on an STM32F4, and a simple web server for live graphing of controller state.


My Role

  • Co-developed the complete steer-by-wire system, including the control logic for the driven motor, network communication, and the web visualization interface.
  • Implemented and tuned a P/PID position controller in C on the STM32F4 microcontroller, incorporating an anti-windup scheme to ensure robust performance.
  • Developed an interrupt-driven routine for accurately reading motor position from a quadrature encoder (HEDS-5540).
  • Configured and utilized PWM signals (20 kHz) via FPGA registers (interfaced by the MCU) for precise motor actuation using an H-bridge (L298N).
  • Implemented UDP socket communication to receive position setpoints from the reference motor controller.
  • Developed a basic HTTP web server on the embedded system to serve live SVG graphs displaying actual motor position, requested position, and PWM duty cycle with a history of at least 2 seconds (refreshed ~100ms).
  • Utilized Git for version control throughout the project, with regular commits from both team members.

Challenges

  • Precise Position Tracking: Achieving accurate and responsive tracking of the absolute reference position, especially with fast movements or external disturbances.
  • Real-Time Data Communication & Visualization: Transmitting setpoints via UDP and refreshing live graphs from an embedded web server with minimal delay.
  • Integrating Multiple System Components: Ensuring seamless interaction between the interrupt handler, control loop, UDP communication task, and web server task.

Outcomes

  • Successfully demonstrated a functional steer-by-wire system capable of precise motor position tracking based on UDP setpoints.
  • The controlled motor accurately mirrored the movements of the reference motor, including tracking absolute position over multiple revolutions.
  • Implemented a live web interface successfully displaying key controller variables (setpoint, actual position, PWM output) with a short history, allowing for real-time monitoring and debugging.
  • The system met requirements for response speed, minimal steady-state error, and no oscillations, without losing motor position.

Figures

Block diagram of the PID motor control system showing the control loop architecture with anti-windup scheme
Fig. 1: Block diagram of the PID motor control system showing the control loop architecture with anti-windup scheme