简体   繁体   English

Python GEKKO 用于 PID 调整

[英]Python GEKKO for PID Tuning

I'm working through the ( excellent! ) Process Dynamics and Control course at apmonitor.com and have a question about using GEKKO for simulating (and optimizing) PID control parameters.我正在学习 apmonitor.com 的(非常棒!过程动力学和控制课程,并且有一个关于使用 GEKKO 模拟(和优化)PID 控制参数的问题。

Starting with Example 14. PID_Control_Tuning I am wondering how to deal with processes that have a physically limited output (OP) range.从示例14 开始。PID_Control_Tuning我想知道如何处理物理上受限的 output (OP) 范围的进程。 (The TCLab heater for example, which is limited to 0-100% of full-scale output.) (以 TCLab 加热器为例,它限制为满量程 output 的 0-100%。)

If the "step" variable in the example is changed to:如果示例中的“step”变量更改为:

step[40:]  = 15.0 # Increase Step Size from 5.0 to 15.0

then the (dimensionless) output (OP) value at time=40 is 150.那么(无量纲的)output(OP)值在 time=40 是 150。

GEKKO Python PID Process Control Plot GEKKO Python PID 过程控制 Plot

If I add LOWER and UPPER boundaries to the OP Variable using:如果我使用以下方法将 LOWER 和 UPPER 边界添加到 OP 变量:

#OP = m.Var(value=0.0) # Original
OP = m.Var(value=0.0, lb=0.0, ub=100.0)

the model fails to solve and results in Exception: @error: Solution Not Found model 无法解决并导致Exception: @error: Solution Not Found

What is the correct way to simulate a process in GEKKO that is bounded by hard limits (like 0%-100%)?在 GEKKO 中模拟受硬限制(如 0%-100%)限制的过程的正确方法是什么?

Unlike the MPC, the PID controller is not an optimization-based algorithm.与 MPC 不同,PID controller 不是基于优化的算法。 If you simulate the PID controller, OP is not a decision variable that can be limited by the 'lb' and 'ub'.如果您模拟 PID controller,则 OP 不是可以受“lb”和“ub”限制的决策变量。
You also may want to use a Gekko simulation mode (imode=4 or 7) as you simulate the PID controller.在模拟 PID controller 时,您可能还想使用 Gekko 模拟模式(imode=4 或 7)。

OP value is a result of the PID calculation. OP 值是 PID 计算的结果。 So, you need to let PID calculate the OP value regardless of the physical limitation.因此,您需要让 PID 计算 OP 值,而不考虑物理限制。 Then, you add the additional conditions to deal with the physical limits as below.然后,您添加附加条件来处理物理限制,如下所示。 You also need to add the anti-windup (reset integral) logic as well.您还需要添加防饱和(重置积分)逻辑。

if OP[i]>=100: # upper limit
    OP[i] = 100.0
    I[i] = I[i-1] # reset integral
if OP[i]<=0: # lower limit
    OP[i] = 0.0
    I[i] = I[i-1] # reset integral

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM