;===================================================== ; µÈЧµÄ C´úÂë ;{
; register short Pos, Delta; ;
; Pos = POSCNT; ;
; Delta = Pos - EncoderParm.iPrevCnt; ; EncoderParm.iPrevCnt = Pos; ;
; if( iDelta >= 0 ) ;{
; // Delta > 0ÒòΪ ; // 1) vel > 0»ò
; // 2) Vel < 0ÇÒ±àÂëÆ÷¼ÆÊýÖµ³öÏַת·µ»Ø¡£ ;
; if( Delta >= EncoderParm.iCntsPerRev/2 ) ;{
; // Delta >= EncoderParm.iCntsPerRev/2 => ¸º×ªËÙ£¬³öÏַת·µ»Ø ;
; Delta -= EncoderParm.iCntsPerRev; ;} ;} ; else ;{
; // Delta < 0ÒòΪ ; // 1) vel < 0»ò
; // 2) Vel > 0²¢³öÏַת·µ»Ø ;;
; if( Delta < -EncoderParm.iCntsPerRev/2 ) ;{
; // Delta < -EncoderParm.iCntsPerRev/2 => ÕýתËÙ£¬³öÏַת·µ»Ø ;
; Delta += EncoderParm.iCntsPerRev; ;} ;} ;
; EncoderParm.iAccumCnt += Delta; ;
; EncoderParm.iVelCntDwn--; ; if(EncoderParm.iVelCntDwn) ; return; ;
; iVelCntDwn = iIrpPerCalc;
; qVelMech = qKvel * iAccumCnt * 2^Nvel; ; EncoderParm.iAccumCnt = 0; ;}
;=================== ´úÂë ===================== ; CalcVelIrpµÄ¼Ä´æÆ÷ʹÓÃ
.equ PosW, w0 ; µ±Ç°Î»Ö㺠POSCNT .equ WorkW, w4 ; ¹¤×÷¼Ä´æÆ÷
.equ DeltaW, w6 ; NewCnt - PrevCnt .global _CalcVelIrp .global CalcVelIrp _CalcVelIrp: CalcVelIrp:
;; ±£´æ¼Ä´æÆ÷ÄÚÈÝ push w0 push w4 push w6
;; Pos = uTestPos; .ifdef SIMU
mov.w _uTestPos,PosW ; ±àÂëÆ÷Öµ ?? .else
mov.w POSCNT,PosW ; ±àÂëÆ÷Öµ .endif
mov.w _EncoderParm+Encod_iPrevCnt,WorkW
;; ÓÃÐ嵀 cnt¸üÐÂǰһ¸ö cnt¡£
mov.w PosW,_EncoderParm+Encod_iPrevCnt
;; ¼ÆËã Delta = New - Prev sub.w PosW,WorkW,DeltaW bra N,jEncoder5 ; Delta < 0
;; Delta > 0ÒòΪ
;; 1) vel > 0»ò