Changed Fan switch logic.

Wed, 01 Apr 2015 15:56:04 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 01 Apr 2015 15:56:04 +0200
changeset 348
ffc4b8aa824f
parent 347
0ab5c3fd7c77
child 349
1f89da6511a9

Changed Fan switch logic.

thermferm/devices.c file | annotate | diff | comparison | revisions
thermferm/thermferm.c file | annotate | diff | comparison | revisions
--- a/thermferm/devices.c	Wed Apr 01 15:20:05 2015 +0200
+++ b/thermferm/devices.c	Wed Apr 01 15:56:04 2015 +0200
@@ -339,9 +339,9 @@
 			    }
 
 			    if ((write_w1(device->address, (char *)"output", output)) == 0) {
-			    	syslog(LOG_NOTICE, "DS2413 PIO%c value=%d", (device->subdevice == 0) ? 'A' : 'B', (value == 0) ? 0 : 1);
+			    	syslog(LOG_NOTICE, "DS2413 PIO%c value=%d (%s)", (device->subdevice == 0) ? 'A' : 'B', (value == 0) ? 0 : 1, device->comment);
 			    	if (debug)
-				    fprintf(stdout, "DS2413 PIO%c value=%d\n", (device->subdevice == 0) ? 'A' : 'B', (value == 0) ? 0 : 1);
+				    fprintf(stdout, "DS2413 PIO%c value=%d (%s)\n", (device->subdevice == 0) ? 'A' : 'B', (value == 0) ? 0 : 1, device->comment);
 				device->value = (value == 0) ? 0 : 1;
 				device->timestamp = time(NULL);
 			    }
--- a/thermferm/thermferm.c	Wed Apr 01 15:20:05 2015 +0200
+++ b/thermferm/thermferm.c	Wed Apr 01 15:56:04 2015 +0200
@@ -1432,16 +1432,13 @@
 			}
 			device_out(unit->cooler_address, unit->cooler_state);
 		    }
-		    if (unit->heater_address && unit->cooler_address && unit->fan_address) {
+
+		    if ((unit->heater_address || unit->cooler_address) && unit->fan_address) {
 			/*
-			 * If the temperature difference between air and beer is more then
-			 * xxx degrees, turn the fan on to make an airflow.
-			 * Maybe, run the fan too if the heater is on because the heater in
-			 * most cases will be some sort of radiating heat device.
-			 * For cooling ??? dunno yet.
+			 * If there is a heater or cooler and we have a fan, turn fan on if
+			 * cooling or heating.
 			 */
-			if (((unit->air_temperature - unit->beer_temperature) > 1000) ||
-				((unit->air_temperature - unit->beer_temperature) < -1000)) {
+			if ((unit->heater_address && unit->heater_state) || (unit->cooler_address && unit->cooler_state)) {
 			    if (! unit->fan_state)
 				syslog(LOG_NOTICE, "Fan Off => On");
 			    unit->fan_state = 100;
@@ -1452,6 +1449,7 @@
 			}
 			device_out(unit->fan_address, unit->fan_state);
 		    }
+
 		} else {
 		    P_err = 0.0;
 		    unit->PID_iState = 0.0;

mercurial