luoyingdong
級別: 略有小成
|
QCPU的PID指令用ST語言做成功能塊使用, 有興趣的請參考, 下方程序是2個LOOP例子。 1. 做成2個功能塊,一個是PID_Initial, 另一個是PID_Control 2. PID_Initial 只要執行一次, PID_Control每一個LOOP執行一次。 3. PID_Initial 程序 DB_PID_2.Loops_Number:=2; DB_PID_2.Loops_Execute:=1; SD794:=HFFFF; SD795:=HFFFF; (* No Limit *) DB_PID_2.Loop1_Operation:=1; (* 1=Reverse *) DB_PID_2.Loop1_Ts:=10; (* Cycle Time *10ms *) DB_PID_2.Loop1_Kp:=100; (* *0.01 *) DB_PID_2.Loop1_Ti:=100; (* *0.1s *) DB_PID_2.Loop1_Td:=100; (* *10ms *) DB_PID_2.Loop1_Filter:=10; DB_PID_2.Loop1_MVLL:=-32767; DB_PID_2.Loop1_MVHL:=32767; DB_PID_2.Loop1_DMVL:=100; DB_PID_2.Loop1_DPVL:=100; DB_PID_2.Loop1_sys1:=0; DB_PID_2.Loop1_Kd:=800; (* *0.01 *) DB_PID_2.Loop1_sys2:=0; DB_PID_2.Loop1_sys3:=0; BMOV( 1 , DB_PID_2.Loop1_Operation , 14 , DB_PID_2.Loop2_Operation ); S_PIDINIT( 1 , DB_PID_2.Loops_Number ); DB_PID_2.Loop1_SV:=0; DB_PID_2.Loop1_PV:=0; DB_PID_2.Loop1_MVman:=0; DB_PID_2.Loop1_Auto:=0; DB_PID_2.Loop1_Alarm:=0; DB_PID_2.Loop2_SV:=0; DB_PID_2.Loop2_PV:=0; DB_PID_2.Loop2_MVman:=0; DB_PID_2.Loop2_Auto:=0; DB_PID_2.Loop2_Alarm:=0; 4. PID_Control程序 nAuto:=0; IF Auto_Man THEN nAuto:=1; END_IF; CASE Loop_Num OF 1: DB_PID_2.Loop1_SV:=SV; DB_PID_2.Loop1_PV:=PV; DB_PID_2.Loop1_MVman:=MV_Man; DB_PID_2.Loop1_Auto:=nAuto; MV:=DB_PID_2.Loop1_MV; 2: DB_PID_2.Loop2_SV:=SV; DB_PID_2.Loop2_PV:=PV; DB_PID_2.Loop2_MVman:=MV_Man; DB_PID_2.Loop2_Auto:=nAuto; MV:=DB_PID_2.Loop2_MV; END_CASE; |
|
---|---|---|
|