PID gains - Brewpi

People, I changed the Brewpi code for Arduino to use it as mash controller. So, now I am testing it. See image below, where red line is HLT temperature and blue line is mash temperature.

I will try to increase Proportional gain e disable Derivate control, because I need more speed temperature increasement. Do you agree with those actions?

Kp: 7
Ki: 0,125
Kd: -3

And, what is your PID settings?

Thanks,

Fabiano da Mata

@Elco and all, when I try tuning my BrewPi, using Pessen Integral Rule (Ultimate Gain), I found the following values:

Kd: 30
Ki: 0.2
Kd: 1470

But, when I type those values on BrewPi, Kd is changed by code for some negative value. Is it a bug? Or Is there some reason for this?

I should remember you (maybe those values sound strange and extremely high for traditional BrewPi usage) that I changed the code to use it as a mash controller.

Thanks,

Fabiano da Mata

The maximum range of the internal storage format is -64 to 64. I don’t know how you changed the code, but the derivative used to be per minute. Having your Kd that high sounds wrong. With a mashing setup, you’d expect very little overshoot, so I think having Kd at zero would work fine probably.

@Elco, I changed only TempControl.h, where I reduce min times on/off, because now my element is a electric coil (5500 W). And I suspect that I need change derivate by minute, because that high number (Kd=1470) was calculated by second. So, Kd goes to 24,5 by minute. Make sense for you now?

Other doubt, is should be positive or negative number? What is the difference between + or - number?

What are the Kp, Ki and Kp to spark when in mash usage?

Thanks,

Fabiano da Mata

if the only modifications that you made are the minimum on and off times, then I don’t think the code is really suitable for mashing. That is why I am now rewriting the code to support PWM.

The PWM settings in your code only give you a difference between fridge temperature setting and beer temperature setting. They do not change how the actuators are driven.

@Elco, and about the Kd signal, what you can tell us? Why in default it is negative?

It is negative because it acted on the derivative of the input signal to the PID, not on the error.

The reason for this is that the derivative of the error is sensitive to setpoint changes.

If the temperature is rising towards the setpoint, the derivative of the temperature is positive, and the derivative of the error is negative.

@Elco, the derivative of the error still negative when I try heat a HLT (increase temperature) to increase MLT temperature during mash? So, I need keep it negative or should I considere, in this case that I am using BrewPi as a mash controller, positive?

Thanks for your help,

Fabiano da Mata

Nope, still needs to be negative. There is not much difference between a mash process and fermentation process in terms of physics.

I will probably change the PID parameters to Kp, Ti and Ts in the future: time constants for the derivative and integral gain. It is more widely used in industry and more intuitive.

@Elco, in industry, the classic PIDs outputs are analog signal between 4-20 mA. In the case of Brewpi in reality we have two on-off states.

When does the Brewpi trigger the control element? Only when the PV leaves the SP? How Brewpi does its estimates?

Thanks,

Fabiano da Mata

On the BrewPi Spark, the heater and cooler are driven with PWM, which can be seen as an ‘analog’ signal.

On the old Arduino, there is no PWM. The only PID action is setting the fridge temperature based on a PID calculation of the beer temperature.

@Elco, and how is it calculated (fridge temperature based on a PID calculation of the beer temperature)? What is the relationship between fridge/beer temperature?

If I remember correctly, you have the Arduino version, on which you can view on the control algorithm tab how the calculation is done.

On the Arduino:
fridge setpoint = beer setpoint + beer error * Kp + beer error integral * Ki + beer error derivative * Kd

On the Spark:
fridge setpoint = beer setpoint + beer error * Kp * (1 + integral / Ti + derivative * Td)

This leaves out some details like anti-windup. For that, please take a look at the source code.

Yes, I am a Arduino User. The source code would be TempControl.cpp e TempControl.h?

Could you explain a little beer more how to find beer error integral and derivative? I suppose beer error is beer SP - beer PV, right?

Fabiano

The Arduino code is here:

The newer equivalent in the Spark code is here:

I cannot help you write the code for Arduino. We did the work for the Spark and abandoned Arduino for good reasons. You are on your own if you insist on using the Arduino. I’m not going to put in anymore time.