From 99234fd036cb36ffe5c6e3b71048d1aa63c371c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lino?= Date: Mon, 4 Jun 2018 10:09:09 +0100 Subject: [PATCH] Updated temperature control to stay bellow the over temperature range. Updated "Trigo" profile to account for wort thermal capacity, longer sparge times and wirlpool time. Setup the "Belga" profile for the next brew. --- Profiles.h | 59 +++++++++++++++++++++++++++--------------------------- brew.h | 3 +++ brew.ino | 59 +++++++++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 82 insertions(+), 39 deletions(-) diff --git a/Profiles.h b/Profiles.h index 24f6053..8317e9e 100644 --- a/Profiles.h +++ b/Profiles.h @@ -28,30 +28,31 @@ // TRIGO -#define PROFILE_TRIGO_STARTPOINT_TIME PROFILE_BASIC_STARTPOINT_TIME -#define PROFILE_TRIGO_BETAGLUCANASE_TIME PROFILE_BASIC_BETAGLUCANASE_TIME -#define PROFILE_TRIGO_DEBRANCHING_TIME PROFILE_BASIC_DEBRANCHING_TIME -#define PROFILE_TRIGO_PROTEOLYTIC_TIME PROFILE_BASIC_PROTEOLYTIC_TIME -#define PROFILE_TRIGO_BETAAMYLASE_TIME PROFILE_BASIC_BETAAMYLASE_TIME -#define PROFILE_TRIGO_ALPHAAMYLASE_TIME PROFILE_BASIC_ALPHAAMYLASE_TIME -#define PROFILE_TRIGO_MASHOUT_TIME PROFILE_BASIC_MASHOUT_TIME -#define PROFILE_TRIGO_RECIRCULATION_TIME PROFILE_BASIC_RECIRCULATION_TIME -#define PROFILE_TRIGO_SPARGE_TIME PROFILE_BASIC_SPARGE_TIME -#define PROFILE_TRIGO_BOIL_TIME PROFILE_BASIC_BOIL_TIME -#define PROFILE_TRIGO_COOLING_TIME PROFILE_BASIC_COOLING_TIME #define PROFILE_TRIGO_STARTPOINT_TEMPERATURE 65 #define PROFILE_TRIGO_BETAGLUCANASE_TEMPERATURE PROFILE_BASIC_BETAGLUCANASE_TEMPERATURE #define PROFILE_TRIGO_DEBRANCHING_TEMPERATURE PROFILE_BASIC_DEBRANCHING_TEMPERATURE #define PROFILE_TRIGO_PROTEOLYTIC_TEMPERATURE PROFILE_BASIC_PROTEOLYTIC_TEMPERATURE #define PROFILE_TRIGO_BETAAMYLASE_TEMPERATURE 62 -#define PROFILE_TRIGO_ALPHAAMYLASE_TEMPERATURE PROFILE_BASIC_ALPHAAMYLASE_TEMPERATURE +#define PROFILE_TRIGO_ALPHAAMYLASE_TEMPERATURE 70 #define PROFILE_TRIGO_MASHOUT_TEMPERATURE 78 -#define PROFILE_TRIGO_RECIRCULATION_TEMPERATURE PROFILE_BASIC_RECIRCULATION_TEMPERATURE +#define PROFILE_TRIGO_RECIRCULATION_TEMPERATURE 78 #define PROFILE_TRIGO_SPARGE_TEMPERATURE PROFILE_BASIC_SPARGE_TEMPERATURE #define PROFILE_TRIGO_BOIL_TEMPERATURE PROFILE_BASIC_BOIL_TEMPERATURE #define PROFILE_TRIGO_COOLING_TEMPERATURE PROFILE_BASIC_COOLING_TEMPERATURE +#define PROFILE_TRIGO_STARTPOINT_TIME 120 +#define PROFILE_TRIGO_BETAGLUCANASE_TIME 0 +#define PROFILE_TRIGO_DEBRANCHING_TIME 0 +#define PROFILE_TRIGO_PROTEOLYTIC_TIME 0 +#define PROFILE_TRIGO_BETAAMYLASE_TIME 2832 // 3600 - 768 : 768 is the time to get from 62C to 70C +#define PROFILE_TRIGO_ALPHAAMYLASE_TIME 1032 // 1800 - 768 : 768 is the time to get from 70C to 78C +#define PROFILE_TRIGO_MASHOUT_TIME PROFILE_BASIC_MASHOUT_TIME +#define PROFILE_TRIGO_RECIRCULATION_TIME 0 +#define PROFILE_TRIGO_SPARGE_TIME 3600 +#define PROFILE_TRIGO_BOIL_TIME 5400 +#define PROFILE_TRIGO_COOLING_TIME 1800 + //#define PROFILE_TRIGO_WHEAT_MULTIPLIER 0.05 //#define PROFILE_TRIGO_PILSNER_MULTIPLIER 0.2 //#define PROFILE_TRIGO_MAGNUM_MULTIPLIER 0.05 @@ -71,7 +72,7 @@ #define PROFILE_IPA_BETAAMYLASE_TIME PROFILE_BASIC_BETAAMYLASE_TIME #define PROFILE_IPA_ALPHAAMYLASE_TIME PROFILE_BASIC_ALPHAAMYLASE_TIME #define PROFILE_IPA_MASHOUT_TIME PROFILE_BASIC_MASHOUT_TIME -#define PROFILE_IPA_RECIRCULATION_TIME PROFILE_BASIC_RECIRCULATION_TIME +#define PROFILE_IPA_RECIRCULATION_TIME 0 #define PROFILE_IPA_SPARGE_TIME PROFILE_BASIC_SPARGE_TIME #define PROFILE_IPA_BOIL_TIME 3900 #define PROFILE_IPA_COOLING_TIME PROFILE_BASIC_COOLING_TIME @@ -95,26 +96,26 @@ // BELGA -#define PROFILE_BELGA_STARTPOINT_TIME PROFILE_BASIC_STARTPOINT_TIME -#define PROFILE_BELGA_BETAGLUCANASE_TIME PROFILE_BASIC_BETAGLUCANASE_TIME -#define PROFILE_BELGA_DEBRANCHING_TIME PROFILE_BASIC_DEBRANCHING_TIME -#define PROFILE_BELGA_PROTEOLYTIC_TIME PROFILE_BASIC_PROTEOLYTIC_TIME -#define PROFILE_BELGA_BETAAMYLASE_TIME PROFILE_BASIC_BETAAMYLASE_TIME -#define PROFILE_BELGA_ALPHAAMYLASE_TIME PROFILE_BASIC_ALPHAAMYLASE_TIME +#define PROFILE_BELGA_STARTPOINT_TIME 120 +#define PROFILE_BELGA_BETAGLUCANASE_TIME 0 +#define PROFILE_BELGA_DEBRANCHING_TIME 0 +#define PROFILE_BELGA_PROTEOLYTIC_TIME 0 +#define PROFILE_BELGA_BETAAMYLASE_TIME 2832 // 3600 - 768 : 768 is the time to get from 62C to 70C +#define PROFILE_BELGA_ALPHAAMYLASE_TIME 1032 // 1800 - 768 : 768 is the time to get from 70C to 78C #define PROFILE_BELGA_MASHOUT_TIME PROFILE_BASIC_MASHOUT_TIME -#define PROFILE_BELGA_RECIRCULATION_TIME PROFILE_BASIC_RECIRCULATION_TIME -#define PROFILE_BELGA_SPARGE_TIME PROFILE_BASIC_SPARGE_TIME -#define PROFILE_BELGA_BOIL_TIME PROFILE_BASIC_BOIL_TIME -#define PROFILE_BELGA_COOLING_TIME PROFILE_BASIC_COOLING_TIME +#define PROFILE_BELGA_RECIRCULATION_TIME 0 +#define PROFILE_BELGA_SPARGE_TIME 3600 +#define PROFILE_BELGA_BOIL_TIME 5400 +#define PROFILE_BELGA_COOLING_TIME 1800 -#define PROFILE_BELGA_STARTPOINT_TEMPERATURE PROFILE_TRIGO_STARTPOINT_TEMPERATURE +#define PROFILE_BELGA_STARTPOINT_TEMPERATURE 65 #define PROFILE_BELGA_BETAGLUCANASE_TEMPERATURE PROFILE_BASIC_BETAGLUCANASE_TEMPERATURE #define PROFILE_BELGA_DEBRANCHING_TEMPERATURE PROFILE_BASIC_DEBRANCHING_TEMPERATURE #define PROFILE_BELGA_PROTEOLYTIC_TEMPERATURE PROFILE_BASIC_PROTEOLYTIC_TEMPERATURE -#define PROFILE_BELGA_BETAAMYLASE_TEMPERATURE PROFILE_TRIGO_BETAAMYLASE_TEMPERATURE -#define PROFILE_BELGA_ALPHAAMYLASE_TEMPERATURE PROFILE_BASIC_ALPHAAMYLASE_TEMPERATURE -#define PROFILE_BELGA_MASHOUT_TEMPERATURE PROFILE_TRIGO_MASHOUT_TEMPERATURE -#define PROFILE_BELGA_RECIRCULATION_TEMPERATURE PROFILE_BASIC_RECIRCULATION_TEMPERATURE +#define PROFILE_BELGA_BETAAMYLASE_TEMPERATURE 62 +#define PROFILE_BELGA_ALPHAAMYLASE_TEMPERATURE 70 +#define PROFILE_BELGA_MASHOUT_TEMPERATURE 78 +#define PROFILE_BELGA_RECIRCULATION_TEMPERATURE 78 #define PROFILE_BELGA_SPARGE_TEMPERATURE PROFILE_BASIC_SPARGE_TEMPERATURE #define PROFILE_BELGA_BOIL_TEMPERATURE PROFILE_BASIC_BOIL_TEMPERATURE #define PROFILE_BELGA_COOLING_TEMPERATURE PROFILE_BASIC_COOLING_TEMPERATURE diff --git a/brew.h b/brew.h index 2972282..e713e07 100644 --- a/brew.h +++ b/brew.h @@ -13,6 +13,9 @@ // ++++++++++++++++++++++++ Defines +++++++++++++++++++++++++++++++++ #define NELEMS(x) (sizeof(x) / sizeof((x)[0])) +// ++++++++++++++++++++++++ Cooking Variables ++++++++++++++++++++++++ +#define COOKING_MAX_OVER_TEMPERATURE_RANGE_ALLOWED 5.0 + // ++++++++++++++++++++++++ OTHER +++++++++++++++++++++++++++++++++ #include "CustomDataStructures.h" #include "debug.h" diff --git a/brew.ino b/brew.ino index d0da864..1655232 100644 --- a/brew.ino +++ b/brew.ino @@ -123,7 +123,8 @@ Temperature downPT100("down", PT100_DOWN_OUTPUT_PIN, PT100_DOWN_INPUT_PIN, PT100_DOWN_TIME_BETWEEN_READINGS, - 2.0309, 2.0288, 658.15, 655.35); + //2.0309, 2.0288, 658.15, 655.35); + 2.0309, 2.0288, 656.15, 655.35); // ######################### INTERRUPTS ######################### void isr () { // Interrupt service routine is executed when a HIGH to LOW transition is detected on CLK @@ -421,7 +422,7 @@ void xCountTheTime( float temperatureMarginRange, boolean bMaximumOfUpDown ) { temperatureCount = basePT100.getCurrentTemperature(); } - // Ignote time ticks if temperature is not within the acceptable margin for this stage + // Ignore time ticks if temperature is not within the acceptable margin for this stage unsigned long lastWindowTime = now - clockLastUpdate; if ( temperatureCount < (cookTemperature - temperatureMarginRange) ) { clockIgnore += lastWindowTime; @@ -465,15 +466,51 @@ double ulWattToWindowTime( double ulAppliedWatts ) { */ bool xRegulateTemperature( boolean bMaximumOfUpDown ) { - double difference = 0; + double difference = 0.0; + double temperatureTarget = cookTemperature; bool overTemperature = false; - //double dWattage = 0.0; + // Get the most recent temperature measurement float tup = upPT100.getCurrentTemperature(); float tdown = downPT100.getCurrentTemperature(); float tbase = basePT100.getCurrentTemperature(); + + if ( bMaximumOfUpDown ) { + + // Calculate max-up-dowd difference + double upDownDifference = 0.0; + if (tup > tdown) { + upDownDifference = cookTemperature - tup; + } + else { + upDownDifference = cookTemperature - tdown; + } + + // If the deviation from the target temperature is greater than the over-temperature range, the target temperature is set to the cooking temperature + the max over-temperature range + if ( upDownDifference > COOKING_MAX_OVER_TEMPERATURE_RANGE_ALLOWED ) { + temperatureTarget = cookTemperature + COOKING_MAX_OVER_TEMPERATURE_RANGE_ALLOWED; + } + // If the deviation from the target temperature is smaller than the over-temperature range, but not null, the target temperature is set to the cooking temperature + the difference + else if ( upDownDifference > 0.0 ) { + temperatureTarget = cookTemperature + upDownDifference; + } + // If the deviation from the target temperature indicates over-temperature, the target temperature is set to the cooking temperature + else { + temperatureTarget = cookTemperature; + } + + } + // For base thermometer control, the cook temperature is always + else { + temperatureTarget = cookTemperature; + } + + // Calculate the deviation between the most recent temperature measurement and the target temperature + difference = temperatureTarget - tbase; + + /*if ( bMaximumOfUpDown ) { if (tup > tdown) { difference = cookTemperature - tup; } @@ -481,18 +518,20 @@ bool xRegulateTemperature( boolean bMaximumOfUpDown ) { difference = cookTemperature - tdown; } - if (tbase > cookTemperature && (tbase >= (PUMP_TEMPERATURE_MAX_OPERATION - 2.0) || difference >= 5.0)) { + // Override bMaximumOfUpDown to false when the base temperature goes beyond the target temparature and either the pump is off or the grain is still very cold + if (tbase > cookTemperature && (tbase >= (PUMP_TEMPERATURE_MAX_OPERATION - 2.0) || difference >= COOKING_MAX_OVER_TEMPERATURE_ALLOWED)) { difference = cookTemperature - tbase; } + // Override bMaximumOfUpDown to false when the base temperature is bellow the target temparature, if ( (tbase < cookTemperature) && (difference < (cookTemperature - tbase)) ) { difference = cookTemperature - tbase; } } else { difference = cookTemperature - tbase; - } + }*/ - // Deviation between the cook temperature set and the cook temperature measured + // Check for over temperature if ( difference < 0.0 ) { difference = difference * (-1.0); overTemperature = true; @@ -505,12 +544,12 @@ bool xRegulateTemperature( boolean bMaximumOfUpDown ) { } else { if ( difference <= 0.5 ) { - if ( cookTemperature > 99.0 ) { + if ( temperatureTarget > 99.0 ) { //dWattage = 2000.0; // pulse hardly at 2000 watt heatingElement.setWattage(heatingElement.getTwoThirdWattage()); // pulse hardly at 2000 watt } else { - if ( cookTemperature > 70.0 ) { + if ( temperatureTarget > 70.0 ) { //dWattage = 1000.0; // pulse moderately at 1000 watt heatingElement.setWattage(heatingElement.getOneThirdWattage()); // pulse moderately at 1000 watt } @@ -522,7 +561,7 @@ bool xRegulateTemperature( boolean bMaximumOfUpDown ) { } else { if ( difference <= 1.0 ) { - if ( cookTemperature > 99.0 ) { + if ( temperatureTarget > 99.0 ) { //dWattage = 2000.0; // pulse hardly at 2000 watt heatingElement.setWattage(heatingElement.getTwoThirdWattage()); // pulse hardly at 2000 watt } -- 2.24.1