一个例程PID 程序,请教高手,怎么样设置Q 格式?
一下是我附上的一个pid 控制程序例程(2407的 ,请教高手,这里边ki 是Q31格式的,如果我的ki 是个大于1的整数,该怎么设置? 还有在寄存器里写个16进制数,怎么样写识别它的格式?比如设置成Q0,Q8,Q15该怎么操作?谢谢了
; File name: pig.asm
; .ref PID_REG1, PID_REG1_INIT ; .ref pid_fb_reg1, pid_ref_reg1 ; .ref pid_out_reg1
; .def PID_REG1, PID_REG1_INIT .def pid_fb_reg1, pid_ref_reg1 .def pid_out_reg1
;DP_USER .set 5 ;DP 指向280h-300h 单元 Kp_REG1_ .set 1000h ;for Kp_reg1
Ki_HI_REG1_ .set 0005h ;for Ki_low_reg1(Ki=0 for PD Ki_LO_REG1_ .set 0DEADh ;for Ki_high_reg1 (Ki=0 for PD Kd_REG1_ .set 0000h ;for Kd_reg1(Kd=0 for PI PID_REF_REG1_ .set 0000h ;for pid_ref_reg1 PID_OUT_MAX_ .set 0666h ;for pid_out_max PID_OUT_MIN_ .set 0000h ;for pid_out_min
.include \;Definition in \
;Variable Definitions for PID_REG1 module Kp_reg1 .usect \Ki_low_reg1 .usect \Ki_high_reg1 .usect \Kd_reg1 .usect \K0_low_reg1 .usect \K0_high_reg1 .usect \K1_reg1 .usect \pid_fb_reg1 .usect \pid_ref_reg1 .usect \pid_out_reg1 .usect \pid_out1_reg1 .usect \pid_e0_reg1 .usect \pid_e1_reg1 .usect \pid_e2_reg1 .usect \tmp1_low_reg1 .usect \tmp1_high_reg1 .usect \
tmp2_low_reg1 .usect \tmp2_high_reg1 .usect \tmp3_reg1 .usect \abs_e0_reg1 .usect \sign_reg1 .usect \.def _c_int0 ;PID_REG1_INIT: .text
_c_int0: ;相当于主程序的入口 LDP #Kp_reg1
SPLK #Kp_REG1_,Kp_reg1 SPLK #Ki_LO_REG1_,Ki_low_reg1 SPLK #Ki_HI_REG1_,Ki_high_reg1 SPLK #Kd_REG1_,Kd_reg1 SPLK #0,pid_e1_reg1 SPLK #0,pid_e2_reg1 SPLK #0,pid_out1_reg1
SPLK #PID_REF_REG1_,pid_ref_reg1 RET