colinl / node-red-contrib-pid

A node-red PID loop controller node intended for the control of real world processes
Apache License 2.0
26 stars 17 forks source link

Cooling instead of heating #6

Closed chixxi closed 6 years ago

chixxi commented 6 years ago

Thanks for your work. I have set up everything so that this works just perfectly for a home brewing setup, now I wanted to use this for fermentation too, but that would be cooling, not heating.

Would it be possible to add that setting? Or is there a possibility where I can change that myself?

colinl commented 6 years ago

If you mean you want to control just cooling (as opposed to a system that needs both heat and cool as appropriate) then take the output (which is 0 to 1) and subtract it from 1 so you get a value which goes from 1 to 0. Then use that to control the cooler. That is all you need do.

chixxi commented 6 years ago

Thanks for the very quick reply! Yes, that is exactly what I meant. I will try that.

So far I have just tested setting the "Proportional band" to a negative value, seems to do the trick too.

colinl commented 6 years ago

I wasn't sure whether a negative prop band might have unexpected side effects, probably safer to flip the output. If you are using my time proportion node then you can just flip the 'invert' checkbox, or if you are using a double throw relay you can use the normally closed instead of normally open. Basically you just need On to be Off and Off to be On. You probably want to think about which way it should go if the pi (or whatever) is powered down.

chixxi commented 6 years ago

Thank you so much for taking the time for these replies.

I did try the option with "1-PID", but in my mind this makes no sense. If the PID would put out a load of 20%, then with that calculation I would apply 80% to the actual cooler.

However, your timeprop node (https://flows.nodered.org/node/node-red-contrib-timeprop) solves all my problems, absolutely great! Too bad I didn't know about this one earlier, I have made all of that manually with functions nodes.

colinl commented 6 years ago

There is no difference. Consider the condition you mention where the PID requests 20%. If you feed that into the timeprop with no invert, with for example a period of 10 mins set, then you will get 2 minutes on and 8 minutes off in each sample, which is appropriate for heating. With the invert set then you will get 8 minutes on and 2 minutes off which is appropriate for cooling. Now consider the other situation, the PID is asking for 20%, subtract that from 100% gives 80% and feed that into a non-inverting timeprop and you get 8 mins on and 2 mins off. Exactly the same.

chixxi commented 6 years ago

Makes sense!

chixxi commented 6 years ago

OK, I did some testing, the 1-PID-Request approach is wrong. I do have an active cooler, meaning to cool 100% the PID should output 1. Now lets say we are so far from the setpoint that the PID would output 1, then it would cool 0%, next we are really close to the setpoint, PID Output would be 0.2, we would be cooling 80%, now we get even closer to the setpoint, PID Output is 0.1, we would cool 90%. So the closer we get to the setpoint the stronger we cool.

However, I do have changed your js file so that it now works with cooling: screenshot from 2017-10-21 12-15-11

It is not a big change. I can send it to you if you want. I think it would very cool if heating or cooling could be selected as an option within the node.

colinl commented 6 years ago

On 21 October 2017 at 11:16, chixxi notifications@github.com wrote:

OK, I did some testing, the 1-PID-Request approach is wrong. I do have an active cooler, meaning to coll 100% the PID should output 1. Now lets say we are so far from the setpoint that the PID would output 1, then it would cool 0%, next we are really close to the setpoint, PID Output would be 0.2, we would be cooling 80%, now we get even closer to the setpoint, PID Output is 0.1, we would cool 90%. So the closer we get to the setpoint the stronger we cool.

As I have said several times all you need to do is to switch the output so that and output of 1 from the PID switches the cooler fully off and and output of 0 from the PID switches the cooler fully off. In particular if you are using node-red-contrib-timeprop then all you need do is the flip the invert checkbox.

Is that what your new code does? changes 1 to 0 and 0 to 1 and linearly in between?

Colin

However, I do have changed your js file so that it now works with cooling: [image: screenshot from 2017-10-21 12-15-11] https://user-images.githubusercontent.com/1770007/31850811-84fe08c6-b659-11e7-984c-51103919cb4c.png

It is not a big change. I can send it to you if you want. I think it would very cool if heating or cooling could be selected as an option within the node.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/colinl/node-red-contrib-pid/issues/6#issuecomment-338381019, or mute the thread https://github.com/notifications/unsubscribe-auth/AACVo5fyxnff4HG2Ce2YpH7cuAIlkC0yks5sucSNgaJpZM4PyzL8 .