Beta releases now available

Iā€™m running the release Beta and everything was going well for 1 week. On April 10th I noticed by temps were not varying at all on the web server. When I checked on my fridge, my conical was drenched in condensation and the fridge temp was in the 30s F. I was able to log on to the web server without any issue, script was running, but it was still reporting fridge and beer temp in the 60s. The web server allowed me to open the maintenance panel and look through the settings, but it could not populate a device list. I had no internet issues or power outages during this time. Iā€™m trying to understand how the web server continued to work (frozen but working) and the Spark went into freezer modeā€¦ It worked out for me as a cold crash, but would have been scary if it happened any earlier. I reset the Pi and Spark and itā€™s been working fine every since, no issues with SSR either.

Hi Jesse,

Are you using DS2413 based actuators (the SSR expansion boards)?

Elco

No, Iā€™m using the Spark outputs.

Hi Jesse,

This is the first time I have heard of this happening. Do you have any more details?
Anything in the log files?
Anything that might help me figure out where in the code it seemed to have deadlocked?

Elco

This is what I got from the log files.

Found BrewPi v0.4.3b build 0.4.3b2-0-g3de44b0, running $

BrewPi: wifiChecker: Attempt 1 to reach 192.168.1.1 failed (Thu Apr 7 22:00:11$
Apr 08 2016 00:00:00 Notification: New day, creating new JSON file.
BrewPi: wifiChecker: Attempt 1 to reach 192.168.1.1 failed (Fri Apr 8 01:40:12$
BrewPi: wifiChecker: Attempt 1 to reach 192.168.1.1 failed (Fri Apr 8 19:30:11$
Apr 09 2016 00:00:00 Notification: New day, creating new JSON file.
BrewPi: wifiChecker: Attempt 1 to reach 192.168.1.1 failed (Sat Apr 9 02:30:12$
BrewPi: wifiChecker: Attempt 1 to reach 192.168.1.1 failed (Sat Apr 9 04:40:12$
BrewPi: wifiChecker: Attempt 1 to reach 192.168.1.1 failed (Sat Apr 9 19:00:11$
Apr 10 2016 00:00:00 Notification: New day, creating new JSON file.
Apr 10 2016 02:28:48 Serial Error: Write timeout)
Apr 10 2016 02:29:23 Serial Error: Write timeout)
Apr 10 2016 02:29:57 Serial Error: Write timeout)

This continues on every 2-3 minutes with Serial Errorā€¦
Apr 10 2016 23:17:07 Serial Error: Write timeout)
Apr 10 2016 23:17:22 Cannot process line from controller: Beer Const. ",$
Apr 10 2016 23:17:28 Serial Error: Write timeout)

Apr 10 2016 23:59:28 Serial Error: Write timeout)
Apr 11 2016 00:00:00 Notification: New day, creating new JSON file.
Apr 11 2016 00:00:02 Serial Error: Write timeout)

And restarted on the 12thApr 12 2016 14:29:08 Serial Error: Write timeout)
Apr 12 2016 14:31:24 Opening serial port
Apr 12 2016 14:31:24 Notification: Script started for beer 'IPA Fermentā€™
Apr 12 2016 14:31:34 Checking software version on controllerā€¦
Apr 12 2016 14:31:34 Found BrewPi v0.4.3b build 0.4.3b2-0-g3de44b0, running $

During this time BrewPi Wifi Checker attempted once and failed to connect, however I continued to have a web server presence on the 11th and 12th before I restarted the Pi on the 12th.

This still happens in the latest beta: Communication between browser and pi fails intermittently on Safari

But this is no problem since it can easily be fixed as described in the link.

Btw, runs just fine on the raspberry 3 and the script start-up time is impressive :wink:

Hi Elco,

I am running 4.3 and have noticed that although the beer temp is being maintained spot on, the way in which it is doing it seems a little untidy. I am noticing cycling between cooling and heating which was not there before. I have a Brewtech 1/2bbl fermenter in a fridge with 11gals of beer, heating is supplied by a 1200w hairdryer. The settings of the Brewpi are factory, are there any changes you would recommend to tidy the control?

Cheers,

Dave.

Please zoom in on a smaller portion of that, like 3 alternations.

Also give my your current settings (you can copy the control algorithm page). It is probably just a matter of reducing the heater Kp, so it heats more gently.

Thanks Elco,

 "kind": "Control",
  "pids": [
    {
      "kind": "Pid",
      "name": "heater1",
      "enabled": true,
      "setPoint": {
        "kind": "SetPointSimple",
        "name": "fridgeset",
        "value": 19.9766
      },
      "inputSensor": {
        "kind": "TempSensorFallback",
        "onBackupSensor": false,
        "sensor": {
          "kind": "TempSensor",
          "name": "fridge",
          "sensor": {
            "kind": "OneWireTempSensor",
            "value": 20,
            "connected": true,
            "address": "28FF510CA515018C",
            "calibrationOffset": 0
          }
        }
      },
      "inputError": 0.0234,
      "Kp": 10,
      "Ti": 600,
      "Td": 60,
      "p": -0.2344,
      "i": 0.1875,
      "d": -0.1563,
      "actuatorIsNegative": false,
      "outputActuator": {
        "kind": "ActuatorPwm",
        "value": 0,
        "period": 4,
        "minVal": 0,
        "maxVal": 100,
        "target": {
          "kind": "ActuatorMutexDriver",
          "mutexGroup": {
            "kind": "ActuatorMutexGroup",
            "deadTime": 1800000,
            "waitTime": 1721324
          },
          "target": {
            "kind": "ActuatorOneWire",
            "state": false,
            "pio": 0,
            "invert": false
          }
        }
      }
    },
    {
      "kind": "Pid",
      "name": "heater2",
      "enabled": true,
      "setPoint": {
        "kind": "SetPointSimple",
        "name": "beer2set",
        "value": null
      },
      "inputSensor": {
        "kind": "TempSensor",
        "name": "beer2",
        "sensor": {
          "kind": "OneWireTempSensor",
          "value": 23.3125,
          "connected": true,
          "address": "2869863607000027",
          "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": 1721253
          },
          "target": {
            "kind": "ActuatorNop",
            "state": false
          }
        }
      }
    },
    {
      "kind": "Pid",
      "name": "cooler",
      "enabled": true,
      "setPoint": {
        "kind": "SetPointSimple",
        "name": "fridgeset",
        "value": 19.9766
      },
      "inputSensor": {
        "kind": "TempSensorFallback",
        "onBackupSensor": false,
        "sensor": {
          "kind": "TempSensor",
          "name": "fridge",
          "sensor": {
            "kind": "OneWireTempSensor",
            "value": 20,
            "connected": true,
            "address": "28FF510CA515018C",
            "calibrationOffset": 0
          }
        }
      },
      "inputError": 0.0234,
      "Kp": 10,
      "Ti": 1800,
      "Td": 200,
      "p": -0.2344,
      "i": 0,
      "d": -0.625,
      "actuatorIsNegative": true,
      "outputActuator": {
        "kind": "ActuatorPwm",
        "value": 0.8594,
        "period": 1200,
        "minVal": 0,
        "maxVal": 100,
        "target": {
          "kind": "ActuatorMutexDriver",
          "mutexGroup": {
            "kind": "ActuatorMutexGroup",
            "deadTime": 1800000,
            "waitTime": 1721178
          },
          "target": {
            "kind": "ActuatorTimeLimited",
            "minOnTime": 120,
            "minOffTime": 180,
            "maxOnTime": 65535,
            "state": false,
            "target": {
              "kind": "ActuatorOneWire",
              "state": false,
              "pio": 1,
              "invert": false
            }
          }
        }
      }
    },
    {
      "kind": "Pid",
      "name": "beer2fridge",
      "enabled": true,
      "setPoint": {
        "kind": "SetPointSimple",
        "name": "beer1set",
        "value": 20
      },
      "inputSensor": {
        "kind": "TempSensor",
        "name": "beer1",
        "sensor": {
          "kind": "OneWireTempSensor",
          "value": 20,
          "connected": true,
          "address": "28FFF0F3A4150132",
          "calibrationOffset": 0
        }
      },
      "inputError": 0,
      "Kp": 2,
      "Ti": 7200,
      "Td": 1200,
      "p": 0,
      "i": 0,
      "d": -0.0234,
      "actuatorIsNegative": false,
      "outputActuator": {
        "kind": "ActuatorSetPoint",
        "targetSetPoint": {
          "kind": "SetPointSimple",
          "name": "fridgeset",
          "value": 19.9766
        },
        "targetSensor": {
          "kind": "TempSensor",
          "name": "fridge",
          "sensor": {
            "kind": "OneWireTempSensor",
            "value": 20,
            "connected": true,
            "address": "28FF510CA515018C",
            "calibrationOffset": 0
          }
        },
        "referenceSetPoint": {
          "kind": "SetPointSimple",
          "name": "beer1set",
          "value": 20
        },
        "output": -0.0234,
        "achieved": 0,
        "minimum": -10,
        "maximum": 10
      }
    }
  ]
}

After heating, your fridge temperature seems to overshoot a lot, like 10 minutes.
Combat that by setting heater1 Td to 5 or even 10 minutes (try 300s first).

Also maybe reduce the intensity of the heater, by reducing Kp from 10 to 2.

Finally, you can set the dead time to 2 hours: so if it wants to switch from heating to cooling, it will have to wait 2 hours.

Thanks Elco,

I have applied those settings.

Dave.

Hi Elco,

Sorry to be a thorn but I would appreciate some feedback if you canā€¦
I applied the settings as you suggested,

  "kind": "Control",
  "pids": [
    {
      "kind": "Pid",
      "name": "heater1",
      "enabled": true,
      "setPoint": {
        "kind": "SetPointSimple",
        "name": "fridgeset",
        "value": 20.582
      },
      "inputSensor": {
        "kind": "TempSensorFallback",
        "onBackupSensor": false,
        "sensor": {
          "kind": "TempSensor",
          "name": "fridge",
          "sensor": {
            "kind": "OneWireTempSensor",
            "value": 20.5625,
            "connected": true,
            "address": "28FF510CA515018C",
            "calibrationOffset": 0
          }
        }
      },
      "inputError": -0.0195,
      "Kp": 2,
      "Ti": 600,
      "Td": 600,
      "p": 0.0391,
      "i": -0.0195,
      "d": 1.2344,
      "actuatorIsNegative": false,
      "outputActuator": {
        "kind": "ActuatorPwm",
        "value": 1.2539,
        "period": 4,
        "minVal": 0,
        "maxVal": 100,
        "target": {
          "kind": "ActuatorMutexDriver",
          "mutexGroup": {
            "kind": "ActuatorMutexGroup",
            "deadTime": 3600000,
            "waitTime": 1816240
          },
          "target": {
            "kind": "ActuatorOneWire",
            "state": false,
            "pio": 0,
            "invert": false
          }
        }
      }
    },
    {
      "kind": "Pid",
      "name": "heater2",
      "enabled": true,
      "setPoint": {
        "kind": "SetPointSimple",
        "name": "beer2set",
        "value": null
      },
      "inputSensor": {
        "kind": "TempSensor",
        "name": "beer2",
        "sensor": {
          "kind": "OneWireTempSensor",
          "value": 20.125,
          "connected": true,
          "address": "2869863607000027",
          "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": 3600000,
            "waitTime": 1816169
          },
          "target": {
            "kind": "ActuatorNop",
            "state": false
          }
        }
      }
    },
    {
      "kind": "Pid",
      "name": "cooler",
      "enabled": true,
      "setPoint": {
        "kind": "SetPointSimple",
        "name": "fridgeset",
        "value": 20.582
      },
      "inputSensor": {
        "kind": "TempSensorFallback",
        "onBackupSensor": false,
        "sensor": {
          "kind": "TempSensor",
          "name": "fridge",
          "sensor": {
            "kind": "OneWireTempSensor",
            "value": 20.5625,
            "connected": true,
            "address": "28FF510CA515018C",
            "calibrationOffset": 0
          }
        }
      },
      "inputError": -0.0195,
      "Kp": 10,
      "Ti": 1800,
      "Td": 200,
      "p": 0.1953,
      "i": -4.875,
      "d": 2.0703,
      "actuatorIsNegative": true,
      "outputActuator": {
        "kind": "ActuatorPwm",
        "value": 2.6094,
        "period": 1200,
        "minVal": 0,
        "maxVal": 100,
        "target": {
          "kind": "ActuatorMutexDriver",
          "mutexGroup": {
            "kind": "ActuatorMutexGroup",
            "deadTime": 3600000,
            "waitTime": 1816093
          },
          "target": {
            "kind": "ActuatorTimeLimited",
            "minOnTime": 120,
            "minOffTime": 180,
            "maxOnTime": 65535,
            "state": false,
            "target": {
              "kind": "ActuatorOneWire",
              "state": false,
              "pio": 1,
              "invert": false
            }
          }
        }
      }
    },
    {
      "kind": "Pid",
      "name": "beer2fridge",
      "enabled": true,
      "setPoint": {
        "kind": "SetPointSimple",
        "name": "beer1set",
        "value": 21
      },
      "inputSensor": {
        "kind": "TempSensor",
        "name": "beer1",
        "sensor": {
          "kind": "OneWireTempSensor",
          "value": 20.9375,
          "connected": true,
          "address": "28FFF0F3A4150132",
          "calibrationOffset": 0
        }
      },
      "inputError": -0.1094,
      "Kp": 2,
      "Ti": 7200,
      "Td": 1200,
      "p": 0.2188,
      "i": -0.8945,
      "d": 0.2578,
      "actuatorIsNegative": false,
      "outputActuator": {
        "kind": "ActuatorSetPoint",
        "targetSetPoint": {
          "kind": "SetPointSimple",
          "name": "fridgeset",
          "value": 20.582
        },
        "targetSensor": {
          "kind": "TempSensor",
          "name": "fridge",
          "sensor": {
            "kind": "OneWireTempSensor",
            "value": 20.5625,
            "connected": true,
            "address": "28FF510CA515018C",
            "calibrationOffset": 0
          }
        },
        "referenceSetPoint": {
          "kind": "SetPointSimple",
          "name": "beer1set",
          "value": 21
        },
        "output": -0.418,
        "achieved": -0.4375,
        "minimum": -10,
        "maximum": 10
      }
    }

But there is a bit of an overshoot and undershoot when adjusting the ā€œbeerā€ temperature.
It also appears to want to still heat during the overshoot and vice versa.




I have attached the overall graph to date with three enlarged periods.

Cheers
Dave.

Hi Dave,

Now your fridge temperature follows the setpoint very nicely. Great.
Now to adjust the beer-to-fridge PID:

The beer responds very slow to the fridge temp, so this should be reflected by long time constants.
But letā€™s start with Kp, which is 2. This means that when the beer temp is 1 degree to high, the fridge setpoin will be 2 degrees below the beer setpoint. Judging from your graphs, that should be fine. You could make it a bit more aggressive by setting it to 8. That way it create a much larger difference between fridge and beer temp.

Your overshoot comes from integrator windup. The integrator time constant is 7200. This means that if the beer is not reaching the setpoint, the integral can increase with the proportional part every 7200 seconds.That is too fast for you. Your beer takes about 5-6 hours to respond to the change in fridge temp. So please increase Ti to 30000 at least.

Now finally, to take into account that if your beer temp is already dropping, take into account about 2 hours into the future that it will stay dropping when you stop cooling: Set Td to 7200.

You probably also want to increase the filtering on your beer temperature, so the setpoint is smoother.
You can set the filter safely delays to 318 seconds, because the beer is temp slow anyway.

Thanks again Elco for the prompt feedback.

I have applied the suggestions.
I have just one concern, the fridge is also used to house a 5gal fermenter, which will obviously have very different thermal characteristics to the 1/2bb/ with 10gals of beer. Will the modified settings be a problem for the smaller volume? There is no way of switching between default settingsā€¦yet?:wink:

Thanks
Dave.

I think the settings will work okay for your smaller volume as well, but youā€™ll just have to try.

My home automation system is surveilencing my BrewPi, basically data is imported by a lua script and the home-automation-base then checks for temperatures and sends me messages if anything is wrong. I recently got a message it was unable to compare date since the compared value is ā€œā€“.-ā€ and not a number. Due to this the system automatically power-cycled the BrewPi.

When I came home I saw this on BrewPi:


So basically BrewPi has no been logging data during a few days. The actual regulation was running, I am sure since I took some beers out every single of these days and they were cold. Sometime during the last 24 hours of not logging any data the cooling stopped and the beer started warming up. It looked like BrewPi had lost the connection to the beer sensor since this was showing ā€œā€“.-ā€. After power-cycling everything seems to be up and running again.

What information is usefull for you the help figure out this behaviour? The logs might be gone, but if it happens again I would like to know what you need.

The stderr log is not overwritten, so that would be helpful.

Can you check the voltage going to the BrewPi Spark? If you are powering it over USB, depending on the quality of the USB cable and Rpi power supply, it might not be getting enough voltage.

Best measurement would be on the 5V pin of the RJ12 connector, or if you have the enclosure open, just the VIN pin on the photon.

OK, I will post the log as soon as I get home, I do not have remote access.

The powersupply ist 2.5A which should be sufficient on a raspberry 2. Could be that the powersupply went bad, I have seen quite a few which are not capable of supplying the specified amperage even when new. The setup has been running for quite some time now, but I will check the voltage too and let you know.

I would only use the official raspberry pi power supplies. Phone chargers are usually not sufficient.

I am getting 4.75 volts on the RJ12 connector of the spark. I guess this could be an issue. I have another BrewPi setup with a raspberry 3 and the official powersupply, I am getting 4.81 volts with this setup.

How do you recognize a ā€œgoodā€ USB cable? Any brand recomendations? I just went for the expensive ones, as short as possible.

According to the log the problem is the connection to the spark if I understood this correctly. The following message is loggeg every 30 second since may 3:
May 03 2016 09:28:04 Serial Error: Write timeout)

In my opinion this explains why no data was logged. But it does not explain why the sensor was lost and the regulation stopped. But I guess there are no logs on the photon itself to figure that out?