Actuators behind a PID now use power percentage instead of always 100%

Thu, 19 Feb 2015 16:39:35 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 19 Feb 2015 16:39:35 +0100
changeset 319
8c454ec761a8
parent 318
aad7789a40f2
child 320
9e419f3c4e49

Actuators behind a PID now use power percentage instead of always 100%

thermferm/thermferm.c file | annotate | diff | comparison | revisions
--- a/thermferm/thermferm.c	Thu Feb 19 16:08:05 2015 +0100
+++ b/thermferm/thermferm.c	Thu Feb 19 16:39:35 2015 +0100
@@ -1418,9 +1418,10 @@
 				unit->heater_wait++;
 				syslog(LOG_NOTICE, "heater_wait + %d/%d", unit->heater_wait, unit->heater_delay);
 			    } else {
-				if (! unit->heater_state) {
-				    syslog(LOG_NOTICE, "Heater Off => On");
-				    unit->heater_state = 100;
+				int	power = round(Out);
+				if (unit->heater_state != power) {
+				    syslog(LOG_NOTICE, "Heater %d%% => %d%%", unit->heater_state, power);
+				    unit->heater_state = power;
 				}
 			    }
 			} else {
@@ -1442,9 +1443,10 @@
 				unit->cooler_wait++;
 				syslog(LOG_NOTICE, "cooler_wait + %d/%d", unit->cooler_wait, unit->cooler_delay);
 			    } else {
-				if (! unit->cooler_state && ! unit->heater_state) {
-				    syslog(LOG_NOTICE, "Cooler Off => On");
-				    unit->cooler_state = 100;
+				int	power = round(0 - Out); 
+				if (unit->cooler_state != power) {
+				    syslog(LOG_NOTICE, "Cooler %d%% => %d%%", unit->cooler_state, power);
+				    unit->cooler_state = power;
 				}
 			    }
 			} else {

mercurial