From 2bc4a1b6a29f4a31d08b48853481ad64dc5e4e86 Mon Sep 17 00:00:00 2001 From: mwood77 <43637076+mwood77@users.noreply.github.com> Date: Tue, 25 Jan 2022 19:33:31 +0100 Subject: [PATCH] chore(memory): clarified some comments, moved relay/pid compute() call to a different location --- koffie/koffie.ino | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/koffie/koffie.ino b/koffie/koffie.ino index 4c3dac1..c747194 100644 --- a/koffie/koffie.ino +++ b/koffie/koffie.ino @@ -92,7 +92,7 @@ float const PRESSURE_SENSOR_INPUT_PIN{A3}; double const RELAY_CONTROL_OUTPUT_PIN{11}; // PWM compatible output @ 498 Hz (CHECK BEFORE CHANGING) const int PRESSURE_TRANSDUCER_MAX_PSI = 60.0; // Change this value to the maximum value your pressure sensor can read in PSI. Ex: 30 PSI sensor = 30.0 - const double ATMOSPHERIC_OFFSET{0.0}; + const double ATMOSPHERIC_OFFSET{0.0}; // Example offset of -0.17 (measured against physical gauge) /* * These values control the overall "tuning" of the PID. @@ -453,12 +453,6 @@ MEASUREMENT_INPUT = convertedReading; - // COMPUTE PID LEVELS - pidControl.Compute(); - - // APPLY PID COMPUTE TO RELAY - relay.loop(); - if (MEASUREMENT_INPUT > SETPOINT) { relay.setDutyCyclePercent(0); relay.setRelayPosition(relayPositionOpen); // change relayPositionOpen to relayPositionClosed if your relay is normally open @@ -466,6 +460,12 @@ relay.setDutyCyclePercent(CONTROL_OUTPUT / 255.0); // Relay library only accepts values between 0 and 1 } + // COMPUTE PID LEVELS + pidControl.Compute(); + + // APPLY PID COMPUTE TO RELAY + relay.loop(); + // Serial.print(F("SETPOINT: ")); // Serial.print(SETPOINT); // only displays in BAR in serial monitor // Serial.print(F(" | MEASUREMENT_INPUT: ")); @@ -591,10 +591,11 @@ display.setTextColor(WHITE, BLACK); - // ************************************************************************************* - // If you want to display a digital readout of the current (unfiltered) pressure, + // ********************************************************************************************************* + // If you want to display a digital readout of the current (unfiltered) pressure in MANU mode, // uncomment the lines beneath and the closing bracket at line 629. - // ************************************************************************************* + // ********************************************************************************************************* + // // if (CURRENT_MODE == 25) { // display.setCursor(70, 28); // display.print(F("TARG "));