hj91 / node-red-contrib-easy-pid-controller

This Node-RED node provides a PID (Proportional-Integral-Derivative) controller functionality. It utilizes the simple-pid-controller package to perform the control logic.
GNU General Public License v3.0
1 stars 1 forks source link

PID setpoint tracking #4

Closed isabido closed 8 months ago

isabido commented 8 months ago

Hi hj91! The first to thank you for your excellent job!

I am designing a system at home where I need all photovoltaic production to be used to heat water.

What I need is, if the solar panels are generating 1kw (this measurement is extracted by mqtt from the inverter and it would be the setpoint remote) I need to divert all that power to a resistor controlled by a dimmer with 0-10v signal input through a Shelly Dimmer 0-10v

Regulator 25A https://es.aliexpress.com/item/20000003997748.html?spm=a2g0o.cart.0.0.eec37a9dSt4vWf&mp=1&gatewayAdapt=glo2esp

https://shelly-api-docs.shelly.cloud/gen2/Devices/ShellyPlus10V

SP is the instantaneous solar power extracted by MQTT from the solar inverter, logically the SP will be continuously oscillating according to the solar generation.

PV will be a ShellyEM with a clamp measuring the consumption of the dimmer. (This value can be obtained by Json HTTP)

OUT will be the Shelly Dimmer 0-10 connected to the SSVR. (

The ultimate goal is that the PV = SP

Do you think could do it with your node?

There was also the option to do it in a ESP32, but seeing your contribution I see it easier to do it in Nodered. I leave you the scheme I had, sorry for my disastrous English!

image

Thanks for your attention!

hj91 commented 8 months ago

It should work. Please test it.

isabido commented 8 months ago

I am very new in Node Red, I know what I want to do but not how to do it.

I planned to find me in your block the connection points for SV, PV, and out.

But I think they are not directly accessible, can it be?

You could help me generate a generic code and I already tried to adapt it later.

Thank you! image

hj91 commented 8 months ago

Check here for template

https://github.com/hj91/node-red-contrib-easy-pid-controller/blob/main/examples/easy-pid-controller.json

isabido commented 8 months ago

Thank you!! I have been able to write the SV and PV values from the MQTT Explorer, but I am not able to connect my MQTT Solar Power to SV input.

Forgive my awkwardness!

image flows.json

hj91 commented 8 months ago

No problem. Replace this node by real pid controller hardware in case things dont work out well as your requirement.

isabido commented 8 months ago

I have already managed to inject SV and PV with an external variable through MQTT.

Now I would have to scale the variables.

SV and PV from 0-2kW

And the OUT would need to be configured from 0-100% flows.json

image

isabido commented 8 months ago

HI @hj91

Let's see if you can clarify for me what I'm doing wrong.

I'm messing around with your example, and I can't understand why the output VALUE value doesn't increase when PV is lower than SV. I've noticed that it takes the same value as the PV input.

The OUTPUT does increase as expected.

image flows.json

hj91 commented 8 months ago

Adjust the values of p, I, d to suite the system.... The values I provided in sample are for theory only.

Let me add that pid tuning is another time consuming exercise one needs to do for their system. And there is no one single magic way to do it in one attempt.

isabido commented 8 months ago

Yes, I know that the PID issue is complex and an art to tune it, but what is happening is that I set the values I set for P I D, the Value output is always equal to the PV.

hj91 commented 8 months ago

Try adjusting the values and check the response of your system - usually it aims to make sure pv is approx equeal or close to sv.

isabido commented 8 months ago

Hi @hj91

Indeed, the PV must ultimately be the same or as close as possible to the SV.

But what I am commenting on is although I have tried different ways to tune the PID, the value that enters PV is as if I copied it to msg.payload.Value. It's always the same.

And the normal thing is that if the PV is below the SV, the value of msg.payload.Value should increase so that the PV gets closer to the SV.

In fact, the msg.payload.Output value does integrate and increase its value.

Thanks!!

But I understand that control output of 0-10V or 4-20mA is collected from msg.payload.Value with a range of 0-100%?

isabido commented 8 months ago

Hi @hj91

I have been reading this post

https://github.com/hj91/node-red-contrib-easy-pid-controller/issues/2

And now I have clarified myself!! The same thing happened to this colleague as me, please you have to correct the documentation and specify that the OUTPUT is the output and not the VALUE, it gives rise to error for us "non-experts"

What I do find strange is the behavior of OUTPUT, should it be limited between 0-100%, what could I do for this?

The msg.payload.Output will be sent to the Shelly Dimmer (this expects a range of 0-100%) and then in proportion it will act with 0-10v on the regulator where the resistance that heats the water is connected.

hj91 commented 8 months ago

ok, i guess its time rewrite the code

isabido commented 8 months ago

Thank you! We all wait patiently for her.