This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

PID regulator
#1
I'm trying to get the PID working the way I want to.
It doesn't seem to adjust to the parameters in the way I'm used to.
with just 1% over or under SP the output goes to 0 or 100..

Any advice in tweaking this to work better?
Reply
#2
For how long was the script running? PID needs some time to stabilize and if you restart the script the accumulated values will be lost. Have you modified the kp/ki/kd gain values?
Reply
#3
Yes I have modified the kp,ki,kd,it has ben on for hours now with same result.
I suspect there is something off in my parameters, cause I changed the max to 80% but it still gives out 100%
Reply
#4
To what object did you link the output?
------------------------------
Ctrl+F5
Reply
#5
32/1/5

Code:
--PID Supply
-- init pid algorithm
if not pTV then
  pTV = PID:init({
    manual    ='32/1/3',        -- Setter PID i manuell ved "1"
    kp    = 1,                -- P-Bånd
    ki    = 300,                 -- I-Tid
    kd    = 1,                  -- D-Tid
    current = '32/1/1',            --Faktisk Verdi
    setpoint = '32/1/7',    --Settpunkt
    inverted = true,        --Inverterer utgangen
    min = 0,            -- Minimum utgangssignal
    max    = 80,        -- Maksimum utgangssignal 
    output = '32/1/5'        --Pådrag
  })
end

-- run algorithm
pTV:run()
log(pTV)
--
Reply
#6
What datatype?
------------------------------
Ctrl+F5
Reply
#7
ki 300 is way too much. Set is to 1, restart the script using disable/enable and check how it works.
Reply
#8
Try this:

To make it work as expected, i.e output 0-100%:
The p-term is calculated in range 0-1, so it should be multiplied with 100 in the script.
 
Some other points:
Kp = 1 / P-band --> P-band = 4 K -> Kp = 0,25
Ki = Kp / Ti * 100 --> Ti = (1 min * 60 s) -> Ki = 0.42
 
You can easily test this:
Current: 20
Setpoint: 21
P-term immediately gives output: 25%
After 1 min output is 50% (as the I-term is aiming reaching P-term i Ti-time)
 
So if you want 5 K / 240 min
 
Kp = 1 / 5 -> 0,2
Ki = (0,2 / 240 * 60) * 100 -> 0.0014
Reply
#9
Thank you, will do some testing. Intended use is to regulate a ventilation fan.

Sent fra min SM-G980F via Tapatalk
Reply
#10
Code:
User library tratec_PID:126: attempt to perform arithmetic on local 'setpoint' (a boolean value)
stack traceback:
User library tratec_PID:126: in function 'compute'
User library tratec_PID:110: in function 'run'
What does this error mean?

Call:
Code:
if not pTV then
  pTV = PID:init({
    --manual   ='',                    -- Setter PID i manuell ved "1"
    kp            = 1,           -- P-Bånd
    ki            = 0.4 ,          -- I-Tid
    kd            = 1,              -- D-Tid
    current     = TV_vav,                --Faktisk Verdi
    setpoint     = TV_vav_SP,                        --Settpunkt
    inverted     = true,                --Inverterer utgangen
    min             = 0,                -- Minimum utgangssignal
    max            = 100,                -- Maksimum utgangssignal 
    output         = '33/1/6'                 --Pådrag
  })
end

-- run algorithm
pTV:run()
log(pTV)
Reply
#11
Check that your setpoint group address has correct data type. Error tells that it is 1-bit instead of 2-byte float.
Reply
#12
figured it out. Is it possible to set some sort of deadband on the PID? So the output does not change when value within a deadband of e.g 2.5

It still regulates as described above, 0 and then 100. I want the output to gradually increese when closing on setpoint, and then gradually reduce when above. Im used to Pgain and I time. but this is not applicable here? d gain, how do you dissable this? does it accept 0?
Reply
#13
Do you need deadband for combined heating and cooling? One option is to have two PID scripts where only one is active at a time. For this you will need an extra object to for mode switch. You can also modify the PID library. Otherwise PID library should be modified to incorporate this.

Erwin's already described how to tune gain values.
Reply
#14
(01.02.2023, 10:28)admin Wrote: Do you need deadband for combined heating and cooling? One option is to have two PID scripts where only one is active at a time. For this you will need an extra object to for mode switch. You can also modify the PID library. Otherwise PID library should be modified to incorporate this.

Erwin's already described how to tune gain values.

I'm not using this as a heating PID, but a fancontroller. The PID transmits settpints to a frequency drive.
Reply
#15
Then please explain exactly how the deadband should work in this case.
Reply
#16
(01.02.2023, 12:03)admin Wrote: Then please explain exactly how the deadband should work in this case.

setpoint= 90% 
actual = value from regulator
deadband = 0.5

if "actual" is within +/- "deadband" of "setpoint" then "output" stays uncanged.
Reply


Forum Jump: