Algorithm doesn't turn on heating or cooling? (help understanding when algorithm should heat/cool)

Setup

  • fermentation chamber with 2 heatpads (1 on side of chamber, 1 underneath ‘beer’)
  • large mug filled with water with ‘beer’ temperature sensor inside (tried previously with 23 L water in a fermentation bucket, but was too slow to react)
  • cooling is a coolbox/ice box with a 12V fan to circulate cold air (reaches around 3 oC less than room temperature)
  • setup temperature sensors in room & fermentation chamber (at back not directly under heater or cooler)

Steps taken

  • install brewpi-tools on pi
  • go to brewpi web UI
  • reset photon to defaults
  • add 3 temp sensors, 2 SSRs (image below)
  • in test mode confirm that SSRs turn on heating and cooling
  • start new brew
  • set beer constant with 0.4 oC difference (17.5 oC) from the starting beer temperature (17.1 oC)
  • current fridge temperature is 18.6 oC
  • change in advanced settings:
    • Dead time when switching between actuators: 30
    • Cooler minimum OFF time: 0
  • leave for an hour

(Naive?) expected behaviour

When the fridge temperature doesn’t match the fridge setting one of the PWM actuators (heating or cooling) turns on the heatpad or the cooling fan.

Observed behaviour

The beer temperature lowers, the fridge setting oscillates well above the beer setting, the fridge temperature and the beer temperature. The system remains in idle.

Graphs, installed devices & control algorithm

 {
  "kind": "Control",
  "pids": [
    {
      "kind": "Pid",
      "name": "heater1",
      "enabled": true,
      "setPoint": {
        "kind": "SetPointSimple",
        "name": "fridgeset",
        "value": 19.6563
      },
      "inputSensor": {
        "kind": "TempSensorFallback",
        "onBackupSensor": false,
        "sensor": {
          "kind": "TempSensor",
          "name": "fridge",
          "sensor": {
            "kind": "OneWireTempSensor",
            "value": 17.375,
            "connected": true,
            "address": "28E0B4C1070000AB",
            "calibrationOffset": 0
          }
        }
      },
      "inputError": -2.2539,
      "Kp": 10,
      "Ti": 600,
      "Td": 60,
      "p": 22.5391,
      "i": 0,
      "d": 0.4688,
      "actuatorIsNegative": false,
      "outputActuator": {
        "kind": "ActuatorPwm",
        "value": 23.0078,
        "period": 4,
        "minVal": 0,
        "maxVal": 100,
        "target": {
          "kind": "ActuatorMutexDriver",
          "mutexGroup": {
            "kind": "ActuatorMutexGroup",
            "deadTime": 30000,
            "waitTime": 0
          },
          "target": {
            "kind": "ActuatorPin",
            "state": false,
            "pin": 17,
            "invert": false
          }
        }
      }
    },
    {
      "kind": "Pid",
      "name": "heater2",
      "enabled": true,
      "setPoint": {
        "kind": "SetPointSimple",
        "name": "beer2set",
        "value": null
      },
      "inputSensor": {
        "kind": "TempSensor",
        "name": "beer2",
        "sensor": {
          "kind": "OneWireTempSensor",
          "value": 17.75,
          "connected": true,
          "address": "283C22C2070000B1",
          "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": 30000,
            "waitTime": 0
          },
          "target": {
            "kind": "ActuatorNop",
            "state": false
          }
        }
      }
    },
    {
      "kind": "Pid",
      "name": "cooler",
      "enabled": true,
      "setPoint": {
        "kind": "SetPointSimple",
        "name": "fridgeset",
        "value": 19.6563
      },
      "inputSensor": {
        "kind": "TempSensorFallback",
        "onBackupSensor": false,
        "sensor": {
          "kind": "TempSensor",
          "name": "fridge",
          "sensor": {
            "kind": "OneWireTempSensor",
            "value": 17.375,
            "connected": true,
            "address": "28E0B4C1070000AB",
            "calibrationOffset": 0
          }
        }
      },
      "inputError": -2.2539,
      "Kp": 10,
      "Ti": 1800,
      "Td": 200,
      "p": 22.5391,
      "i": 0,
      "d": 1.4844,
      "actuatorIsNegative": true,
      "outputActuator": {
        "kind": "ActuatorPwm",
        "value": 0,
        "period": 1200,
        "minVal": 0,
        "maxVal": 100,
        "target": {
          "kind": "ActuatorMutexDriver",
          "mutexGroup": {
            "kind": "ActuatorMutexGroup",
            "deadTime": 30000,
            "waitTime": 0
          },
          "target": {
            "kind": "ActuatorTimeLimited",
            "minOnTime": 120,
            "minOffTime": 0,
            "maxOnTime": 65535,
            "state": false,
            "target": {
              "kind": "ActuatorNop",
              "state": false
            }
          }
        }
      }
    },
    {
      "kind": "Pid",
      "name": "beer2fridge",
      "enabled": true,
      "setPoint": {
        "kind": "SetPointSimple",
        "name": "beer1set",
        "value": 17.5
      },
      "inputSensor": {
        "kind": "TempSensor",
        "name": "beer1",
        "sensor": {
          "kind": "OneWireTempSensor",
          "value": 16.875,
          "connected": true,
          "address": "283658C107000026",
          "calibrationOffset": 0
        }
      },
      "inputError": -0.625,
      "Kp": 2,
      "Ti": 7200,
      "Td": 1200,
      "p": 1.25,
      "i": 0.2266,
      "d": 0.6797,
      "actuatorIsNegative": false,
      "outputActuator": {
        "kind": "ActuatorSetPoint",
        "targetSetPoint": {
          "kind": "SetPointSimple",
          "name": "fridgeset",
          "value": 19.6563
        },
        "targetSensor": {
          "kind": "TempSensor",
          "name": "fridge",
          "sensor": {
            "kind": "OneWireTempSensor",
            "value": 17.375,
            "connected": true,
            "address": "28E0B4C1070000AB",
            "calibrationOffset": 0
          }
        },
        "referenceSetPoint": {
          "kind": "SetPointSimple",
          "name": "beer1set",
          "value": 17.5
        },
        "output": 2.1563,
        "achieved": -0.125,
        "minimum": -10,
        "maximum": 10
      }
    }
  ]
}

Thanks for the great problem description.

The value for the PWM heater is 27.9, so I would expect the output pin to go high.
If it stays low, I think you might have found a bug.

Did the heater still not start?
Does power cycling the system help?

1 Like