PID Javascript demo

Published 2015-05-13

Back at the end of 2014 I had to give some brief instructions on how PID loops work.

Working at Gigatron at our CNC division, I had to understand, design and configure several PID loops on several types of machines over the years (plasma cutters, routers, etc).

From the point of view of an experienced programmer, PID loops are pretty obvious (if not immediatly, at least in retrospect). In fact, in LinuxCNC the important bit is implemented as a single line of code:

https://github.com/jepler/linuxcnc-mirror/blob/2.6/src/hal/components/pid.c#L421

To enhance my demonstration of how a PID loop could be implemented (at least a simple one) by a programmer, I wrote a javascript UI to present the relevant variables and allow an user to play around with different versions of the code.

Since then I added a couple of written instructions (the original presentation I made was face-to-face), translated to english (original was in portuguese) and put it up online for anyone to see.

It’s currently available at:

https://github.com/matheusd/graf-pid

Note: this is meant as a simple demonstration of PID loops and as a helper tool for someone either studying control theory or wanting to get a “feel” for how a machine driven by PID loops behaves. It is not an authoritative source for all things PID.