# PID Mixing Valve Temperature control

**URL:** https://discourse.nodered.org/t/pid-mixing-valve-temperature-control/18316
**Category:** General
**Created:** [23 November 2019 14:20 UTC](https://discourse.nodered.org/t/pid-mixing-valve-temperature-control/18316 "2019-11-23T14:20:08Z")
**Posts on this page:** 9
**Page:** 2

<div class="post-metadata">

### Author: ![sokomm](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@sokomm](https://discourse.nodered.org/u/sokomm)
#### Post date: [30 November 2019 12:14 UTC](https://discourse.nodered.org/t/pid-mixing-valve-temperature-control/18316/21 "2019-11-30T12:14:03Z")

</div>

ok  
I'll try tonight with integral of 600 and PB 4 and start doubling PB.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [30 November 2019 13:50 UTC](https://discourse.nodered.org/t/pid-mixing-valve-temperature-control/18316/22 "2019-11-30T13:50:05Z")

</div>

By stable I mean that the temperature is not oscillating wildly. In particular the PID output should settle out in the middle somewhere rather than bouncing off one end or the other.

---

<div class="post-metadata">

### Author: ![sokomm](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@sokomm](https://discourse.nodered.org/u/sokomm)
#### Post date: [30 November 2019 17:52 UTC](https://discourse.nodered.org/t/pid-mixing-valve-temperature-control/18316/23 "2019-11-30T17:52:49Z")

</div>

Tuning is ongoing  
PB4 I600

 ![PB4I600](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/9/9ab4901bfda59ce333fd4b047d1ca5ade84b8ff7.png)

PB8 I600

 ![PB8I600](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/f/f16a07d1d5096048defc9406e4e7ad29de8aa0ad.png)

Should I increase PB more or lower i?

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [30 November 2019 18:15 UTC](https://discourse.nodered.org/t/pid-mixing-valve-temperature-control/18316/24 "2019-11-30T18:15:43Z")

</div>

What happened at the start of the second one?  
Experiment and see. If you decrease it too much it will start ringing and eventually go unstable, but it doesn't look too far off at the moment. Since you don't want the servo moving too much and you don't need super accurate control then you might be better to leave the PB fairly wide as the servo won't move about as much.  
Once you are happy with it then you can reduce the Integral time which will pull it onto the setpoint more quickly. If you make it too short again it will start ringing or go unstable.  
Make sure you keep notes on what you did so you can look back at the charts and know what the response was like for the various settings.  
Finally you could try a bit of derivative which might allow for snappier response, but it will make the servo jump about a lot more so probably you don't want to do that.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [30 November 2019 18:28 UTC](https://discourse.nodered.org/t/pid-mixing-valve-temperature-control/18316/25 "2019-11-30T18:28:14Z")

</div>

Oh, I see, you increased the PB and the re-deploy kicked it. I don't think you needed to increase it, it looked pretty good at 4 didn't it?

---

<div class="post-metadata">

### Author: ![sokomm](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@sokomm](https://discourse.nodered.org/u/sokomm)
#### Post date: [30 November 2019 18:46 UTC](https://discourse.nodered.org/t/pid-mixing-valve-temperature-control/18316/26 "2019-11-30T18:46:04Z")

</div>

Yes at PB4 it got there real fast but I noticed pid was often changing, at PB8 Its slover but the servo moves less. The Buffer has now gone over 60C so for tonight i'm done.  
Tomorrow I'll let it run longer at PB4 and see how often does it adjust when it gets to the setpoint.  
I'll leave the integral at 600 for now

Notes for tonight's run

 ![3011](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/a/a31eaff145cefefe0cbbe04190cb31b4ae2fb709.png)

---

<div class="post-metadata">

### Author: ![sokomm](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@sokomm](https://discourse.nodered.org/u/sokomm)
#### Post date: [13 December 2019 16:09 UTC](https://discourse.nodered.org/t/pid-mixing-valve-temperature-control/18316/27 "2019-12-13T16:09:21Z")

</div>

After testing the PID for 2 weeks I found the system to be working good with PB8 I500

Thanks Colin for your help and the great PID node

 ![pid](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/2/28b4aae45ed4c0eb0c7ddf489dbcb188c2e4c03f.png)

Here is my flow if somebody needs to do a similar setup

```auto
[
    {
        "id": "a6ee5f70.096cf",
        "type": "tab",
        "label": "PID Kotlarnica",
        "disabled": false,
        "info": ""
    },
    {
        "id": "ec330aa8.b59f88",
        "type": "PID",
        "z": "a6ee5f70.096cf",
        "name": "",
        "setpoint": "60",
        "pb": "8",
        "ti": "500",
        "td": "0",
        "integral_default": "0",
        "smooth_factor": "0",
        "max_interval": 600,
        "enable": "1",
        "disabled_op": "0",
        "x": 607,
        "y": 78,
        "wires": [
            [
                "9c0ca922.2658d8"
            ]
        ]
    },
    {
        "id": "9c0ca922.2658d8",
        "type": "range",
        "z": "a6ee5f70.096cf",
        "minin": "0",
        "maxin": "1",
        "minout": "64",
        "maxout": "21",
        "action": "scale",
        "round": true,
        "property": "payload",
        "name": "Scale power",
        "x": 745,
        "y": 79,
        "wires": [
            [
                "ef3d89a8.a68a08"
            ]
        ]
    },
    {
        "id": "581c2099.5b745",
        "type": "mqtt out",
        "z": "a6ee5f70.096cf",
        "name": "MQTT",
        "topic": "",
        "qos": "1",
        "retain": "true",
        "broker": "ca0557c2.d52418",
        "x": 1365,
        "y": 84,
        "wires": []
    },
    {
        "id": "8e0f869d.3f1b88",
        "type": "mqtt in",
        "z": "a6ee5f70.096cf",
        "name": "Boiler Sensors",
        "topic": "sokomm/tele/kot/SENSOR",
        "qos": "1",
        "datatype": "auto",
        "broker": "ca0557c2.d52418",
        "x": 426.25000381469727,
        "y": 187.00000190734863,
        "wires": [
            [
                "25186461.aa728c"
            ]
        ]
    },
    {
        "id": "25186461.aa728c",
        "type": "json",
        "z": "a6ee5f70.096cf",
        "name": "",
        "property": "payload",
        "action": "",
        "pretty": false,
        "x": 430,
        "y": 140,
        "wires": [
            [
                "75a49fe7.e79cd"
            ]
        ]
    },
    {
        "id": "4fcaaf1d.3e893",
        "type": "change",
        "z": "a6ee5f70.096cf",
        "name": "Position Topic",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "sokomm/cmnd/mventil/Dimmer",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1192.7500190734863,
        "y": 67,
        "wires": [
            [
                "581c2099.5b745"
            ]
        ]
    },
    {
        "id": "1fed989e.973627",
        "type": "trigger",
        "z": "a6ee5f70.096cf",
        "op1": "OFF",
        "op2": "ON",
        "op1type": "str",
        "op2type": "str",
        "duration": "4",
        "extend": false,
        "units": "s",
        "reset": "",
        "bytopic": "all",
        "name": "Delay OFF",
        "x": 1026,
        "y": 106.25,
        "wires": [
            [
                "4cd64d25.3c2c34"
            ]
        ]
    },
    {
        "id": "4cd64d25.3c2c34",
        "type": "change",
        "z": "a6ee5f70.096cf",
        "name": "ON OFF Topic",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "sokomm/cmnd/mventil/Power1",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1194.500015258789,
        "y": 105.25000190734863,
        "wires": [
            [
                "581c2099.5b745"
            ]
        ]
    },
    {
        "id": "653cb467.8f3e6c",
        "type": "delay",
        "z": "a6ee5f70.096cf",
        "name": "",
        "pauseType": "delay",
        "timeout": "1",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "minute",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": true,
        "x": 1034.5,
        "y": 65.75,
        "wires": [
            [
                "4fcaaf1d.3e893"
            ]
        ]
    },
    {
        "id": "75a49fe7.e79cd",
        "type": "function",
        "z": "a6ee5f70.096cf",
        "name": "Split Data",
        "func": "var msgBoilerIN = {};\nvar msgBuffer = {};\nvar msgPump = {};\nvar msgPID = {};\nmsgBoilerIN.payload = msg.payload.DS18x20.S28FF3C29001704ED; //Temp Sensor on the Boiler Inlet\nmsgBuffer.payload = msg.payload.DS18x20.S28FF4BB7311703D3; // Buffer Tnak Bottom Temperatue\nmsgPump.payload = msg.payload.Switch1; //Reads the state of the Buffer Tnak Pump,ON and OFF are inverted\n\n\n\nif ((msgBuffer.payload > 63 && msgPump.payload === \"OFF\") || msgPump.payload === \"ON\") {msgPID.payload=false;\n msgPID.topic = 'enable';\n return [msgPID];\n}\nelse;\n {msgPID.payload=true;\n msgPID.topic = 'enable';\n return [msgBoilerIN,msgPID];\n } \n\nnode.status({fill:\"black\",shape:\"dot\",text:msgPump.payload });\n\n\n\n\n\n",
        "outputs": 2,
        "noerr": 0,
        "x": 439,
        "y": 77,
        "wires": [
            [
                "ec330aa8.b59f88"
            ],
            [
                "ec330aa8.b59f88"
            ]
        ],
        "outputLabels": [
            "Temp Ventil",
            "PID on off"
        ]
    },
    {
        "id": "ef3d89a8.a68a08",
        "type": "rbe",
        "z": "a6ee5f70.096cf",
        "name": "",
        "func": "rbe",
        "gap": "",
        "start": "",
        "inout": "out",
        "property": "payload",
        "x": 886.5,
        "y": 78,
        "wires": [
            [
                "653cb467.8f3e6c",
                "1fed989e.973627"
            ]
        ]
    },
    {
        "id": "ca0557c2.d52418",
        "type": "mqtt-broker",
        "z": "",
        "name": "",
        "broker": "localhost",
        "port": "1883",
        "clientid": "",
        "usetls": false,
        "compatmode": true,
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "closeTopic": "",
        "closePayload": "",
        "willTopic": "",
        "willQos": "0",
        "willPayload": ""
    }
]

```

---

<div class="post-metadata">

### Author: ![Coa1234](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/coa1234/32/15705_2.png) [@Coa1234](https://discourse.nodered.org/u/Coa1234)
#### Post date: [2 January 2020 13:24 UTC](https://discourse.nodered.org/t/pid-mixing-valve-temperature-control/18316/28 "2020-01-02T13:24:40Z")

</div>

@sokomm  
Can you provide more information and pictures about the servo, wiring with nodemcu and valve mounting?  
Unable to send private messages.

---

<div class="post-metadata">

### Author: ![sokomm](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@sokomm](https://discourse.nodered.org/u/sokomm)
#### Post date: [11 January 2020 13:20 UTC](https://discourse.nodered.org/t/pid-mixing-valve-temperature-control/18316/29 "2020-01-11T13:20:06Z")

</div>

![3d](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/2/e265b1e8146459538450e7e758860b04321b9434.png)

 ![sema](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/e/0e1da7dcd283ac75509e0069a36dd0f928367138.png)

[STL Files For Servo mount](https://www.thingiverse.com/thing:4096754)

[Previous page](https://discourse.nodered.org/t/pid-mixing-valve-temperature-control/18316.md?page=1)
