Java Runtime Environment: which java platform is used and what version
openHAB version: openHAB 4.3.2
Issue of the topic: Cant find a step by step guide for a simple PID rule
Hello!
I am new to openHAB and home automation in general.
I got some shelly power switches and esphome based temperature sensors.
After playing around with Modeling and Plots i would like to try out the PID controller
add on. My understanding from the documentation is that in order for the PID to work
i need to have a action that accepts more then just ON/OFF. The way to do that would
be with a PWM item.
I just couldnt find any example/tutorial on how to implement that.
Any suggestions and links are welcome. Im stuck for 2 days now and dont seem to get
any closer to even test the PID addon.
First of all: Welcome to the very best home-automation community.
Btw: Trying for 2 days is quite a lot. You can ask here earlier and the best way is to describe your goal in detail and what you already tried (e.g. paste your code (use code fences!) or a screenshot of your rule).
I currently don’t use PID or PWM controllers but this is how I think it should work:
Install the add-ons (I guess that’s done)
Create a rule
– chose ID and label as you like
– select PWM as your template
– save (ignore the error)
click PWM-trigger and chose your parameters
click add action and select your actuator and save the rule
Repeat the same for the PID-rule and chose your PWM-item as the action item.
For now i just want to use a 40W lightbulb on a power switch & a Temperature sensor
in a shoe box to test the capabilities of the PID controller and my ability to configure it.
If i manage that i want to replace the thermostat in my small workshop with a openhab
based control solution.
What i did so far is:
Create all the necessary items and channels. That worked like a charm!
Put up nice plots on the Overviewpage. Also very intuitive and very nice to look at.
For my PID experiment i installed the PID Controller and the PWM Controller Add-ons.
Then i created a String item with the Tags Setpoint and Temperature and put a control widget on the overview page for easy access.
After that i created a heaterpwm rule. And last but not least the PID rule.
Since my last post i fixed some errors and the PID is now triggering the PWM and the lamp/heater goes on. it overshoots and the openhab rules page is not responsive. but thats just
tuning issues i asume.
I guess now comes the tuning part. ill come back when i have finished playing around with the pwm dutycycle and other parameters and the PID.
Had some time to continue playing with PID and PWM so here is an update.
created the following items:
type: Number, class: Setpoint, semantic property: temperature
testSetpoint - this is used as the target temperature
type: Number, class: Equipment_HVAC
PwmDutyCycleItem - this one gets the value from the PID and is used by the PWM controller
type: Number, class: Point
PIDpInspector - Name of the inspector Item for the current P-part
PIDiInspector - Name of the inspector Item for the current I-part
PIDdInspector - Name of the inspector Item for the current D-part
PIDeInspector - Name of the inspector Item for the current regulation difference (error)
still not working properly. it switches on below testsetpoint, but does not switch off.
even if the PWMdutycycleItem is 0 or , and i dont know how this can be is -1.
but then again i only defined a ON in the PWM Rules as command.
any insights are welcome. but i am in no hurry and confident that i can figure this out within a month or something like that…
This was not the fault, just changes the “reaction time” to duty cycle changes.
Well, i still dont know why PWM does not switch of when dutycyle is 0, or and thats strange sometimes -1 or -2.
I think i can build a scheduled script that checks if dutycycle is 0 and switches
off the power to the lamp/heater. but thats a workaround, id rather find out
what i am missing here with the PWM. At least i think i have a PWM problem
since my PID sets the dutycyle as i want it to, except for the small negative values
which should not matter since the PWM rounds up evrything below 0 to zero.
At least thats what the documentation in the GUI says.