thermferm/thermferm.c

changeset 318
aad7789a40f2
parent 317
18dd6eadba31
child 319
8c454ec761a8
equal deleted inserted replaced
317:18dd6eadba31 318:aad7789a40f2
1362 pid = NULL; 1362 pid = NULL;
1363 } else { 1363 } else {
1364 /* 1364 /*
1365 * Simple temperature control 1365 * Simple temperature control
1366 */ 1366 */
1367 if (P_err < 0) { 1367 if (P_err > 0) {
1368 Out = 100.0; 1368 Out = 100.0;
1369 } else if (P_err > 0) { 1369 } else if (P_err < 0) {
1370 Out = -100.0; 1370 Out = -100.0;
1371 } else { 1371 } else {
1372 Out = 0.0; 1372 Out = 0.0;
1373 } 1373 }
1374 if ((Out >= 1) || (Out <= -1) || (seconds == 60) || unit->heater_state || unit->cooler_state) { 1374 if ((Out >= 1) || (Out <= -1) || (seconds == 60) || unit->heater_state || unit->cooler_state) {
1410 // syslog(LOG_NOTICE, "sp=%.2f pv=%.2f P_err=%.2f dState=%.2f iState=%.2f pTerm=%.2f iTerm=%.2f dTerm=%.2f Out=%.2f", 1410 // syslog(LOG_NOTICE, "sp=%.2f pv=%.2f P_err=%.2f dState=%.2f iState=%.2f pTerm=%.2f iTerm=%.2f dTerm=%.2f Out=%.2f",
1411 // sp, pv, P_err, unit->PID_dState, unit->PID_iState, pTerm, iTerm, dTerm, Out); 1411 // sp, pv, P_err, unit->PID_dState, unit->PID_iState, pTerm, iTerm, dTerm, Out);
1412 // } 1412 // }
1413 // unit->PID_dState = pv; 1413 // unit->PID_dState = pv;
1414 1414
1415 if (unit->heater_address) { 1415 if (unit->heater_address && ! unit->cooler_state) {
1416 if (Out >= 1) { 1416 if (Out >= 1) {
1417 if (unit->heater_wait < unit->heater_delay) { 1417 if (unit->heater_wait < unit->heater_delay) {
1418 unit->heater_wait++; 1418 unit->heater_wait++;
1419 syslog(LOG_NOTICE, "heater_wait + %d/%d", unit->heater_wait, unit->heater_delay); 1419 syslog(LOG_NOTICE, "heater_wait + %d/%d", unit->heater_wait, unit->heater_delay);
1420 } else { 1420 } else {
1421 if (! unit->heater_state && ! unit->cooler_state) { 1421 if (! unit->heater_state) {
1422 syslog(LOG_NOTICE, "Heater Off => On"); 1422 syslog(LOG_NOTICE, "Heater Off => On");
1423 unit->heater_state = 100; 1423 unit->heater_state = 100;
1424 } 1424 }
1425 } 1425 }
1426 } else { 1426 } else {
1434 } 1434 }
1435 } 1435 }
1436 } 1436 }
1437 device_out(unit->heater_address, unit->heater_state); 1437 device_out(unit->heater_address, unit->heater_state);
1438 } 1438 }
1439 if (unit->cooler_address) { 1439 if (unit->cooler_address && ! unit->heater_state) {
1440 if (Out <= -1) { 1440 if (Out <= -1) {
1441 if (unit->cooler_wait < unit->cooler_delay) { 1441 if (unit->cooler_wait < unit->cooler_delay) {
1442 unit->cooler_wait++; 1442 unit->cooler_wait++;
1443 syslog(LOG_NOTICE, "cooler_wait + %d/%d", unit->cooler_wait, unit->cooler_delay); 1443 syslog(LOG_NOTICE, "cooler_wait + %d/%d", unit->cooler_wait, unit->cooler_delay);
1444 } else { 1444 } else {

mercurial