Skip to content

Commit

Permalink
rename voltagesensor
Browse files Browse the repository at this point in the history
rename VOLTAGESENSORTYPE to OPTOCOUPLERTYPE
remove PINMODEVOLTAGESENSOR
  • Loading branch information
LoQue90 authored and fiendie committed Dec 12, 2023
1 parent 8394c33 commit 95aa6be
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
41 changes: 24 additions & 17 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const int OnlyPID = ONLYPID;
const int TempSensor = TEMPSENSOR;
const int brewDetectionMode = BREWDETECTION;
const int triggerType = TRIGGERTYPE;
const int VoltageSensorType = VOLTAGESENSORTYPE;
const int optoCouplerType = OPTOCOUPLERTYPE;
const boolean ota = OTA;
int BrewMode = BREWMODE;

Expand Down Expand Up @@ -123,7 +123,7 @@ int maxflushCycles = MAXFLUSHCYCLES;
// Voltage Sensor
unsigned long previousMillisVoltagesensorreading = millis();
const unsigned long intervalVoltagesensor = 200;
int VoltageSensorON, VoltageSensorOFF;
int optoCouplerON, optoCouplerOFF;

// QuickMill thermoblock steam-mode (only for BREWDETECTION = 3)
const int maxBrewDurationForSteamModeQM_ON = 200; // if brewtime is shorter steam-mode starts
Expand Down Expand Up @@ -746,13 +746,13 @@ void brewDetection() {
}
} else if (brewDetectionMode == 3) {
// timeBrewed counter
if ((digitalRead(PIN_BREWSWITCH) == VoltageSensorON) && brewDetected == 1) {
if ((digitalRead(PIN_BREWSWITCH) == optoCouplerON) && brewDetected == 1) {
timeBrewed = millis() - startingTime;
lastbrewTime = timeBrewed;
}

// OFF: reset brew
if ((digitalRead(PIN_BREWSWITCH) == VoltageSensorOFF) && (brewDetected == 1 || coolingFlushDetectedQM == true)) {
if ((digitalRead(PIN_BREWSWITCH) == optoCouplerOFF) && (brewDetected == 1 || coolingFlushDetectedQM == true)) {
isBrewDetected = 0; // rearm brewDetection
brewDetected = 0;
timePVStoON = timeBrewed; // for QuickMill
Expand Down Expand Up @@ -784,7 +784,7 @@ void brewDetection() {
if (!coolingFlushDetectedQM) {
int pvs = digitalRead(PIN_BREWSWITCH);

if (pvs == VoltageSensorON && brewDetected == 0 &&
if (pvs == optoCouplerON && brewDetected == 0 &&
brewSteamDetectedQM == 0 && !steamQM_active) {
timeBrewDetection = millis();
timePVStoON = millis();
Expand All @@ -798,7 +798,7 @@ void brewDetection() {

const unsigned long minBrewDurationForSteamModeQM_ON = 50;
if (brewSteamDetectedQM == 1 && millis()-timePVStoON > minBrewDurationForSteamModeQM_ON) {
if (pvs == VoltageSensorOFF) {
if (pvs == optoCouplerOFF) {
brewSteamDetectedQM = 0;

if (millis() - timePVStoON < maxBrewDurationForSteamModeQM_ON) {
Expand Down Expand Up @@ -827,7 +827,7 @@ void brewDetection() {
default:
previousMillisVoltagesensorreading = millis();

if (digitalRead(PIN_BREWSWITCH) == VoltageSensorON && brewDetected == 0) {
if (digitalRead(PIN_BREWSWITCH) == optoCouplerON && brewDetected == 0) {
debugPrintln("HW Brew - Voltage Sensor - Start");
timeBrewDetection = millis();
startingTime = millis();
Expand Down Expand Up @@ -908,7 +908,7 @@ boolean checkSteamOffQM() {
* thermoblock. Once the pinvolagesenor remains OFF for longer than a
* pump-pulse time peride the switch is turned off and steam mode finished.
*/
if (digitalRead(PIN_BREWSWITCH) == VoltageSensorON) {
if (digitalRead(PIN_BREWSWITCH) == optoCouplerON) {
lastTimePVSwasON = millis();
}

Expand Down Expand Up @@ -2003,17 +2003,19 @@ void setup() {
if (triggerType) {
relayON = HIGH;
relayOFF = LOW;
} else {
}
else {
relayON = LOW;
relayOFF = HIGH;
}

if (VOLTAGESENSORTYPE) {
VoltageSensorON = HIGH;
VoltageSensorOFF = LOW;
} else {
VoltageSensorON = LOW;
VoltageSensorOFF = HIGH;
if (OPTOCOUPLERTYPE == HIGH) {
optoCouplerON = HIGH;
optoCouplerOFF = LOW;
}
else {
optoCouplerON = LOW;
optoCouplerOFF = HIGH;
}

// Initialize Pins
Expand All @@ -2034,9 +2036,14 @@ void setup() {
pinMode(PIN_STEAMSWITCH, INPUT_PULLDOWN);
}

// IF Voltage sensor selected
// IF optocoupler selected
if (BREWDETECTION == 3) {
pinMode(PIN_BREWSWITCH, PINMODEVOLTAGESENSOR);
if (OPTOCOUPLERTYPE == HIGH) {
pinMode(PIN_BREWSWITCH, INPUT_PULLDOWN);
}
else {
pinMode(PIN_BREWSWITCH, INPUT_PULLUP);
}
}
else {
pinMode(PIN_BREWSWITCH, INPUT_PULLDOWN);
Expand Down
5 changes: 2 additions & 3 deletions src/userConfig_sample.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,12 @@ enum MACHINE {
#define ONLYPID 1 // 0 = PID and preinfusion, 1 = Only PID
#define ONLYPIDSCALE 0 // 0 = off , 1 = OnlyPID with Scale
#define BREWMODE 1 // 1 = Brew by time (with preinfusion); 2 = Brew by weight (from scale)
#define BREWDETECTION 0 // 0 = off, 1 = Software (Onlypid 1), 2 = Hardware (Onlypid 0), 3 = Sensor/Hardware for Only PID
#define BREWDETECTION 0 // 0 = off, 1 = Software (Onlypid 1), 2 = Hardware (Onlypid 0), 3 = optocoupler for Only PID
#define BREWSWITCHTYPE 0 // 0 = no switch connected, 1 = normal switch, 2 = trigger switch
#define POWERSWITCHTYPE 0 // 0 = no switch connected, 1 = normal switch, 2 = trigger switch
#define STEAMSWITCHTYPE 0 // 0 = no switch connected, 1 = normal switch, 2 = trigger switch
#define OPTOCOUPLERTYPE HIGH // BREWDETECTION 3 configuration; HIGH or LOW trigger optocoupler
#define TRIGGERTYPE HIGH // LOW = low trigger, HIGH = high trigger relay for pump & valve
#define VOLTAGESENSORTYPE HIGH // BREWDETECTION 3 configuration (HIGH or LOW trigger optocoupler)
#define PINMODEVOLTAGESENSOR INPUT // Mode INPUT_PULLUP, INPUT or INPUT_PULLDOWN_16 (Only Pin 16)
#define PRESSURESENSOR 0 // 0 = no pressure sensor connected, 1 = pressure sensor connected
#define TEMP_LED 1 // Blink status LED when temp is in range

Expand Down

0 comments on commit 95aa6be

Please sign in to comment.