Updated 2024-11-14 !
In
a former post
I did some hacking/checking how our underfloor heating control system
handled the valves, actuators, regulating the heat.
Now it was time to do some tests with NodeRed(NR), with a
PID controller, and a
Shelly 1(S1) connected via WiFi and driving the actuator.
The actuators are in my case controlled by 24 VAC and the S1 accepts 110
- 240 VAC, 24 - 60 VDC and 12 VDC. So in this case it was simple to
just add a rectifier and a capacitor, to the 24 VAC, to get
approx 36 VDC to source the S1.
Hardware setup
Raspberry Pi
I have a Raspberry Pi which is running 24/7, with other functions, so added the below flow to the NR installation.
Relay
So connect according to the schematics, seen at the right, and
then setup the S1
for your WiFi.
Thermometer
A very nice sensor is the Ruuvi tag but due to it is Bluetooth the range could be limited. Another solution could be using cheep 433 MHz temperature sensors.
Software
Prerequisites
As said I have used
NodeRed with the additional nodes
- node-red-contrib-pid, PID node. Check the documentation with links to a sample flow
- node-red-dashboard, which visualizes the data
- node-red-contrib-timeprop, gives a time proportioned output from a linear input.
The flow
As an extra function the valve is exercised to max open during 10
minutes, at 06:45, so it will not get stuck. Especially useful during
summertime when it's probably closed most of the time.
Tuning
There are lot of documentation for tuning PID controllers but the guy who wrote the PID node have done an article and Eurotherm, a machine automating company, also have a good compact writing.
Start up with configure the PID node to use ON/OFF control
- "Proportional band” set to zero.
- The integral effect, "Integral time", will be disabled with a large number. One day in seconds => 24x60x60 => 86400.
- Disable the derivate effect, "Derivative time" and set to zero.
- "Initial integral" set to zero.
- "Derivate smoothing factor" set to zero.
Start up the process and check the temperature progress in the graph. Get the values for "Xosc" and "tosc". As a first approach change the values in the PID to;
P = 2.0 * Xosc, Proportional band
I = 1.5 * tosc, Integral time
D = I / 5, Derivative time
I = 1.5 * tosc, Integral time
D = I / 5, Derivative time
As said by Eurotherm "These values result in a slightly over damped response and consequently all values can be reduced slightly to give a more responsive loop."
Wrap up
As seen in the picture, set point 20 °C, the measured temperature values are in 0,1 °C steps which makes the PID output react with a quick raise in the
output. This could be changed with a smaller "Derivative time", or a
low pass filter on the input, but the best way is to have
a measurement which is moore stable and have a better resolution.
For the moment the setup is running with the mentioned Ruuvi which really improves performance.
Please note that the data with the valve opening status have
another time base.
If you want to learn more about the PID controller and it's parameters
just search on Youtube and, as said, use the sample flow.
Hi, please can you share your Node-Red flow in json-format?
ReplyDeleteHi, planning to start a WEB-shop and sell some code. Could that be of any interest?
Deletedifficult to say whether this makes sense, as ChatGPT can now output really good code and Node-Red flows.
DeleteOk, thanks for your response.
DeleteWhat Kp, Ki and Kd parameters you ended up?
ReplyDeleteThis setup has not been running for a long time, but just started it up again with some code changes. For the moment it's just on/off due to some problems with shunt/pump. But still it's within +- 0,25 C. It really makes a big difference if you have a stable temperature measurement with good resolution. Now using Ruuvi.
Delete