Skip to content

Control blocks

setra

Control blocks for mechatronics: PID, filters, motion profiles, state-space control, a Kalman filter and plant models for simulation.

See the code on GitHub

The problem

Rewriting a PID or a Kalman filter in every project leads to different bugs every time. I wanted one tested core that runs the same on a computer and on a microcontroller.

How it is built

The core is Rust with no std and no dynamic memory, so the code tested on the computer is the same code that runs on the microcontroller. On top there is a Python module to simulate and plot. Time is always in seconds and every block gets its own dt: nothing depends on a clock or a platform.

What it includes

pidClamped output, anti-windup integral, filtered derivative and feedforward
filterLow-pass, biquad and slew-rate limiter
profileTrapezoidal profile and jerk-limited S-curve
plantDC motor with dry friction, pendulum, Furuta pendulum and Runge-Kutta 4
statesDiscretization, LQR, Luenberger observer
identificationFitting a motor model from a test run
kalmanFixed-size linear Kalman filter

Where it stands

It works in simulation: a motor follows a trapezoidal profile under a load torque, an inverted pendulum is balanced with LQR and an observer, and a Furuta pendulum runs with the limits of a real rig. It still needs a physical build.

Technologies

  • Rust
  • no_std
  • Python
  • PID
  • LQR
  • Kalman filter
  • Motion profiles

Gallery

Photos of this project are coming soon.

Are you interested in any of this?

Write to me and we'll talk it over.

Write to me