Commit 3e5d29c2 authored by João Lino's avatar João Lino

added pump speed control into the stages.

parent 137dd9b6
...@@ -42,6 +42,14 @@ ...@@ -42,6 +42,14 @@
//#define MIXER_PIN 12 //#define MIXER_PIN 12
//#define MIXER_MAX_POSITION 255 //#define MIXER_MAX_POSITION 255
// ++++++++++++++++++++++++ Pump ++++++++++++++++++++++++
#define PUMP_PIN 6
#define PUMP_SPEED_STOP 0
#define PUMP_SPEED_SLOW 64
#define PUMP_SPEED_AVERAGE 128
#define PUMP_SPEED_FAST 192
#define PUMP_SPEED_MAX 255
// ++++++++++++++++++++++++ Rotary Encoder ++++++++++++++++++++++++ // ++++++++++++++++++++++++ Rotary Encoder ++++++++++++++++++++++++
#define ROTARY_ENCODER_INTERRUPT_NUMBER 1 // On Mega2560 boards, interrupt 1 is on pin 3 #define ROTARY_ENCODER_INTERRUPT_NUMBER 1 // On Mega2560 boards, interrupt 1 is on pin 3
#define ROTARY_ENCODER_CLK_PIN 3 // Used for generating interrupts using CLK signal #define ROTARY_ENCODER_CLK_PIN 3 // Used for generating interrupts using CLK signal
...@@ -170,6 +178,9 @@ int iWindowSize; // Time frame to operate in ...@@ -170,6 +178,9 @@ int iWindowSize; // Time frame to operate in
unsigned long windowStartTime; unsigned long windowStartTime;
double dWattPerPulse; double dWattPerPulse;
// ++++++++++++++++++++++++ Pump ++++++++++++++++++++++++
int iPumpSpeed; // Time frame to operate in
// ######################### INITIALIZE ######################### // ######################### INITIALIZE #########################
// ++++++++++++++++++++++++ Library - LiquidCrystal_I2C ++++++++++++++++++++++++ // ++++++++++++++++++++++++ Library - LiquidCrystal_I2C ++++++++++++++++++++++++
LiquidCrystal_I2C lcd(LCD_I2C_ADDR, LCD_EN_PIN, LCD_RW_PIN, LCD_RS_PIN, LCD_D4_PIN, LCD_D5_PIN, LCD_D6_PIN, LCD_D7_PIN); LiquidCrystal_I2C lcd(LCD_I2C_ADDR, LCD_EN_PIN, LCD_RW_PIN, LCD_RS_PIN, LCD_D4_PIN, LCD_D5_PIN, LCD_D6_PIN, LCD_D7_PIN);
...@@ -279,6 +290,7 @@ void isr () { // Interrupt service routine is executed when a HIGH to LOW tr ...@@ -279,6 +290,7 @@ void isr () { // Interrupt service routine is executed when a HIGH to LOW tr
// ######################### START ######################### // ######################### START #########################
void xSafeHardwarePowerOff() { void xSafeHardwarePowerOff() {
// analogWrite(MIXER_PIN, 0); // Turn mixer OFF for safety // analogWrite(MIXER_PIN, 0); // Turn mixer OFF for safety
analogWrite(PUMP_PIN, PUMP_SPEED_STOP); // analogWrite values from 0 to 255
digitalWrite(HEATING_ELEMENT_OUTPUT_PIN, LOW); // Turn heading element OFF for safety digitalWrite(HEATING_ELEMENT_OUTPUT_PIN, LOW); // Turn heading element OFF for safety
//basePT100.xSafeHardwarePowerOff(); // Turn temperature sensor OFF for safety //basePT100.xSafeHardwarePowerOff(); // Turn temperature sensor OFF for safety
} }
...@@ -305,6 +317,11 @@ void setup() { ...@@ -305,6 +317,11 @@ void setup() {
// pinMode (MIXER_PIN, OUTPUT); // pinMode (MIXER_PIN, OUTPUT);
// analogWrite (MIXER_PIN, 0); // analogWrite (MIXER_PIN, 0);
// ++++++++++++++++++++++++ Pump ++++++++++++++++++++++++
pinMode(PUMP_PIN, OUTPUT); // sets the pin as output
iPumpSpeed = PUMP_SPEED_STOP; // Time frame to operate in
analogWrite(PUMP_PIN, iPumpSpeed); // analogWrite values from 0 to 255
// ++++++++++++++++++++++++ Temperature Sensor PT100 ++++++++++++++++++++++++ // ++++++++++++++++++++++++ Temperature Sensor PT100 ++++++++++++++++++++++++
//basePT100.setup(); //basePT100.setup();
/* /*
...@@ -888,9 +905,9 @@ void MainMenu_Cooling() { ...@@ -888,9 +905,9 @@ void MainMenu_Cooling() {
} }
void MainMenu_Settings() { void MainMenu_Settings() {
iPumpSpeed = xSetGenericValue( iPumpSpeed, 0, 255, "Pump Speed", "PWM" );
backToStatus(); backToStatus();
} }
void MainMenu_Back() { void MainMenu_Back() {
...@@ -982,11 +999,15 @@ bool xRegulateTemperature() { ...@@ -982,11 +999,15 @@ bool xRegulateTemperature() {
} }
} }
bool xRegulatePumpSpeed() {
analogWrite(PUMP_PIN, iPumpSpeed); // analogWrite values from 0 to 255
}
void xWarnClockEnded() { void xWarnClockEnded() {
/// TODO /// TODO
} }
void xStageFirstRun( int stageTime, int stageTemperature ) { void xStageFirstRun( int stageTime, int stageTemperature, int stagePumpSpeed ) {
// Set the clock // Set the clock
cookTime = stageTime; cookTime = stageTime;
...@@ -996,6 +1017,9 @@ void xStageFirstRun( int stageTime, int stageTemperature ) { ...@@ -996,6 +1017,9 @@ void xStageFirstRun( int stageTime, int stageTemperature ) {
// Reset the clock // Reset the clock
clockStartTime = millis(); clockStartTime = millis();
clockIgnore = 0; clockIgnore = 0;
// Set the pump speed
iPumpSpeed = stagePumpSpeed;
} }
void xTransitionIntoStage_GlobalVariables(eCookingStages nextStage) { void xTransitionIntoStage_GlobalVariables(eCookingStages nextStage) {
...@@ -1030,7 +1054,7 @@ void xBasicStageOperation( int iStageTime, int iStageTemperature, int iStageTemp ...@@ -1030,7 +1054,7 @@ void xBasicStageOperation( int iStageTime, int iStageTemperature, int iStageTemp
return; return;
} else { } else {
// Set the clock, target temperature and Reset the clock // Set the clock, target temperature and Reset the clock
xStageFirstRun( iStageTime, iStageTemperature ); xStageFirstRun( iStageTime, iStageTemperature, PUMP_SPEED_SLOW );
} }
} else { } else {
// Account for time spent at the target temperature | Input 1: range in ºC within which the target temperature is considered to be reached // Account for time spent at the target temperature | Input 1: range in ºC within which the target temperature is considered to be reached
...@@ -1039,6 +1063,9 @@ void xBasicStageOperation( int iStageTime, int iStageTemperature, int iStageTemp ...@@ -1039,6 +1063,9 @@ void xBasicStageOperation( int iStageTime, int iStageTemperature, int iStageTemp
if( isTimeLeft() ) { if( isTimeLeft() ) {
// Do temperature control // Do temperature control
xRegulateTemperature(); xRegulateTemperature();
// Do flow control
xRegulatePumpSpeed();
} else { } else {
// Continue to the next stage // Continue to the next stage
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment