Tuning Help - after reinstall


#1

Good evening, Elco.
My BrewPi was corrupted after an electrical outage. I had re-installed the package and need some help with the tuning parameters. What should P&ID parameters would be more appropriate? Thank you very much. -Maciej


Parameters here:

{
  "kind": "Control",
  "pids": [
    {
      "kind": "Pid",
      "name": "heater1",
      "enabled": true,
      "setPoint": {
        "kind": "SetPointSimple",
        "value": 4.4453
      },
      "inputSensor": {
        "kind": "TempSensor",
        "name": "fridge",
        "sensor": {
          "kind": "OneWireTempSensor",
          "value": 14.0625,
          "connected": false,
          "address": "28E16BA20600001E",
          "calibrationOffset": 0
        }
      },
      "inputError": 9.6367,
      "Kp": 10,
      "Ti": 600,
      "Td": 60,
      "p": -96.3672,
      "i": 0,
      "d": -0.1172,
      "actuatorIsNegative": false,
      "outputActuator": {
        "kind": "ActuatorPwm",
        "value": 0,
        "period": 4,
        "minVal": 0,
        "maxVal": 100,
        "target": {
          "kind": "ActuatorMutexDriver",
          "mutexGroup": {
            "kind": "ActuatorMutexGroup",
            "deadTime": 1800000,
            "lastActiveTime": 4293167296
          },
          "target": {
            "kind": "ActuatorPin",
            "state": false,
            "pin": 16,
            "invert": false
          }
        }
      }
    },
    {
      "kind": "Pid",
      "name": "heater2",
      "enabled": true,
      "setPoint": {
        "kind": "SetPointSimple",
        "value": null
      },
      "inputSensor": {
        "kind": "TempSensor",
        "name": "beer2",
        "sensor": {
          "kind": "OneWireTempSensor",
          "value": 12.3125,
          "connected": false,
          "address": "28ABD0A106000013",
          "calibrationOffset": 0
        }
      },
      "inputError": 0,
      "Kp": 10,
      "Ti": 600,
      "Td": 60,
      "p": 0,
      "i": 0,
      "d": 0,
      "actuatorIsNegative": false,
      "outputActuator": {
        "kind": "ActuatorPwm",
        "value": 0,
        "period": 4,
        "minVal": 0,
        "maxVal": 100,
        "target": {
          "kind": "ActuatorMutexDriver",
          "mutexGroup": {
            "kind": "ActuatorMutexGroup",
            "deadTime": 1800000,
            "lastActiveTime": 4293167296
          },
          "target": {
            "kind": "ActuatorNop",
            "state": false
          }
        }
      }
    },
    {
      "kind": "Pid",
      "name": "cooler",
      "enabled": true,
      "setPoint": {
        "kind": "SetPointSimple",
        "value": 4.4453
      },
      "inputSensor": {
        "kind": "TempSensor",
        "name": "fridge",
        "sensor": {
          "kind": "OneWireTempSensor",
          "value": 14.0625,
          "connected": false,
          "address": "28E16BA20600001E",
          "calibrationOffset": 0
        }
      },
      "inputError": 9.6367,
      "Kp": 10,
      "Ti": 1800,
      "Td": 200,
      "p": -96.3672,
      "i": 0,
      "d": -0.4688,
      "actuatorIsNegative": true,
      "outputActuator": {
        "kind": "ActuatorPwm",
        "value": 96.8359,
        "period": 1200,
        "minVal": 0,
        "maxVal": 100,
        "target": {
          "kind": "ActuatorMutexDriver",
          "mutexGroup": {
            "kind": "ActuatorMutexGroup",
            "deadTime": 1800000,
            "lastActiveTime": 4293167296
          },
          "target": {
            "kind": "ActuatorTimeLimited",
            "minOnTime": 120,
            "minOffTime": 180,
            "maxOnTime": 65535,
            "active": false,
            "target": {
              "kind": "ActuatorPin",
              "state": false,
              "pin": 17,
              "invert": false
            }
          }
        }
      }
    },
    {
      "kind": "Pid",
      "name": "beer2fridge",
      "enabled": false,
      "setPoint": {
        "kind": "SetPointSimple",
        "value": null
      },
      "inputSensor": {
        "kind": "TempSensor",
        "name": "beer1",
        "sensor": {
          "kind": "OneWireTempSensor",
          "value": 18.375,
          "connected": false,
          "address": "28EEDA30231500EC",
          "calibrationOffset": 0
        }
      },
      "inputError": 0,
      "Kp": 2,
      "Ti": 7200,
      "Td": 1200,
      "p": 0,
      "i": 0,
      "d": 0,
      "actuatorIsNegative": false,
      "outputActuator": {
        "kind": "ActuatorSetPoint",
        "targetSetPoint": {
          "kind": "SetPointSimple",
          "value": 4.4453
        },
        "targetSensor": {
          "kind": "TempSensor",
          "name": "fridge",
          "sensor": {
            "kind": "OneWireTempSensor",
            "value": 14.0625,
            "connected": false,
            "address": "28E16BA20600001E",
            "calibrationOffset": 0
          }
        },
        "referenceSetPoint": {
          "kind": "SetPointSimple",
          "value": null
        },
        "output": 127.9961,
        "achieved": 127.9961,
        "minimum": -10,
        "maximum": 10
      }
    }
  ],
  "sensors": [
    {
      "kind": "TempSensor",
      "name": "fridge",
      "sensor": {
        "kind": "OneWireTempSensor",
        "value": 14.0625,
        "connected": false,
        "address": "28E16BA20600001E",
        "calibrationOffset": 0
      }
    },
    {
      "kind": "TempSensor",
      "name": "beer1",
      "sensor": {
        "kind": "OneWireTempSensor",
        "value": 18.375,
        "connected": false,
        "address": "28EEDA30231500EC",
        "calibrationOffset": 0
      }
    },
    {
      "kind": "TempSensor",
      "name": "beer2",
      "sensor": {
        "kind": "OneWireTempSensor",
        "value": 12.3125,
        "connected": false,
        "address": "28ABD0A106000013",
        "calibrationOffset": 0
      }
    }
  ],
  "actuators": [
    {
      "kind": "ActuatorPwm",
      "value": 96.8359,
      "period": 1200,
      "minVal": 0,
      "maxVal": 100,
      "target": {
        "kind": "ActuatorMutexDriver",
        "mutexGroup": {
          "kind": "ActuatorMutexGroup",
          "deadTime": 1800000,
          "lastActiveTime": 4293167296
        },
        "target": {
          "kind": "ActuatorTimeLimited",
          "minOnTime": 120,
          "minOffTime": 180,
          "maxOnTime": 65535,
          "active": false,
          "target": {
            "kind": "ActuatorPin",
            "state": false,
            "pin": 17,
            "invert": false
          }
        }
      }
    },
    {
      "kind": "ActuatorPwm",
      "value": 0,
      "period": 4,
      "minVal": 0,
      "maxVal": 100,
      "target": {
        "kind": "ActuatorMutexDriver",
        "mutexGroup": {
          "kind": "ActuatorMutexGroup",
          "deadTime": 1800000,
          "lastActiveTime": 4293167296
        },
        "target": {
          "kind": "ActuatorPin",
          "state": false,
          "pin": 16,
          "invert": false
        }
      }
    },
    {
      "kind": "ActuatorPwm",
      "value": 0,
      "period": 4,
      "minVal": 0,
      "maxVal": 100,
      "target": {
        "kind": "ActuatorMutexDriver",
        "mutexGroup": {
          "kind": "ActuatorMutexGroup",
          "deadTime": 1800000,
          "lastActiveTime": 4293167296
        },
        "target": {
          "kind": "ActuatorNop",
          "state": false
        }
      }
    }
  ],
  "setpoints": [
    {
      "kind": "SetPointNamed",
      "name": "beer1set",
      "setPoint": {
        "kind": "SetPointSimple",
        "value": null
      }
    },
    {
      "kind": "SetPointNamed",
      "name": "beer2set",
      "setPoint": {
        "kind": "SetPointSimple",
        "value": null
      }
    },
    {
      "kind": "SetPointNamed",
      "name": "fridgeset",
      "setPoint": {
        "kind": "SetPointSimple",
        "value": 4.4453
      }
    }
  ]
}

#2

It is very strange that your beer setpoint does not seem to be set in the beer-to-fridge PID, but it is showing on the display.
Your PID also seems to be disabled.

I would really like to know how it is possible that the system is in this state. Could you give the steps you took?

To get out of this state, can you try setting to fridge constant and then back to beer constant?


#3

Hi, Elco

I installed the current version of BrewPi from the instructions on this website. Configured the devices (temperature probes and SSR for heating and cooling). Transferred my wort to the fermentor and set the the beer constant to 65F. Oxygenated and pitched my yeast.

I switched from beer constant to fridge constant back to beer constant and finally profile.

I updated the parameters last night and they look like this:

{
  "kind": "Control",
  "pids": [
    {
      "kind": "Pid",
      "name": "heater1",
      "enabled": true,
      "setPoint": {
        "kind": "SetPointSimple",
        "value": 4.4453
      },
      "inputSensor": {
        "kind": "TempSensor",
        "name": "fridge",
        "sensor": {
          "kind": "OneWireTempSensor",
          "value": 14.0625,
          "connected": false,
          "address": "28E16BA20600001E",
          "calibrationOffset": 0
        }
      },
      "inputError": 9.6367,
      "Kp": 10,
      "Ti": 600,
      "Td": 60,
      "p": -96.3672,
      "i": 0,
      "d": -0.1172,
      "actuatorIsNegative": false,
      "outputActuator": {
        "kind": "ActuatorPwm",
        "value": 0,
        "period": 4,
        "minVal": 0,
        "maxVal": 100,
        "target": {
          "kind": "ActuatorMutexDriver",
          "mutexGroup": {
            "kind": "ActuatorMutexGroup",
            "deadTime": 1800000,
            "lastActiveTime": 4293167296
          },
          "target": {
            "kind": "ActuatorPin",
            "state": false,
            "pin": 16,
            "invert": false
          }
        }
      }
    },
    {
      "kind": "Pid",
      "name": "heater2",
      "enabled": true,
      "setPoint": {
        "kind": "SetPointSimple",
        "value": null
      },
      "inputSensor": {
        "kind": "TempSensor",
        "name": "beer2",
        "sensor": {
          "kind": "OneWireTempSensor",
          "value": 12.3125,
          "connected": false,
          "address": "28ABD0A106000013",
          "calibrationOffset": 0
        }
      },
      "inputError": 0,
      "Kp": 10,
      "Ti": 600,
      "Td": 60,
      "p": 0,
      "i": 0,
      "d": 0,
      "actuatorIsNegative": false,
      "outputActuator": {
        "kind": "ActuatorPwm",
        "value": 0,
        "period": 4,
        "minVal": 0,
        "maxVal": 100,
        "target": {
          "kind": "ActuatorMutexDriver",
          "mutexGroup": {
            "kind": "ActuatorMutexGroup",
            "deadTime": 1800000,
            "lastActiveTime": 4293167296
          },
          "target": {
            "kind": "ActuatorNop",
            "state": false
          }
        }
      }
    },
    {
      "kind": "Pid",
      "name": "cooler",
      "enabled": true,
      "setPoint": {
        "kind": "SetPointSimple",
        "value": 4.4453
      },
      "inputSensor": {
        "kind": "TempSensor",
        "name": "fridge",
        "sensor": {
          "kind": "OneWireTempSensor",
          "value": 14.0625,
          "connected": false,
          "address": "28E16BA20600001E",
          "calibrationOffset": 0
        }
      },
      "inputError": 9.6367,
      "Kp": 10,
      "Ti": 1800,
      "Td": 200,
      "p": -96.3672,
      "i": 0,
      "d": -0.4688,
      "actuatorIsNegative": true,
      "outputActuator": {
        "kind": "ActuatorPwm",
        "value": 96.8359,
        "period": 1200,
        "minVal": 0,
        "maxVal": 100,
        "target": {
          "kind": "ActuatorMutexDriver",
          "mutexGroup": {
            "kind": "ActuatorMutexGroup",
            "deadTime": 1800000,
            "lastActiveTime": 4293167296
          },
          "target": {
            "kind": "ActuatorTimeLimited",
            "minOnTime": 120,
            "minOffTime": 180,
            "maxOnTime": 65535,
            "active": false,
            "target": {
              "kind": "ActuatorPin",
              "state": false,
              "pin": 17,
              "invert": false
            }
          }
        }
      }
    },
    {
      "kind": "Pid",
      "name": "beer2fridge",
      "enabled": false,
      "setPoint": {
        "kind": "SetPointSimple",
        "value": null
      },
      "inputSensor": {
        "kind": "TempSensor",
        "name": "beer1",
        "sensor": {
          "kind": "OneWireTempSensor",
          "value": 18.375,
          "connected": false,
          "address": "28EEDA30231500EC",
          "calibrationOffset": 0
        }
      },
      "inputError": 0,
      "Kp": 2,
      "Ti": 7200,
      "Td": 1200,
      "p": 0,
      "i": 0,
      "d": 0,
      "actuatorIsNegative": false,
      "outputActuator": {
        "kind": "ActuatorSetPoint",
        "targetSetPoint": {
          "kind": "SetPointSimple",
          "value": 4.4453
        },
        "targetSensor": {
          "kind": "TempSensor",
          "name": "fridge",
          "sensor": {
            "kind": "OneWireTempSensor",
            "value": 14.0625,
            "connected": false,
            "address": "28E16BA20600001E",
            "calibrationOffset": 0
          }
        },
        "referenceSetPoint": {
          "kind": "SetPointSimple",
          "value": null
        },
        "output": 127.9961,
        "achieved": 127.9961,
        "minimum": -10,
        "maximum": 10
      }
    }
  ],
  "sensors": [
    {
      "kind": "TempSensor",
      "name": "fridge",
      "sensor": {
        "kind": "OneWireTempSensor",
        "value": 14.0625,
        "connected": false,
        "address": "28E16BA20600001E",
        "calibrationOffset": 0
      }
    },
    {
      "kind": "TempSensor",
      "name": "beer1",
      "sensor": {
        "kind": "OneWireTempSensor",
        "value": 18.375,
        "connected": false,
        "address": "28EEDA30231500EC",
        "calibrationOffset": 0
      }
    },
    {
      "kind": "TempSensor",
      "name": "beer2",
      "sensor": {
        "kind": "OneWireTempSensor",
        "value": 12.3125,
        "connected": false,
        "address": "28ABD0A106000013",
        "calibrationOffset": 0
      }
    }
  ],
  "actuators": [
    {
      "kind": "ActuatorPwm",
      "value": 96.8359,
      "period": 1200,
      "minVal": 0,
      "maxVal": 100,
      "target": {
        "kind": "ActuatorMutexDriver",
        "mutexGroup": {
          "kind": "ActuatorMutexGroup",
          "deadTime": 1800000,
          "lastActiveTime": 4293167296
        },
        "target": {
          "kind": "ActuatorTimeLimited",
          "minOnTime": 120,
          "minOffTime": 180,
          "maxOnTime": 65535,
          "active": false,
          "target": {
            "kind": "ActuatorPin",
            "state": false,
            "pin": 17,
            "invert": false
          }
        }
      }
    },
    {
      "kind": "ActuatorPwm",
      "value": 0,
      "period": 4,
      "minVal": 0,
      "maxVal": 100,
      "target": {
        "kind": "ActuatorMutexDriver",
        "mutexGroup": {
          "kind": "ActuatorMutexGroup",
          "deadTime": 1800000,
          "lastActiveTime": 4293167296
        },
        "target": {
          "kind": "ActuatorPin",
          "state": false,
          "pin": 16,
          "invert": false
        }
      }
    },
    {
      "kind": "ActuatorPwm",
      "value": 0,
      "period": 4,
      "minVal": 0,
      "maxVal": 100,
      "target": {
        "kind": "ActuatorMutexDriver",
        "mutexGroup": {
          "kind": "ActuatorMutexGroup",
          "deadTime": 1800000,
          "lastActiveTime": 4293167296
        },
        "target": {
          "kind": "ActuatorNop",
          "state": false
        }
      }
    }
  ],
  "setpoints": [
    {
      "kind": "SetPointNamed",
      "name": "beer1set",
      "setPoint": {
        "kind": "SetPointSimple",
        "value": null
      }
    },
    {
      "kind": "SetPointNamed",
      "name": "beer2set",
      "setPoint": {
        "kind": "SetPointSimple",
        "value": null
      }
    },
    {
      "kind": "SetPointNamed",
      "name": "fridgeset",
      "setPoint": {
        "kind": "SetPointSimple",
        "value": 4.4453
      }
    }
  ]
}

#4

I don't get it. I'll send you a PM to arrange a chat. I need more info on this.
Are you running 0.4.4? (shown at the boot logo).


#5

Just checked, its running 0.4.2. It appears running the installer in the raspberry pi command does not pull the most current version of BrewPi. I will follow up. Thanks again.


#6

You need to run the update script. The installer does not update the firmware.

cd ~/brewpi-tools
sudo python updater.py

#7

Hi Elco,

So I updated to 0.4.4 and still have issues. The beer temperature never approaches to the desired set point. Below are the settings and screen shots of the temperature trends. Please advise on the proper tuning parameters. Thank you.

{
  "kind": "Control",
  "pids": [
    {
      "kind": "Pid",
      "name": "heater1",
      "enabled": true,
      "setPoint": {
        "kind": "SetPointSimple",
        "name": "fridgeset",
        "value": 4.4453
      },
      "inputSensor": {
        "kind": "TempSensorFallback",
        "onBackupSensor": false,
        "sensor": {
          "kind": "TempSensor",
          "name": "fridge",
          "sensor": {
            "kind": "OneWireTempSensor",
            "value": 6.75,
            "connected": true,
            "address": "28E16BA20600001E",
            "calibrationOffset": 0
          }
        }
      },
      "inputError": 2.3047,
      "Kp": 55.5508,
      "Ti": 6300,
      "Td": 0,
      "p": -128.0273,
      "i": 0,
      "d": 0,
      "actuatorIsNegative": false,
      "outputActuator": {
        "kind": "ActuatorPwm",
        "value": 0,
        "period": 360,
        "minVal": 0,
        "maxVal": 100,
        "target": {
          "kind": "ActuatorMutexDriver",
          "mutexGroup": {
            "kind": "ActuatorMutexGroup",
            "deadTime": 1800000,
            "waitTime": 0
          },
          "target": {
            "kind": "ActuatorPin",
            "state": false,
            "pin": 16,
            "invert": false
          }
        }
      }
    },
    {
      "kind": "Pid",
      "name": "heater2",
      "enabled": true,
      "setPoint": {
        "kind": "SetPointSimple",
        "name": "beer2set",
        "value": null
      },
      "inputSensor": {
        "kind": "TempSensor",
        "name": "beer2",
        "sensor": {
          "kind": "OneWireTempSensor",
          "value": 13.5625,
          "connected": true,
          "address": "28ABD0A106000013",
          "calibrationOffset": 0
        }
      },
      "inputError": null,
      "Kp": 10,
      "Ti": 600,
      "Td": 60,
      "p": 0,
      "i": 0,
      "d": 0,
      "actuatorIsNegative": false,
      "outputActuator": {
        "kind": "ActuatorPwm",
        "value": 0,
        "period": 4,
        "minVal": 0,
        "maxVal": 100,
        "target": {
          "kind": "ActuatorMutexDriver",
          "mutexGroup": {
            "kind": "ActuatorMutexGroup",
            "deadTime": 1800000,
            "waitTime": 0
          },
          "target": {
            "kind": "ActuatorNop",
            "state": false
          }
        }
      }
    },
    {
      "kind": "Pid",
      "name": "cooler",
      "enabled": true,
      "setPoint": {
        "kind": "SetPointSimple",
        "name": "fridgeset",
        "value": 4.4453
      },
      "inputSensor": {
        "kind": "TempSensorFallback",
        "onBackupSensor": false,
        "sensor": {
          "kind": "TempSensor",
          "name": "fridge",
          "sensor": {
            "kind": "OneWireTempSensor",
            "value": 6.75,
            "connected": true,
            "address": "28E16BA20600001E",
            "calibrationOffset": 0
          }
        }
      },
      "inputError": 2.3047,
      "Kp": 27.7813,
      "Ti": 6300,
      "Td": 0,
      "p": -64.0273,
      "i": 0,
      "d": 0,
      "actuatorIsNegative": true,
      "outputActuator": {
        "kind": "ActuatorPwm",
        "value": 64.0273,
        "period": 180,
        "minVal": 0,
        "maxVal": 100,
        "target": {
          "kind": "ActuatorMutexDriver",
          "mutexGroup": {
            "kind": "ActuatorMutexGroup",
            "deadTime": 1800000,
            "waitTime": 0
          },
          "target": {
            "kind": "ActuatorTimeLimited",
            "minOnTime": 1800,
            "minOffTime": 300,
            "maxOnTime": 65535,
            "state": false,
            "target": {
              "kind": "ActuatorPin",
              "state": false,
              "pin": 17,
              "invert": false
            }
          }
        }
      }
    },
    {
      "kind": "Pid",
      "name": "beer2fridge",
      "enabled": false,
      "setPoint": {
        "kind": "SetPointSimple",
        "name": "beer1set",
        "value": null
      },
      "inputSensor": {
        "kind": "TempSensor",
        "name": "beer1",
        "sensor": {
          "kind": "OneWireTempSensor",
          "value": 6.1875,
          "connected": true,
          "address": "28EEDA30231500EC",
          "calibrationOffset": 0
        }
      },
      "inputError": null,
      "Kp": 1.5508,
      "Ti": 3600,
      "Td": 0,
      "p": 0,
      "i": 0,
      "d": 0,
      "actuatorIsNegative": false,
      "outputActuator": {
        "kind": "ActuatorSetPoint",
        "targetSetPoint": {
          "kind": "SetPointSimple",
          "name": "fridgeset",
          "value": 4.4453
        },
        "targetSensor": {
          "kind": "TempSensor",
          "name": "fridge",
          "sensor": {
            "kind": "OneWireTempSensor",
            "value": 6.75,
            "connected": true,
            "address": "28E16BA20600001E",
            "calibrationOffset": 0
          }
        },
        "referenceSetPoint": {
          "kind": "SetPointSimple",
          "name": "beer1set",
          "value": null
        },
        "output": 127.9961,
        "achieved": 127.9961,
        "minimum": -0.0547,
        "maximum": 0.0547
      }
    }
  ]
}


#8

The PID that should manipulate the fridge setting does not have a valid setpoint. I don't know why yet. The fridge setpoint should be continuously adjusted.

It is very strange that the fridge setpoint in the top right corner does not match the chart.

Can you try resetting to factory defaults and adding your sensors and heater and cooler again? Are you sure you are running on 0.4.4? It is displayed at boot and in the script log.


#9

Confirmed that 0.4.4 was installed on the splashscreen and did the factory reset in the maintenance panel. Reinstalled probes and SSRs and this is what I get, can get it any better?


#10

The fridge setting is still not updating correctly. Can you try setting it to beer constant?


#11

Updated to beer constant at 72F.


#12

What is your beer-to-fridge Kp, Ti and Td? I don't think the settings are set correctly. Please add me on Skype still.


#13

Beer-to-fridge, Kp; 50, Ti: 7200, Td: 1200


#14

I think that was the problem, Kp should be about 5.
I'll look into why it results in such strange behavior though.