Fixed HendiControl interface connecter to match the board input. Tested the new circuit.

Sat, 19 Jun 2021 20:46:42 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 19 Jun 2021 20:46:42 +0200
changeset 101
1bc6e9263ada
parent 100
9833fd86736b
child 102
96e30a3a3980

Fixed HendiControl interface connecter to match the board input. Tested the new circuit.

kicad/Mainboard.sch file | annotate | diff | comparison | revisions
main/Kconfig.projbuild file | annotate | diff | comparison | revisions
main/buttons.c file | annotate | diff | comparison | revisions
main/buttons.h file | annotate | diff | comparison | revisions
main/config.c file | annotate | diff | comparison | revisions
main/config.h file | annotate | diff | comparison | revisions
main/setup.c file | annotate | diff | comparison | revisions
main/task_driver.c file | annotate | diff | comparison | revisions
main/task_driver.h file | annotate | diff | comparison | revisions
sdkconfig file | annotate | diff | comparison | revisions
--- a/kicad/Mainboard.sch	Thu Jun 17 13:58:13 2021 +0200
+++ b/kicad/Mainboard.sch	Sat Jun 19 20:46:42 2021 +0200
@@ -827,28 +827,26 @@
 $Comp
 L power:+5P #PWR0217
 U 1 1 60CD580B
-P 2000 5250
-F 0 "#PWR0217" H 2000 5100 50  0001 C CNN
-F 1 "+5P" H 2015 5423 50  0000 C CNN
-F 2 "" H 2000 5250 50  0001 C CNN
-F 3 "" H 2000 5250 50  0001 C CNN
-	1    2000 5250
+P 2150 5100
+F 0 "#PWR0217" H 2150 4950 50  0001 C CNN
+F 1 "+5P" H 2165 5273 50  0000 C CNN
+F 2 "" H 2150 5100 50  0001 C CNN
+F 3 "" H 2150 5100 50  0001 C CNN
+	1    2150 5100
 	1    0    0    -1  
 $EndComp
 $Comp
 L Connector:Screw_Terminal_01x04 J209
 U 1 1 60CE8E01
-P 1700 5550
-F 0 "J209" H 1950 5100 50  0000 C CNN
-F 1 "Hendi" H 1900 5200 50  0000 C CNN
-F 2 "" H 1700 5550 50  0001 C CNN
-F 3 "~" H 1700 5550 50  0001 C CNN
-	1    1700 5550
+P 1700 5350
+F 0 "J209" H 1950 4900 50  0000 C CNN
+F 1 "Hendi" H 1950 5000 50  0000 C CNN
+F 2 "" H 1700 5350 50  0001 C CNN
+F 3 "~" H 1700 5350 50  0001 C CNN
+	1    1700 5350
 	-1   0    0    1   
 $EndComp
-Text Notes 1300 5700 0    50   ~ 0
-0V
-Text Notes 1300 5600 0    50   ~ 0
+Text Notes 1300 5150 0    50   ~ 0
 +5V
 Text Notes 1300 5500 0    50   ~ 0
 PWR
@@ -857,23 +855,15 @@
 $Comp
 L power:GND #PWR0219
 U 1 1 60D12DE2
-P 2000 6550
-F 0 "#PWR0219" H 2000 6300 50  0001 C CNN
-F 1 "GND" H 2005 6377 50  0000 C CNN
-F 2 "" H 2000 6550 50  0001 C CNN
-F 3 "" H 2000 6550 50  0001 C CNN
-	1    2000 6550
+P 2600 5750
+F 0 "#PWR0219" H 2600 5500 50  0001 C CNN
+F 1 "GND" H 2605 5577 50  0000 C CNN
+F 2 "" H 2600 5750 50  0001 C CNN
+F 3 "" H 2600 5750 50  0001 C CNN
+	1    2600 5750
 	1    0    0    -1  
 $EndComp
 Wire Wire Line
-	1900 5350 2600 5350
-Wire Wire Line
-	2000 5250 2000 5550
-Wire Wire Line
-	2000 5550 1900 5550
-Wire Wire Line
-	1900 5450 2150 5450
-Wire Wire Line
 	2150 5450 2150 6050
 Wire Wire Line
 	2150 6050 2600 6050
@@ -911,20 +901,6 @@
 	1    0    0    -1  
 $EndComp
 Wire Wire Line
-	1900 5650 2000 5650
-Wire Wire Line
-	2000 5650 2000 5750
-Wire Wire Line
-	2600 5750 2000 5750
-Connection ~ 2000 5750
-Wire Wire Line
-	2000 5750 2000 6450
-Wire Wire Line
-	2600 6450 2000 6450
-Connection ~ 2000 6450
-Wire Wire Line
-	2000 6450 2000 6550
-Wire Wire Line
 	2900 5550 3000 5550
 Wire Wire Line
 	2900 6250 3000 6250
@@ -1016,4 +992,24 @@
 $EndComp
 Text Notes 3100 1100 0    50   ~ 0
 Instellen op 5,7 tot 6,0 volt.
+Wire Wire Line
+	2150 5450 1900 5450
+Wire Wire Line
+	1900 5350 2600 5350
+Wire Wire Line
+	1900 5150 2150 5150
+Wire Wire Line
+	2150 5150 2150 5100
+NoConn ~ 1900 5250
+$Comp
+L power:GND #PWR?
+U 1 1 60DB46CB
+P 2600 6450
+F 0 "#PWR?" H 2600 6200 50  0001 C CNN
+F 1 "GND" H 2605 6277 50  0000 C CNN
+F 2 "" H 2600 6450 50  0001 C CNN
+F 3 "" H 2600 6450 50  0001 C CNN
+	1    2600 6450
+	1    0    0    -1  
+$EndComp
 $EndSCHEMATC
--- a/main/Kconfig.projbuild	Thu Jun 17 13:58:13 2021 +0200
+++ b/main/Kconfig.projbuild	Sat Jun 19 20:46:42 2021 +0200
@@ -55,6 +55,18 @@
 
                 GPIOs 35-39 are input-only so cannot be used as outputs.
 
+config PWM_MLT_GPIO
+    int "MLT PWM GPIO number"
+	range 0 34
+	default 0
+	help	GPIO number (IOxx) to the PWM pin for the MLT kettle. This is used for systems that can
+		control the heating using a PWM signal. A Hendi induction cooker for example.
+		Even when not used, this pin must be defined.
+
+		Some GPIOs are used for other purposes (flash connections, etc.) and cannot be used to drive PWM.
+
+		GPIOs 35-39 are input-only so cannot be used as PWM outputs.
+
 config SSR_HLT_GPIO
     int "HLT SSR GPIO number"
         range 0 34
--- a/main/buttons.c	Thu Jun 17 13:58:13 2021 +0200
+++ b/main/buttons.c	Sat Jun 19 20:46:42 2021 +0200
@@ -610,6 +610,21 @@
 
 
 
+void Show2Integer(uint16_t x, uint16_t y, char *label, char *suffix, int val, int val2)
+{
+    char        tmp[32];
+
+    ShowLabel(x, y, label);
+    sprintf(tmp, "%d/%d", val, val2);
+    TFT_print(tmp, LASTX, LASTY);
+    if (suffix) {
+	_fg = TFT_LIGHTGREY;
+	TFT_print(suffix, LASTX, LASTY);
+    }
+}
+
+
+
 void ShowBool(uint16_t x, uint16_t y, char *label, bool val)
 {
     ShowLabel(x, y, label);
--- a/main/buttons.h	Thu Jun 17 13:58:13 2021 +0200
+++ b/main/buttons.h	Sat Jun 19 20:46:42 2021 +0200
@@ -106,6 +106,17 @@
 void ShowInteger(uint16_t x, uint16_t y, char *label, char *suffix, int val);
 
 /**
+ * @brief Show two integers data field.
+ * @param x The X position on the screen
+ * @param y The Y position on the screen
+ * @param label The field name text
+ * @param suffix Some text after the data value or NULL
+ * @param val The first integer data value to show.
+ * @param val2 The second integer data value to show.
+ */
+void Show2Integer(uint16_t x, uint16_t y, char *label, char *suffix, int val, int val2);
+
+/**
  * @brief Show boolean data field.
  * @param x The X position on the screen
  * @param y The Y position on the screen
--- a/main/config.c	Thu Jun 17 13:58:13 2021 +0200
+++ b/main/config.c	Sat Jun 19 20:46:42 2021 +0200
@@ -122,6 +122,9 @@
 	equipment.PID_kI = 2.0;
 	equipment.PID_kD = 1.5;
 	equipment.SampleTime = 3000;
+	equipment.Hendi = false;
+	equipment.RampPower = 100;
+	equipment.Max_watt = 3000;
 	bytes = fwrite(dst, 1, sizeof(equipment), f);
 	fclose(f);
     } else {
@@ -136,34 +139,39 @@
             fclose(f);
             return;
         }
-#if 0
+#if 1
 	if (equipment_hdr.version < EQUIPMENT_VERSION) {
+	    uint32_t	oldsize = equipment_hdr.recsize;
 	    FILE	*nf = fopen("/spiffs/etc/equipments.new", "w");
 
             ESP_LOGW(TAG, "/spiffs/etc/equipments.conf version %d, new %d", equipment_hdr.version, EQUIPMENT_VERSION);
 	    dst = (uint8_t*)&equipment_hdr;
             memset(dst, 0, sizeof(equipment_hdr));
+	    // Update the header with new sizes
             equipment_hdr.version = EQUIPMENT_VERSION;
             equipment_hdr.hdrsize = sizeof(equipment_hdr);
             equipment_hdr.recsize = sizeof(equipment);
             bytes = fwrite(dst, 1, sizeof(equipment_hdr), nf);
 
-            fseek(f, 0, SEEK_SET);
-            dst = (uint8_t*)&recipe;
-            while ((bytes = fread(dst, 1, equipment_hdr.recsize, f))) {
+            dst = (uint8_t*)&equipment;
+            while ((bytes = fread(dst, 1, oldsize, f))) {
                 // Upgrade data here
+		equipment.Hendi = false;
+		equipment.RampPower = equipment.BoilPower;
+		equipment.Max_watt = 3000;
                 bytes = fwrite(dst, 1, sizeof(equipment), nf);
                 if (bytes != sizeof(equipment)) {
                     ESP_LOGE(TAG, "/spiffs/etc/equipments.new write data, %d/%d bytes", bytes, sizeof(equipment));
                 }
             }
-            // Update the header with new sizes
             fclose(nf);
             fclose(f);
             rename("/spiffs/etc/equipments.conf", "/spiffs/etc/equipments.old");
             rename("/spiffs/etc/equipments.new", "/spiffs/etc/equipments.conf");
             unlink("/spiffs/etc/equipments.old");
 	    f = fopen("/spiffs/etc/equipments.conf", "r");
+	    dst = (uint8_t*)&equipment_hdr;
+	    fread(dst, 1, sizeof(equipment_hdr), f);
 	}
 #endif
 	dst = (uint8_t*)&equipment;
--- a/main/config.h	Thu Jun 17 13:58:13 2021 +0200
+++ b/main/config.h	Sat Jun 19 20:46:42 2021 +0200
@@ -148,7 +148,7 @@
     SSR2_OFF = 0,			///< SSR2 not used.
     SSR2_HLT_SHARE,			///< SSR2 for HLT shared with MLT
     SSR2_HLT_IND,			///< SSR2 for HLT independend.
-    SSR2_ON_IDLE,			///< SSR2 on when NLT is idle.
+    SSR2_ON_IDLE,			///< SSR2 on when MLT is idle.
 } SSR2_TYPE;
 
 
@@ -192,7 +192,7 @@
 void read_config(void);
 
 
-#define EQUIPMENT_VERSION	2		///< Equipment file version
+#define EQUIPMENT_VERSION	3		///< Equipment file version
 
 /**
  * @brief Equipment configuration. File /spiffs/equipments.conf
@@ -224,6 +224,9 @@
     double	PID_kD;				///< PID D setting.
     bool	xPID_POn;
     int		SampleTime;			///< PID sample time in seconds.
+    bool	Hendi;				///< HendiControl in use.
+    int		RampPower;			///< The power percentage to ramp to boil.
+    int		Max_watt;			///< MLT plus HLT peak, shut off HLT if higher.
 } equipment;					///< Equipment record.
 
 /**
--- a/main/setup.c	Thu Jun 17 13:58:13 2021 +0200
+++ b/main/setup.c	Sat Jun 19 20:46:42 2021 +0200
@@ -168,22 +168,24 @@
 			    ShowText(2, 28, (char *)"Naam", equipment.Name);
 			    ShowInteger(  2, 44, (char *)"Kook vermogen", (char *)"%", equipment.BoilPower);
 			    ShowInteger(161, 44, (char *)"Maisch verm.", (char *)"%", equipment.MashPower);
-			    ShowInteger(  2, 60, (char *)"Pomp cyclus", (char *)"m", equipment.PumpCycle);
-			    ShowInteger(161, 60, (char *)"Pomp rust", (char *)"m", equipment.PumpRest);
-			    ShowBool(  2,  76, (char *)"Pomp opwarmen", equipment.PumpPreMash);
-			    ShowBool(161,  76, (char *)"Pomp maischen", equipment.PumpOnMash);
-			    ShowBool(  2,  92, (char *)"Pomp uitmaischen", equipment.PumpMashOut);
-			    ShowBool(161,  92, (char *)"Pomp bij koken", equipment.PumpOnBoil);
-			    ShowInteger(2, 108, (char *)"Pomp maxtemp.", (char *)"C", equipment.PumpMaxTemp);
-			    ShowBool(161, 108, (char *)"PID bij mout weg", equipment.PIDPipe);
-			    ShowSSR2(2, 124, equipment.SSR2);
-			    ShowFloat(161, 124, (char *)"Spoelwater", NULL, equipment.TempHLT, 2);
-			    ShowDouble(2, 140, (char *)"PID P", NULL, equipment.PID_kP, 3);
-			    ShowInteger(161, 140, (char *)"Sample tijd", (char *)"mS", equipment.SampleTime);
-			    ShowDouble(2, 156, (char *)"PID I", NULL, equipment.PID_kI, 3);
+			    ShowInteger(  2, 60, (char *)"Ramp vermogen", (char *)"%", equipment.RampPower);
+			    ShowFloat(161, 60, (char *)"Spoelwater", NULL, equipment.TempHLT, 2);
+			    ShowInteger(  2, 76, (char *)"Sample tijd", (char *)"mS", equipment.SampleTime);
+			    Show2Integer(161, 76, (char *)"Pomp cyclus", (char *)"m", equipment.PumpCycle, equipment.PumpRest);
+			    ShowBool(  2,  92, (char *)"Pomp opwarmen", equipment.PumpPreMash);
+			    ShowBool(161,  92, (char *)"Pomp maischen", equipment.PumpOnMash);
+			    ShowBool(  2,  108, (char *)"Pomp uitmaischen", equipment.PumpMashOut);
+			    ShowBool(161,  108, (char *)"Pomp bij koken", equipment.PumpOnBoil);
+			    ShowInteger(2, 124, (char *)"Pomp maxtemp.", (char *)"C", equipment.PumpMaxTemp);
+			    ShowBool(161, 124, (char *)"PID bij mout weg", equipment.PIDPipe);
+			    ShowSSR2(2, 140, equipment.SSR2);
+			    ShowBool(161, 140, (char *)"Hendi PWM", equipment.Hendi);
+			    ShowDouble(2, 156, (char *)"PID P", NULL, equipment.PID_kP, 3);
 			    ShowInteger(161, 156, (char *)"MLT watt", NULL, equipment.MLT_watt);
-			    ShowDouble(2, 172, (char *)"PID D", NULL, equipment.PID_kD, 3);
+			    ShowDouble(2, 172, (char *)"PID I", NULL, equipment.PID_kI, 3);
 			    ShowInteger(161, 172, (char *)"HLT watt", NULL, equipment.HLT_watt);
+			    ShowDouble(2, 188, (char *)"PID D", NULL, equipment.PID_kD, 3);
+			    ShowInteger(161, 188, (char *)"Max watt", NULL, equipment.Max_watt);
 			    Buttons_Clear();
 			    Buttons_Add(  0, 210, 45, 30, (char *)"Ok"  , 0);
 			    Buttons_Add( 46, 210, 45, 30, (char *)"+"   , 1);
@@ -284,6 +286,13 @@
 			EditText((char *)"Naam", equipment.Name, 31);
 			EditInt((char *)"Kook vermogen in %", &equipment.BoilPower, 0, 100);
 			EditInt((char *)"Maisch vermogen in %", &equipment.MashPower, 0, 100);
+			EditInt((char *)"Ramp vermogen in %", &equipment.RampPower, 0, 100);
+			EditFloat((char *)"Spoelwater temp", &equipment.TempHLT, 75, 98, 2);
+                        // Round to 0.25 values.
+                        equipment.TempHLT = ((int)(equipment.TempHLT * 4)) / 4.0;
+			EditInt((char *)"Sample tijd in mS", &equipment.SampleTime, 1000, 20000);
+			// Round to 250 mSec units.
+                        equipment.SampleTime = ((int)(equipment.SampleTime / 250)) * 250;
 			EditInt((char *)"Pomp cyclus minuten", &equipment.PumpCycle, 5, 15);
 			EditInt((char *)"Pomp rust minuten", &equipment.PumpRest, 0, 5);
 			EditBool((char *)"Pomp bij opwarmen", &equipment.PumpPreMash);
@@ -293,17 +302,13 @@
 			EditInt((char *)"Pomp max. temperatuur", &equipment.PumpMaxTemp, 60, 105);
 			EditBool((char *)"PID by mout verwijderen", &equipment.PIDPipe);
 			EditSSR2(&equipment.SSR2);
-			EditFloat((char *)"Spoelwater temp", &equipment.TempHLT, 75, 98, 2);
-			// Round to 0.25 values.
-			equipment.TempHLT = ((int)(equipment.TempHLT * 4)) / 4.0;
+			EditBool((char *)"Hendi PWM", &equipment.Hendi);
 			EditDouble((char *)"PID P",  &equipment.PID_kP, 20, 2000, 3);
 			EditDouble((char *)"PID I",  &equipment.PID_kI, 0, 100, 3);
 			EditDouble((char *)"PID D",  &equipment.PID_kD, 0, 50000, 3);
-			EditInt((char *)"Sample tijd in mS", &equipment.SampleTime, 1000, 20000);
-			// Round to 250 mSec units.
-			equipment.SampleTime = ((int)(equipment.SampleTime / 250)) * 250;
 			EditInt((char *)"MLT watt", &equipment.MLT_watt, 100, 45000);
 			EditInt((char *)"HLT watt", &equipment.HLT_watt, 100, 45000);
+			EditInt((char *)"Max watt", &equipment.Max_watt, 100, 45000);
 
 			crc2 = crc32_le(0, dst, sizeof(equipment));
 			if ((crc1 != crc2) && Confirm((char *)"Gewijzigd, opslaan?", (char *)"Ja", (char *)"Nee")) {
--- a/main/task_driver.c	Thu Jun 17 13:58:13 2021 +0200
+++ b/main/task_driver.c	Sat Jun 19 20:46:42 2021 +0200
@@ -18,6 +18,7 @@
 #define	SSR_MLT		CONFIG_SSR_MLT_GPIO			///< GPIO SSR MLT pin
 #define	SSR_HLT		CONFIG_SSR_HLT_GPIO			///< GPIO SSR HLT pin
 #define SSR_PUMP	CONFIG_SSR_PUMP_GPIO			///< GPIO Pump relay pin
+#define	PWM_MLT		CONFIG_PWM_MLT_GPIO			///< GPIO PWM MLT pin
 
 
 bool			outEnable = false;			///< Enable outputs flag
@@ -162,6 +163,9 @@
     driver_state->hlt_and_mlt = false;
     driver_state->pump_gpio = SSR_PUMP;
     driver_state->pump_run = 0;
+    driver_state->pwm_gpio = PWM_MLT;
+    driver_state->pwm_mlt = false;
+    driver_state->pwm_nohlt = 10;	/* Conservative safety value. */
 
     PID(&Input, &Output, &Setpoint, 200, 2.0, 1.5, PID_DIRECT);
     
--- a/main/task_driver.h	Thu Jun 17 13:58:13 2021 +0200
+++ b/main/task_driver.h	Sat Jun 19 20:46:42 2021 +0200
@@ -43,6 +43,9 @@
     double mlt_sp;			///< Setpoint MLT temperature
     double mlt_pv;			///< Current MLT temperature
     int    mlt_power;			///< Current MLT drive power %
+    int    pwm_gpio;			///< PWM GPIO pin
+    bool   pwm_mlt;			///< PWM in use for MLT
+    int    pwm_nohlt;			///< PWM power limit to shutdown HLT
     int    hlt_gpio;			///< HLT SSR  GPIO pin
     int    hlt_mode;			///< HLT Mode:  0 = off, 1 = bang on/off, 2 = always on
     double hlt_sp;			///< Setpoint HLT temperature
--- a/sdkconfig	Thu Jun 17 13:58:13 2021 +0200
+++ b/sdkconfig	Sat Jun 19 20:46:42 2021 +0200
@@ -121,11 +121,10 @@
 #
 # BrewBoard Configuration
 #
-CONFIG_TEMP_SENSORS_ONEWIRE=y
-# CONFIG_TEMP_SENSORS_SIMULATOR is not set
-CONFIG_ONE_WIRE_MLT=27
-CONFIG_ONE_WIRE_HLT=26
+# CONFIG_TEMP_SENSORS_ONEWIRE is not set
+CONFIG_TEMP_SENSORS_SIMULATOR=y
 CONFIG_SSR_MLT_GPIO=32
+CONFIG_PWM_MLT_GPIO=0
 CONFIG_SSR_HLT_GPIO=33
 CONFIG_SSR_PUMP_GPIO=12
 CONFIG_BUZZER_GPIO=25

mercurial