Teleperiod is the MQTT update period. The PID loop runs faster
The ESP8266 will run the PID algorithm at 1 cycle per second, which is much faster than is needed for the sort of processes Sonoff devices are usually associated with.
Regards
Phil K
Sent from Mail for Windows
--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/bb4fada0-94df-4047-971f-295ad64320f1n%40googlegroups.com.
Forgot to add, if you don’t change PID_UPDATE_SECS from 0 the algorithm runs every time it gets a temperature update.
Regards
Phil K
Sent from Mail for Windows
From: Terje Moseid Bryhni
Sent: 19 January 2022 10:56
To: TasmotaUsers
Subject: Fast PID control hampered by minimum teleperiod 10 sec
Hi,
I think you are confusing 2 issues - the PID update and MQTT updates.
With PID_UPDATE_SECS at 0 the PID algorithm runs every time the sensor reading is updated. So the PID is doing the job of controlling reacting to the sensor input.
The state of the PID is reported at TelePeriod – it does not affect the PID - it is just reporting – reducing the TelePeriod will not make the PID react to the temperature change any faster as it reacts to every sensor reading. Sending MQTT messages more frequently just clogs the system.
Having said that, if you have a heating system with a time constant at under 5 seconds you most likely have an over sized heating element. In the days when I used to do PID for a living we would be working with (heating) time constants of several minutes and sensor updates every 10 seconds or so. Mind you, one of the advantages of using 4-20mA was ignoring ‘least significant digit’ over control – as soon as digital instruments came in control room staff started to want to control to the nearest 0.1C despite that being lower than the accuracy/repeatability of the sensor.
PID is a ‘black art’. With heating we often just used PD as Integral ’wind up’ could be a big problem (particularly at start up). We’d also often have 2 elements and 1 controller. One would be used at system start up to get the temperature up quickly then we’d switch over to a smaller element and the controller for process control
--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/bb4fada0-94df-4047-971f-295ad64320f1n%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/8c6f3525-a87f-4f8d-a5a4-24fc72d67a9fn%40googlegroups.com.
You have a steam generator. 9kW will raise 1l of water by 45C in 20 seconds. The temperature will be rising so fast that the PID won’t be able to cope. The residual heat in the element means that switching the element off at, say, 10 seconds may still result in an overshoot. I’m presuming that there is a water flow and you are trying to maintain a constant output temperature. Depending on what you are trying to achieve it may be that a 4.5kW pre-heater followed by a PID controlled 4.5kW final heater may give you better control. Alternatively controlling the water flow may also be stable (like a power shower).
Good luck
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/5226a455-b7e0-4af4-9f34-e6fcb4863e3bn%40googlegroups.com.
I would erase and reflash and try it without changing any of the defaults (and possibly with a smaller heating element so that it’s less critical). PID is difficult at the best of times and once it goes wrong it’s virtually impossible to resolve. Having said that I think the issue isn’t with the PID put the Time Proportional part. The cycle time of that defaults to 60 seconds and needs to be set at build time. You have a system that has a cycle time of 20 seconds. If you set the cycle time to 5 seconds (and the dead time to 1 second – you’ll have to experiment with this (and the cycle time) – too short and the element won’t heat up – too long and you’ll lose control) you’ll get 5 seconds of full power. The PID would then send a reduced value of say 0.5 so you’d get 2.5 seconds of heat in that 5 seconds. The next cycle might be 1 second in 5 seconds etc.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/d24c8ec6-c5e5-401f-be39-52b10741da2dn%40googlegroups.com.

The cycle time shown is the process cycle time and is the maximum that the cycle time could be set to but, in practice, you would set the cycle time (time between scans of the inputs) to about 25% of the process cycle time but it MUST be longer than the dead time.

From: Philip Knowles
Sent: 08 February 2022 11:01
To: Terje Moseid Bryhni; TasmotaUsers
Subject: Re: Fast PID control hampered by minimum teleperiod 10 sec
Dead time MUST be significantly lower than cycle time. The cycle time is the time for the element to heat the water from cold the dead time is the time for a change to appear in the temperature. The controller will not attempt to control until the dead time has elapsed.
You need to find both by experimenting. Switch the element on from cold and firstly time for the temperature to start to rise then the time it takes to reach the temperature. That's the cycle time. Switch the element off and see how long it takes for the water temperature to drop. That, along with the first time you took, is a good approximation of the dead time.
Regards
Phil K
![]()
From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of Terje Moseid Bryhni <mrt...@gmail.com>
Sent: Tuesday, February 8, 2022 10:46:15 AM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Re: Fast PID control hampered by minimum teleperiod 10 sec
Not so successful test last night. Tried with deadtimes=12 and cycletimes = 12 and 1. I can't see any difference, so I am wondering if I have my platformio setup right. Time proportional module does not seem to work, so you can all imagine when the controller kicks in with 100%= 9 kW for 10-12 seconds and possibly even another round.... Still seeing overshoots of 30-40 deg C....
Maybe I should try to load tasmota from a fresh start and try to do just a minimum of changes. Keep changes of user configs to the user_config_override part? That file will be read after my-user-configs and override it, right?
Terje
søndag 6. februar 2022 kl. 11:34:22 UTC+1 skrev Terje Moseid Bryhni:
Hi,
I appreciate your input! I take it that there is still some hope in trying to implement this with the tasmota PID and time proportional function. I put the project aside for a few days, but today I made a simulation model in Unisim - as realistic as I am able to.
I fiddled with the PID constants and observed that there was not much room for aggressive control before it oscillated. I decided to try the autotune function and Unisim suggested Kc=0.407, Ti=2.02 and Td=0.448. Here is a plot of some responses to changes in setpoint, and an upset with a 5% reduction in flowrate at the end. Slow - takes 20 minutes from 8 to 78 degC, but possibly acceptable in use. I will try to flash the ESP32 with the new values, and a dead time of 12 seconds (which I assume is the same as you call "dwell time"). Cheers!
lørdag 29. januar 2022 kl. 17:54:33 UTC+1 skrev knowles...@gmail.com:
1 second is too short. It needs to be long enough to heat the water otherwise everything will wind itself up. The dwell time should also be long enough to make a difference or, again, it will wind everything up. The normal dwell is the time taken to cycle a valve. In your case it should be long enough for the element to make a reasonable change in temperature.
A good place to start is half the time taken for the element to heat from cold to the required temperature. That's your cycle time. The dwell should be about half the time to reach the temperature again after it moves of the set point.
At the start of the process the output will be on for 100% of the cycle time. After it reaches halfway the output should start to pulse and as it nears the set point the output should start to cycle at the dwell time once a cycle to maintain the temperature. If the temperature oscillate you may need to reduce the dwell.
What happens, is that all the pauses/timers come after the sensor readings are finished in a rush (acquiring identical temperature values). The same sort of behavior with tasmota.delay(500) (which is a terrible idea, anyway). You probably guessed I'm not a programmer... help?