【发布时间】:2013-09-18 18:40:29
【问题描述】:
实现我拥有的这个pid代码,主要是我需要传递给函数的信息。有六个变量要传递,但我真的不知道要输入什么。 一些背景知识,我正在自动化我的家庭啤酒厂,虽然它已经全部启动并运行,但 RIM 的温度控制无处不在。对于那些不熟悉 RIM 是什么的人来说,这是一种确保被浸泡的谷物保持在非常恒定的温度的方法。它通过使用泵和加热元件加热从浸泡容器底部取出的流体并将其通过加热元件并在需要时加热流体来实现这一点。我现在运行的代码很笨,所以我需要用更智能的东西代替它,比如 PID! 加热加热器元件 计划使用一个名为“每秒”的简单函数,该函数将根据需要对温度进行多少校正,将元件通电时间从 100 毫秒更改为 1000 毫秒。
好的,我有代码,它只是如何使用它!我想在使用 vb.net 的独立 Windows 窗体项目中启动并运行它。我知道我需要使用 PID 值以使其适合我的应用程序,但是要输入什么才能让我开始呢?
非常感谢您的帮助!
Public Function PID_output(ByVal process As Double, ByVal setpoint As Double, ByVal Gain As Double, _
ByVal Integ As Double, ByVal deriv As Double, ByVal deltaT As Double)
Dim Er As Double
Dim Derivative As Double
Dim Proportional As Double
Static Olderror As Double
Static Cont As Double
Static Integral As Double
Static Limiter_Switch As Double
Limiter_Switch = 1
Er = setpoint - process
If ((Cont >= 1 And Er > 0) Or (Cont <= 0 And Er < 0) Or (Integ >= 9999)) Then
Limiter_Switch = 0
Else
Limiter_Switch = 1
End If
Integral = Integral + Gain / Integ * Er * deltaT * Limiter_Switch
Derivative = Gain * deriv * (Er - Olderror) / deltaT
Proportional = Gain * Er
Cont = Proportional + Integral + Derivative
Olderror = Er
If (Cont > 1) Then
Cont = 1
End If
If (Cont < 0) Then
Cont = 0
End If
Return (Cont)
End Function
【问题讨论】:
-
在您的上下文中 PID == http://en.wikipedia.org/wiki/PID_controller 不是进程标识符。
-
糟糕。这可能就是为什么要传递这么多变量的原因?我希望通过当前温度、目标温度、p、I、d 并返回一个数字来设置加热器功率水平。