Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 false // Use a potentiometer to adjust trigger value

/**
* Feature flags
Expand Down
1 change: 1 addition & 0 deletions InputConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 10 additions & 3 deletions OpenBeerFiller.ino
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ volatile bool fillSensor3Triggered = false;
bool idleMessageDisplayed = false;
enum ProgramState {UNDEF,IDLE,START,FILLING,STOP};
ProgramState currentState = UNDEF;
int sensorValue;

/**
* ***************************************************************************
Expand All @@ -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);
Expand All @@ -83,13 +85,18 @@ 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;
}
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();
}
}
Expand Down