The PID Controller –  Part 3

Hi there!

In my earlier post, I described the equations that drive the PID controller behavior.  Finally here is the PID controller implementation. The code is very simple: there are just two things to notice:

  • The thread is executed once each SampleTime  milliseconds. There’s no warranty that it will be actually executed exactly when it’s due, but the PID controller is robust enough to tolerate small delays… at least for our Mindstorms applications.
  • The u is saturated to the defined boundaries before being assigned to the OutputSignal .

You can compile the above code using Xamarin Studio 5.10.1 (Build 6), with Mono 4.2.1 as active runtime and the Monobrick Firmware Library 1.2.0.39486 to let it work on board the Lego Mindstorms Ev3 with the Monobrick firmware.

Full code is available here and I will soon post a sample application. Stay tuned… And Happy New Year!

The PID Controller – Part 3
Tagged on:             

Leave a Reply