# HG changeset patch # User Michiel Broek # Date 1431897805 -7200 # Node ID 2f9bbbcd24075877ae4bea24870a4c8f8017f044 # Parent 468ec0d96cceb737f6f787b7e38b0021c6a3f26a Tuning PID code. Samll changes on the unit web page. diff -r 468ec0d96cce -r 2f9bbbcd2407 configure --- a/configure Sun May 17 19:34:55 2015 +0200 +++ b/configure Sun May 17 23:23:25 2015 +0200 @@ -2034,7 +2034,7 @@ PACKAGE="mbsePi-apps" -VERSION="0.3.1" +VERSION="0.3.2" COPYRIGHT="Copyright (C) 2014-2015 Michiel Broek, All Rights Reserved" CYEARS="2014-2015" diff -r 468ec0d96cce -r 2f9bbbcd2407 configure.ac --- a/configure.ac Sun May 17 19:34:55 2015 +0200 +++ b/configure.ac Sun May 17 23:23:25 2015 +0200 @@ -8,7 +8,7 @@ dnl General settings dnl After changeing the version number, run autoconf! PACKAGE="mbsePi-apps" -VERSION="0.3.1" +VERSION="0.3.2" COPYRIGHT="Copyright (C) 2014-2015 Michiel Broek, All Rights Reserved" CYEARS="2014-2015" AC_SUBST(PACKAGE) diff -r 468ec0d96cce -r 2f9bbbcd2407 thermferm/server.c --- a/thermferm/server.c Sun May 17 19:34:55 2015 +0200 +++ b/thermferm/server.c Sun May 17 23:23:25 2015 +0200 @@ -1965,10 +1965,10 @@ srv_send((char *)"HEATER_USAGE,%d", unit->heater_usage); if (unit->PID_heat) { srv_send((char *)"PIDH_IMAX,%.1f", unit->PID_heat->iMax); + srv_send((char *)"PIDH_IDLERANGE,%.2f", unit->PID_heat->idleRange); srv_send((char *)"PIDH_PGAIN,%.2f", unit->PID_heat->pGain); srv_send((char *)"PIDH_IGAIN,%.2f", unit->PID_heat->iGain); srv_send((char *)"PIDH_DGAIN,%.2f", unit->PID_heat->dGain); - srv_send((char *)"PIDH_IDLERANGE,%.2f", unit->PID_heat->idleRange); } srv_send((char *)"COOLER_ADDRESS,%s", unit->cooler_address); srv_send((char *)"COOLER_STATE,%d", unit->cooler_state); @@ -1976,10 +1976,10 @@ srv_send((char *)"COOLER_USAGE,%d", unit->cooler_usage); if (unit->PID_cool) { srv_send((char *)"PIDC_IMAX,%.1f", unit->PID_cool->iMax); + srv_send((char *)"PIDC_IDLERANGE,%.2f", unit->PID_cool->idleRange); srv_send((char *)"PIDC_PGAIN,%.2f", unit->PID_cool->pGain); srv_send((char *)"PIDC_IGAIN,%.2f", unit->PID_cool->iGain); srv_send((char *)"PIDC_DGAIN,%.2f", unit->PID_cool->dGain); - srv_send((char *)"PIDC_IDLERANGE,%.2f", unit->PID_cool->idleRange); } srv_send((char *)"FAN_ADDRESS,%s", unit->fan_address); srv_send((char *)"FAN_STATE,%d", unit->fan_state); diff -r 468ec0d96cce -r 2f9bbbcd2407 thermferm/thermferm.c --- a/thermferm/thermferm.c Sun May 17 19:34:55 2015 +0200 +++ b/thermferm/thermferm.c Sun May 17 23:23:25 2015 +0200 @@ -1399,39 +1399,43 @@ /* * PID controller compute */ + UpdatePID(unit->PID_heat); + UpdatePID(unit->PID_cool); + + /* + * Logging + */ if (unit->heater_address) { - UpdatePID(unit->PID_heat); - if (debug) fprintf(stdout, "Heat: sp=%.2f Input=%.2f iState=%.2f Err=%.2f Out=%.2f\n", unit->PID_heat->SetP, unit->PID_heat->Input, unit->PID_heat->iState, unit->PID_heat->Err, unit->PID_heat->OutP); - if (((unit->PID_heat->OutP >= 1) && unit->heater_address) || (seconds == 60) || unit->heater_state) { + if (((unit->PID_heat->OutP >= 2) && unit->heater_address) || (seconds == 60) || unit->heater_state) { syslog(LOG_NOTICE, "Heat: sp=%.2f Input=%.2f iState=%.2f Err=%.2f Out=%.2f", unit->PID_heat->SetP, unit->PID_heat->Input, unit->PID_heat->iState, unit->PID_heat->Err, unit->PID_heat->OutP); } } if (unit->cooler_address) { - UpdatePID(unit->PID_cool); - if (debug) fprintf(stdout, "Cool: sp=%.2f Input=%.2f iState=%.2f Err=%.2f Out=%.2f\n", unit->PID_cool->SetP, unit->PID_cool->Input, unit->PID_cool->iState, unit->PID_cool->Err, unit->PID_cool->OutP); - if (((unit->PID_cool->OutP >= 1) && unit->cooler_address) || (seconds == 60) || unit->cooler_state) { + if (((unit->PID_cool->OutP >= 2) && unit->cooler_address) || (seconds == 60) || unit->cooler_state) { syslog(LOG_NOTICE, "Cool: sp=%.2f Input=%.2f iState=%.2f Err=%.2f Out=%.2f", unit->PID_cool->SetP, unit->PID_cool->Input, unit->PID_cool->iState, unit->PID_cool->Err, unit->PID_cool->OutP); } } + /* + * Deadlock + */ if (unit->PID_cool->OutP && unit->PID_heat->OutP) { syslog(LOG_NOTICE, "Heat and Cool lockdown"); unit->PID_cool->OutP = unit->PID_heat->OutP = 0.0; } if (unit->heater_address && ! unit->cooler_state) { - if (unit->PID_heat->OutP >= 1) { + if (unit->PID_heat->OutP >= 2) { if (unit->heater_wait < unit->heater_delay) { unit->heater_wait++; -// syslog(LOG_NOTICE, "heater_wait + %d/%d", unit->heater_wait, unit->heater_delay); } else { int power = round(unit->PID_heat->OutP); if (unit->heater_state != power) { @@ -1442,7 +1446,6 @@ } else { if (unit->heater_wait > 0) { unit->heater_wait--; -// syslog(LOG_NOTICE, "heater_wait - %d/%d", unit->heater_wait, unit->heater_delay); } else { if (unit->heater_state) { syslog(LOG_NOTICE, "Unit `%s' heater On => Off", unit->name); @@ -1457,10 +1460,9 @@ } if (unit->cooler_address && ! unit->heater_state) { - if (unit->PID_cool->OutP >= 1) { + if (unit->PID_cool->OutP >= 2) { if (unit->cooler_wait < unit->cooler_delay) { unit->cooler_wait++; -// syslog(LOG_NOTICE, "cooler_wait + %d/%d", unit->cooler_wait, unit->cooler_delay); } else { int power = round(unit->PID_cool->OutP); if (unit->cooler_state != power) { @@ -1471,7 +1473,6 @@ } else { if (unit->cooler_wait > 0) { unit->cooler_wait--; -// syslog(LOG_NOTICE, "cooler_wait - %d/%d", unit->cooler_wait, unit->cooler_delay); } else { if (unit->cooler_state) { syslog(LOG_NOTICE, "Unit `%s' cooler On => Off", unit->name); diff -r 468ec0d96cce -r 2f9bbbcd2407 www-thermferm/units.php --- a/www-thermferm/units.php Sun May 17 19:34:55 2015 +0200 +++ b/www-thermferm/units.php Sun May 17 23:23:25 2015 +0200 @@ -446,7 +446,7 @@ } if ($f[0] == "PIDH_IDLERANGE") { $outstr .= ' '.PHP_EOL; - $outstr .= ' PID Heat Idle Range'.PHP_EOL; + $outstr .= ' Heater Idle Range'.PHP_EOL; $outstr .= ' °C (Heater margin)'.PHP_EOL; $outstr .= ' '.PHP_EOL; } @@ -503,7 +503,7 @@ } if ($f[0] == "PIDC_IDLERANGE") { $outstr .= ' '.PHP_EOL; - $outstr .= ' PID Cool Idle Range'.PHP_EOL; + $outstr .= ' Cooler Idle Range'.PHP_EOL; $outstr .= ' °C (Cooler margin)'.PHP_EOL; $outstr .= ' '.PHP_EOL; }