欢迎来到天天文库
浏览记录
ID:43543974
大小:31.00 KB
页数:3页
时间:2019-10-10
《组态软件MCGS的PID程序》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、'*asng1DataValue(0)=PV'*asng1DataValue(1)=SV'*asng1DataValue(2)=OP'*asng1DataValue(3)=P'*asng1DataValue(4)=I'*asng1DataValue(5)=D'sng1ParP=250'*比例系数P'sng1ParI=50'*积分系数I'sng1ParD=5'*微分系数D'sng1PvMin=0'*PV值下限'sng1PvMax=300'*PV值上限'sng1SvMin=0'*SV值下限'sng1SvMax=300'*SV值上限'sng1OpMin=0'*OP值下限
2、'sng1OpMax=100'*OP值上限'sng1ChangeMin=1'*死区范围'sng1ChangeMax=10'*调节范围'sng1OutPutMax=80'*超调时输出'sng1CtlDirection=1'*调节方向'sng1ControlT=100'*PID的调控周期,和设备的采集周期相同'Dimsng1PVRange'*PV值的量程'Dimsng1Outdx'*PID计算出的输出增加值'''*确保控制周期不为0Ifsng1ControlT=0Thensng1ControlT=1''*计算PV值的量程,并确保其不为0sng1PVRange=sng1
3、PvMax-sng1PvMinIfsng1PVRange<=0Thensng1PVRange=1''*把超调值由百分比转换成实际物理量'sng1ChangeMax=sng1PVRange*sng1ChangeMax/100'*======================================================================================''*PV值和SV值必须在设定的限值范围之内Ifsng1Pvsng1PvMaxThensng1
4、Pv=sng1PvMaxIfsng1Svsng1SvMaxThensng1Sv=sng1SvMax'*================================================================================================='*计算SV和PV值的差值,第一次计算时,取m_sng1SvPvdx1、m_sng1SvPvdx2值和m_sng1SvPvdx相同'm_sng1SvPvdx'*本次调控时SV和PV值的差值'm_s
5、ng1SvPvdx1'*上次调控时SV和PV值的差值'm_sng1SvPvdx2'*调控过程中SV和PV值的差值的累计和m_sng1SvPvdx=sng1Sv-sng1Pvm_sng1SvPvdx2=m_sng1SvPvdx2+m_sng1SvPvdxm_sng1SvPvdx1=m_sng1SvPvdx'设定m_sng1SvPvdx1的初值为111111;标记是否第一次进行PID计算,防止m_sng1SvPvdx和1m_sng1SvPvdx2的值为0Ifm_sng1SvPvdx1=111111Thenm_sng1SvPvdx1=m_sng1SvPvdxm_sng1
6、SvPvdx2=m_sng1SvPvdxEndIf'*进行PID运算,sng1ParI=0和sng1ParI<>0的算法不一样'sng1ControlT:调节周期,和设备的采集周期相同(单位为:秒)Ifsng1ParI<>0Thensng1Outdx=sng1ParP*(m_sng1SvPvdx-m_sng1SvPvdx1+m_sng1SvPvdx*sng1ControlT/sng1ParI+(m_sng1SvPvdx-2*m_sng1SvPvdx1+m_sng1SvPvdx2)*sng1ParD/sng1ControlT)Elsesng1Outdx=sng1Pa
7、rP*(m_sng1SvPvdx-m_sng1SvPvdx1+(m_sng1SvPvdx-2*m_sng1SvPvdx1+m_sng1SvPvdx2)*sng1ParD/sng1ControlT)EndIf'*处在死区范围,输出值保持不变If!Abs(m_sng1SvPvdx)
8、=sng1
此文档下载收益归作者所有