PID Controller

I want to do PID control, I could not find a Squirrel library. What would be a good place to start?

http://playground.arduino.cc/Code/PIDLibrary
http://code.activestate.com/recipes/577231-discrete-pid-controller/

Any other suggestions? Would it be better to run this on the Imp or run it server side for control?

Thanks,
Paul

You should really run this device side. Generally, the feedback loop needs to be as quick as possible (depends on the bandwidth of the system in question). You might adjust the coefficients remotely but the actual control loop would run locally.

PID control is really quite simple, there’s some pseudocode on http://en.wikipedia.org/wiki/PID_controller - the tricky bit is working out the right coefficients for your system.

I’ve seen this article referenced many places

http://www.embedded.com/ContentEETimes/Documents/Embedded.com/2000/f-wescot.pdf

PID without a PhD by Tim Wescott

I also want to do PID on the Imp but I’d guess I am many months out from accomplishing it. I need to learn PID and squirrel and finish building my system.

The examples I have seen use imp.wakeup to call a function after some period of time - often a function calling itself. I think one would set the PID controller to loop in this way; setting the rate at the appropriate speed. The article I linked discusses how often to calculate based on your desired settling time.

If you know your desired settling time, desired calculation rate and your ins and outs then perhaps this forum could advise you about the capability of the Imp hardware. In my case I am controlling temperature and it changes so slowly I have no concerns about the Imp keeping up.

Just general note in many years of commissioning PID loops I’ve never used the D: Derivative term. What are you trying to regulate? You can get reasonable control with just the P term which would be simple to implement and then add the I term. I often send people hear http://www.csimn.com/CSI_pages/PIDforDummies.html

Thanks for all the help folks.

This is for fermentation control.

I have found this stuff as well:
http://www.expertune.com/tutor.aspx
http://wwwdsa.uqac.ca/~rbeguena/Systemes_Asservis/PID.pdf

Some additional google-fu:

http://www.controlguru.com/
http://brettbeauregard.com/blog/2012/01/arduino-pid-autotune-library/


Paul I would like to help out on this.
Perhaps testing I’ve got a whole load of motorised valves I want to fit to control my radiators (heating). I was going to use straight proportional control but having PI would be brilliant.

Sounds good! I would be happy to share. I was planning on just trying to port the Arduino library mentioned at the top to Squirrel. I’m down for a few days, My Imp died yesterday so I’m waiting on an RMA.

The author of the Arduino goes through the code almost line by line here: http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-introduction/. I’m hoping that helps with the port as well as my understanding.

There is also an Autotune library as well here: http://playground.arduino.cc/Code/PIDAutotuneLibrary

Paul
p g r u n w a l d AT g m a i l DOT c o m