questions on using the PID library for a makeshift waterbath

Hi there. I am trying to put together a simple temperature controlled water bath for sous vide cooking. it consists of a pot sitting on an electric hob with a temperature sensor sitting in the bath.the arduino is connected to a solid state relay which allows it to control the hob. i have been trying to use the arduino pid library to regulate the temperature but havent had a great deal of success. i tried using the pid adaptive tunings example and watched as it still applied power as it passed the setpoint which had me bemused. could anyone point me towards a resource which would provide explanation on how to choose the best pid values? my setup has a big metal plate holds a lot of heat and so takes a long time to dissipate resulting in hefty overshooting and lengthy correction time. its far from an ideal setup but im sure with the right tuning it can provide a reasonably steady state.

i have also tried to use the autotune library but again havent quite been able to grasp how to use it. i have tried looking for good documentation but havent found anything which explains how to use it(ive seen the authors description on how it works but this doesnt explain how to implement it)

any help on the matter would be much appreciated. thanks.

It is possible that your system has dead time. That is the time from that the actuator changes until the sensor records that change. Systems with dead time are notoriously hard to tune.

Normally i recommend this tuning procedure:

  • Start with all gains at zero
  • Increase kp in steps until oscillation occurs. That is not just overshoot but a steady oscillation. It is the proportional par of a pid that does the main job but it cannot regulate to zero error. Increasing the gain reduces the remaining (after several tau) error up to a point where oscillation occurs. When you have found this point bach of to 70%-80% of kp
  • Increase ki in steps until oascillation occurs. The function of the integral part is to reduce the remaining error to zero but it slows the regulator down and increases the risk for oscillations. Oscillations caused by the integrator have a output that is 90 degrees out of phase with the input. When you find the value where the system starts to oscillate back off to 70%-80% of ki.
  • increase kd as much as possible to stabilize the system

These are just rules of thumb and they could be hard to apply when dead time is involved. Maybe you have to experiment with sensor placement and/or agitate/circulate the water

there most certainly is dead time. i would imagine that there is a certain amount in all of these systems but since the heater is at the bottom of the pot and itself takes time to heat up it is a considerable amount of time before the output is registered. is the logic in the pid algorithm capable of compensating for this? or would i be better of fiddling about with my own logic, eg. testing how long it takes for the temperature to keep rising after power has been cut off as i have been thinking of doing?

If you can establish both the time constant and the dead time (please observe, they are two very different phenomena) the PID parameters can be estimated from that

An other solution would be to record the steady state temperatures for different levels of power and build a fuzzy controller on those values. Or you could use these values and a stepwise linear function to interpolate offset and k values for a simple P regulator