发布于 2013-02-27 18:49:43
3楼
将 pidCalc.awl 导入到你的工程,在使用前要对pid 参数进行初始化,如:
// 自定义PID 参数 初始化
MOVW 2500, PID_WDA_Kc:VW400
MOVW 9000, PID_WDA_Ti:VW402
MOVW 0, PID_WDA_Td:VW404
MOVD 0, WDA_PID_LastError:VD820
MOVD 0, WDA_PID_SumError:VD824
MOVW 0, WDA_PID_OutPut:VW828
MOVW 10000, WDA_PID_OutPut_MAX:VW830 // 输出上限
MOVW -10000, WDA_PID_OutPut_MINI:VW832 // 输出下限
//----------------温度PID参数初始化----------------
使用时只要调用PID子程序即可计算出输出的控制值:
// SetPoint ,NextPoint ,kc,ti,td,OutPut_MINI,OutPut_MAX,PID_LastError,PID_SumError,PID_OutPut
CALL PIDCalc, SetPoint ,NextPoint ,PID_WDA_kc,PID_WDA_ti,PID_WDA_td, WDA_PID_OutPut_MINI,WDA_PID_OutPut_MAX,WDA_PID_LastError,WDA_PID_SumError,WDA_PID_OutPut//
PID_OutPut,就是输出值。
注意: 运算中所以的数据均为整数。