Skip to content
Snippets Groups Projects
Commit 887c9249 authored by Pico2's avatar Pico2
Browse files

Update temperature controller with secondary input.

parent 840ba232
Branches
No related tags found
No related merge requests found
# CHANGELOG # CHANGELOG
## 1.3.1
### Added
* Add a secondary control Pin (to switch both outputs at the same time)
## 1.3.0 ## 1.3.0
### Added ### Added
......
...@@ -4,15 +4,18 @@ ...@@ -4,15 +4,18 @@
* Read sensor values and calculate a PID value from sensor 0. * Read sensor values and calculate a PID value from sensor 0.
* Depending on this PID value, a control (relay, valve etc.) is switched. * Depending on this PID value, a control (relay, valve etc.) is switched.
* *
* Error is setpoint minus current value.
* For temperature: higher temperature is lower value. Positive P/I increases with rising temperatures.
* An additional channel can deactivate the controller as an emergency shut off. * An additional channel can deactivate the controller as an emergency shut off.
*************************** ***************************
*/ */
//** CONSTANTS PARAMETERS change for your application **// //** CONSTANTS PARAMETERS change for your application **//
const String version = "1.3.0"; // Version of this script. Filename is added before, date of compilation afterwards. const String version = "1.3.1"; // Version of this script. Filename is added before, date of compilation afterwards.
const int cyclePeriod = 1; //program cycle period in s const int cyclePeriod = 1; //program cycle period in s
const int controlPin = 11; //Pin by which the control unit is controlled (11 or 12) const int controlPin = 11; //Pin by which the control unit is controlled (11 or 12)
const int secondaryControlPin = 12; // Secondary Pin to control output (or -1)
const int emergencyPin = -1; // Analog channel to which the emergency sensor is connected. Set to -1 to deactivate const int emergencyPin = -1; // Analog channel to which the emergency sensor is connected. Set to -1 to deactivate
const int emergencyThreshold = 341; // Threshold value, when the control should be deactivated due to emergency activated const int emergencyThreshold = 341; // Threshold value, when the control should be deactivated due to emergency activated
...@@ -103,11 +106,11 @@ void setup() { ...@@ -103,11 +106,11 @@ void setup() {
} }
EEPROM.get(1 * floatsize, PIDKp); EEPROM.get(1 * floatsize, PIDKp);
if ( isnan(PIDKp)){ if ( isnan(PIDKp)){
PIDKp = -1000; PIDKp = 1000;
} }
EEPROM.get(2 * floatsize, PIDKi); EEPROM.get(2 * floatsize, PIDKi);
if ( isnan(PIDKi)){ if ( isnan(PIDKi)){
PIDKi = -1; PIDKi = 1;
} }
EEPROM.get(3 * floatsize, integral); EEPROM.get(3 * floatsize, integral);
if ( isnan(integral) || integral < 0 || integral > 1000 ){ if ( isnan(integral) || integral < 0 || integral > 1000 ){
...@@ -343,5 +346,8 @@ void enable_control(const boolean enabled){ ...@@ -343,5 +346,8 @@ void enable_control(const boolean enabled){
if (digitalRead(controlPin) != enabled){ if (digitalRead(controlPin) != enabled){
digitalWrite(controlPin, enabled); digitalWrite(controlPin, enabled);
digitalWrite(indicatorPin, enabled); digitalWrite(indicatorPin, enabled);
if (secondaryControlPin >= 0){
digitalWrite(secondaryControlPin, enabled);
}
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment