From e4102909c15e84d004c8108a4de8a59497dc64f8 Mon Sep 17 00:00:00 2001 From: David Gray Date: Sun, 17 May 2020 07:54:03 +1000 Subject: [PATCH 1/2] Add ability to adjust fill trigger variable --- Config.h | 1 + InputConfig.h | 1 + OpenBeerFiller.ino | 14 +++++++++++--- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Config.h b/Config.h index d680bbc..6f52781 100644 --- a/Config.h +++ b/Config.h @@ -30,6 +30,7 @@ #define CO2_PURGE_RETRACTION_PERIOD 500 #define FILL_SENSORS_TIMER_FREQUENCY 100000 // 100ms This value needs to be defined in microseconds. #define FILL_SENSORS_TRIGGER 400 // Int between 0 and 1023 used to trigger the fill sensor: operating voltage(5v or 3.3v) / 1024 +#define VARIABLE_FILL_SENSOR_TRIGGER true // Use a potentiometer to adjust trigger value /** * Feature flags diff --git a/InputConfig.h b/InputConfig.h index 7631c4f..54dea40 100644 --- a/InputConfig.h +++ b/InputConfig.h @@ -30,6 +30,7 @@ #define BEER_FILL_SENSOR_1 A0 #define BEER_FILL_SENSOR_2 A1 #define BEER_FILL_SENSOR_3 A2 +#define BEER_FILL_SENSOR_POT A3 #define CO2_PURGE_SOL 4 #define FILL_RAIL_SOL 3 #define BEER_BELT_SOL 2 diff --git a/OpenBeerFiller.ino b/OpenBeerFiller.ino index 6633fe2..78f4c75 100644 --- a/OpenBeerFiller.ino +++ b/OpenBeerFiller.ino @@ -41,6 +41,7 @@ volatile bool fillSensor3Triggered = false; bool idleMessageDisplayed = false; enum ProgramState {UNDEF,IDLE,START,FILLING,STOP}; ProgramState currentState = UNDEF; +int sensorValue; /** * *************************************************************************** @@ -66,6 +67,7 @@ void setupPins() { pinMode(BEER_FILL_SENSOR_1, INPUT); pinMode(BEER_FILL_SENSOR_2, INPUT); pinMode(BEER_FILL_SENSOR_3, INPUT); + pinMode(BEER_FILL_SENSOR_POT, INPUT); // Start/Stop button. pinMode(START_BUTTON, INPUT); @@ -83,13 +85,19 @@ void setupFillSensorsTimer() { * Check if the fill sensors have been triggered. */ void checkFillSensors() { - if (FILL_SENSORS_TRIGGER < analogRead(BEER_FILL_SENSOR_1)) { + if (VARIABLE_FILL_SENSOR_TRIGGER) { + sensorValue = analogRead(BEER_FILL_SENSOR_POT); + } else { + sensorValue = FILL_SENSORS_TRIGGER; + } + Serial.println(sensorValue); + if (sensorValue < analogRead(BEER_FILL_SENSOR_1)) { triggerFullFillSensor1(); } - if (FILL_SENSORS_TRIGGER < analogRead(BEER_FILL_SENSOR_2)) { + if (sensorValue < analogRead(BEER_FILL_SENSOR_2)) { triggerFullFillSensor2(); } - if (FILL_SENSORS_TRIGGER < analogRead(BEER_FILL_SENSOR_3)) { + if (sensorValue < analogRead(BEER_FILL_SENSOR_3)) { triggerFullFillSensor3(); } } From 1e06950c8392d12f30014933bb8ffa43cb1601a9 Mon Sep 17 00:00:00 2001 From: David Gray Date: Sun, 17 May 2020 08:05:58 +1000 Subject: [PATCH 2/2] Use fixed value by default --- Config.h | 2 +- OpenBeerFiller.ino | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Config.h b/Config.h index 6f52781..b7ffce4 100644 --- a/Config.h +++ b/Config.h @@ -30,7 +30,7 @@ #define CO2_PURGE_RETRACTION_PERIOD 500 #define FILL_SENSORS_TIMER_FREQUENCY 100000 // 100ms This value needs to be defined in microseconds. #define FILL_SENSORS_TRIGGER 400 // Int between 0 and 1023 used to trigger the fill sensor: operating voltage(5v or 3.3v) / 1024 -#define VARIABLE_FILL_SENSOR_TRIGGER true // Use a potentiometer to adjust trigger value +#define VARIABLE_FILL_SENSOR_TRIGGER false // Use a potentiometer to adjust trigger value /** * Feature flags diff --git a/OpenBeerFiller.ino b/OpenBeerFiller.ino index 78f4c75..18929b9 100644 --- a/OpenBeerFiller.ino +++ b/OpenBeerFiller.ino @@ -90,7 +90,6 @@ void checkFillSensors() { } else { sensorValue = FILL_SENSORS_TRIGGER; } - Serial.println(sensorValue); if (sensorValue < analogRead(BEER_FILL_SENSOR_1)) { triggerFullFillSensor1(); }