Version 0.9.8. Added extra path to the fonts for Debian buster. Changed the PID to work on Proportional on Measurement. Added loops so that it looks like the PID is running at 100 mSec intervals.

Sat, 25 Apr 2020 20:31:31 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 25 Apr 2020 20:31:31 +0200
changeset 605
e00f8ff4de9a
parent 604
e2766e538d0e
child 606
798dd0c4fd00

Version 0.9.8. Added extra path to the fonts for Debian buster. Changed the PID to work on Proportional on Measurement. Added loops so that it looks like the PID is running at 100 mSec intervals.

brewpanel/sdlgui.c file | annotate | diff | comparison | revisions
configure file | annotate | diff | comparison | revisions
configure.ac file | annotate | diff | comparison | revisions
thermferm/pid.c file | annotate | diff | comparison | revisions
thermferm/thermferm.c file | annotate | diff | comparison | revisions
--- a/brewpanel/sdlgui.c	Mon Nov 04 13:19:27 2019 +0100
+++ b/brewpanel/sdlgui.c	Sat Apr 25 20:31:31 2020 +0200
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Copyright (C) 2015
+ * Copyright (C) 2015-2020
  *   
  * Michiel Broek <mbroek at mbse dot eu>
  *
@@ -124,8 +124,11 @@
 	if ((pFont = TTF_OpenFont(Pt, 14 )) == NULL) {
 	    sprintf(Pt, "%s", "/usr/share/fonts/truetype/freefont/DejaVuSans.ttf");
 	    if ((pFont = TTF_OpenFont(Pt, 14 )) == NULL) {
-		syslog(LOG_NOTICE, "Could not load DejaVuSans.ttf");
-		return -1;
+		sprintf(Pt, "%s", "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf");
+		if ((pFont = TTF_OpenFont(Pt, 14 )) == NULL) {
+		    syslog(LOG_NOTICE, "Could not load DejaVuSans.ttf");
+		    return -1;
+		}
 	    }
 	}
     }
--- a/configure	Mon Nov 04 13:19:27 2019 +0100
+++ b/configure	Sat Apr 25 20:31:31 2020 +0200
@@ -2047,9 +2047,9 @@
 
 
 PACKAGE="mbsePi-apps"
-VERSION="0.9.7"
-COPYRIGHT="Copyright (C) 2014-2019 Michiel Broek, All Rights Reserved"
-CYEARS="2014-2019"
+VERSION="0.9.8"
+COPYRIGHT="Copyright (C) 2014-2020 Michiel Broek, All Rights Reserved"
+CYEARS="2014-2020"
 
 
 
--- a/configure.ac	Mon Nov 04 13:19:27 2019 +0100
+++ b/configure.ac	Sat Apr 25 20:31:31 2020 +0200
@@ -8,9 +8,9 @@
 dnl General settings
 dnl After changeing the version number, run autoconf!
 PACKAGE="mbsePi-apps"
-VERSION="0.9.7"
-COPYRIGHT="Copyright (C) 2014-2019 Michiel Broek, All Rights Reserved"
-CYEARS="2014-2019"
+VERSION="0.9.8"
+COPYRIGHT="Copyright (C) 2014-2020 Michiel Broek, All Rights Reserved"
+CYEARS="2014-2020"
 AC_SUBST(PACKAGE)
 AC_SUBST(VERSION)
 AC_SUBST(COPYRIGHT)
--- a/thermferm/pid.c	Mon Nov 04 13:19:27 2019 +0100
+++ b/thermferm/pid.c	Sat Apr 25 20:31:31 2020 +0200
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Copyright (C) 2015..2016
+ * Copyright (C) 2015..2020
  *   
  * Michiel Broek <mbroek at mbse dot eu>
  *
@@ -41,26 +41,26 @@
 {
     if (pid->Mode == PID_MODE_AUTO) {
 
-	double	dTerm;
+	double	dInput;
 
 	if (pid->Type == PID_TYPE_HEAT)
 	    pid->Err = pid->SetP - pid->Input;
 	else
 	    pid->Err = pid->Input - pid->SetP;
 
+	dInput = (pid->Input - pid->InputLast);
+
 	/*
 	 * Calculate the integral state with appopriate limiting.
-	 * Use ErrLastLast as iState
 	 */
 	pid->iState += (pid->iGain * pid->Err);
+	pid->iState -= (pid->pGain * dInput); // Add Proportional on Measurement
 	if (pid->iState > pid->iMax)
 	    pid->iState = pid->iMax;
 	else if (pid->iState < 0)
 	    pid->iState = 0;
 
-	dTerm = (pid->Input - pid->InputLast);
-
-	pid->OutP = (pid->pGain * pid->Err) + pid->iState - (pid->dGain * dTerm);
+	pid->OutP = pid->iState - pid->dGain * dInput;
 	pid->InputLast = pid->Input;
 
     } else if (pid->Mode == PID_MODE_BOO) {
--- a/thermferm/thermferm.c	Mon Nov 04 13:19:27 2019 +0100
+++ b/thermferm/thermferm.c	Sat Apr 25 20:31:31 2020 +0200
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Copyright (C) 2014-2019
+ * Copyright (C) 2014-2020
  *   
  * Michiel Broek <mbroek at mbse dot eu>
  *
@@ -1642,10 +1642,12 @@
 		    }
 
 		    /*
-		     * PID controller compute
+		     * PID controller compute, simulate 100 mSec loops.
 		     */
-		    UpdatePID(unit->PID_heat);
-		    UpdatePID(unit->PID_cool);
+		    for (int i = 0; i < 10; i++) {
+		    	UpdatePID(unit->PID_heat);
+		    	UpdatePID(unit->PID_cool);
+		    }
 
 		    /*
 		     * Logging
@@ -1869,9 +1871,7 @@
 			publishDBirth(unit);
 			unit->mqtt_flag &= ~MQTT_FLAG_BIRTH;
 		    } else {
-//			if (unit->mode != UNITMODE_OFF) {
-			    publishDData(unit);
-//			}
+			publishDData(unit);
 			unit->mqtt_flag &= ~MQTT_FLAG_DATA;
 		    }
 		    if (unit->mqtt_flag & MQTT_FLAG_DEATH) {

mercurial