diff --git a/Profiles.h b/Profiles.h index 24f60530a4e2257807981a120fa456dffcec5ba2..8317e9efaa76b6c0b41ac1e755c1709684190089 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 29722820b956ac8199b3c77a70dfd5582a41d9da..e713e075e37f90fd9970efa6d2528810fd09bd0e 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 d0da86482b269f96d74b01e95e792356170994fc..1655232f0e2003f26bc63b07c37249b6fdfe2535 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 }