亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? pid.asm

?? pic16c745 的 firmware的一個usb樣例,供大家參考
?? ASM
字號:
;	File : PID.asm
;
;	Proportional, Integral, Differential control loop utility.

	GLOBAL	doPID, InitPID, SetTarget
	GLOBAL	K1,K2,K3,Target,DeltaV

#include	<P16C745.inc>

	errorlevel  -302              ; suppress message 302 from list file
	
#define MaximumTarget	H'C2'
#define TargetADC	MaximumTarget

#define subwl	sublw		; Ward's Secret Macro

Kp	equ	D'200'	 	; Proportional error multiplier
Ki 	equ	D'128'		; Integral error multiplier
Kd	equ	D'32'		; Differential error multiplier

;*****************************************************************************************
;*
;* Define RAM variables
;*

bank0			udata

multcnd		res	1	; 8 bit multiplicand
multplr		res	1	; 8 bit multiplier
xCount		res	1	; counter workspace used by Multiply and Tacq
H_Byte		res	1	; High byte of the 16 bit multiply result
L_Byte		res	1	; Low byte of the 16 bit multiply result
K1		res	1	; P multiplier
K2		res	1	; I multiplier
K3		res	1	; D multiplier
Target		res	1	; Target boost voltage ADC
MaxTarget	res	1	; Maximum target boost voltage
DeltaV		res	1	; difference between target and measured output voltage
LastDeltaV 	res	1	; previous DeltaV
H_Integral 	res	1	; ms byte of 16 bit error integrator
L_Integral 	res	1	; ls byte of 16 bit error integrator
H_PIDSum 	res	1	; ms byte of 16 bit PID sum
L_PIDSum 	res	1	; ls byte of 16 bit PID sum
PIDTemp		res	1	; temporary work space

	global	K1
	global	K2
	global	K3

PORT1	code

doPID
	; use value passed through W as latest input for PID

	movwf	PIDTemp

CtrlLoop	
	banksel	DeltaV
	movf	DeltaV,w			; get most recent error voltage
	movwf	LastDeltaV		; save as last

	bcf	STATUS,C			; assure zero in msb after rotate
	rrf	PIDTemp,w		; get latest input (7 bit signed)
	subwf	Target,w			; compute error voltage
	movwf	DeltaV			; save

; Proportional error

	movf	K1,w				; prepare for multiply by pre-placing...
	movwf	multplr			; ...Proportional multiplier and...
	movf	DeltaV,w			; ...error voltage...
	movwf	multcnd			; ...in multiply workspace
	call	Multiply			; multiply Proportional error by K1
	movf	H_Byte,w			; accumulate first of PID offsets
	movwf	H_PIDSum			;
	movf	L_Byte,w			;
	movwf	L_PIDSum			;

; Integral error

	movf	K2,w				; prepare for multiply by pre-placing...
	movwf	multplr			; ...Integral multiplier
	movf	DeltaV,w			; compute Integral Deltas
	movwf	multcnd			; save integral in multiply workspace
	call	Multiply			; multiply Integral error by K2
	call	Integrate		; integrate and accumulate

; Differential error

	movf	K3,w				; prepare for multiply by pre-placing...
	movwf	multplr			; ...Differential multiplier
	movf	LastDeltaV,w			; compute Differential voltage...
	subwf	DeltaV,w	; ...Differential = Delta - LastDelta
	movwf	multcnd			; save Differential in multiply workspace
	call	Multiply			; multiply Diffential error by K3
	call	Accumulate		; add to previous result

; return corrected control byte

	movf	H_PIDSum,w	; recover control byte into W
	return				; return the byte
	

Multiply
;*****************************************************************
;
;       8 x 8 multiplier routine
;       enter with two 8 bit numbers in multcnd and multplr
;       16 bit result is returned in H_Byte and L_Byte
;       multplr is altered in the process.
;	This is a semi-signed multiply which means that if the
;	multcnd is negative the result will be negative. The
;	multplr is always unsigned.
;
;*****************************************************************
;
	clrf    H_Byte		; clear workspace (L_Byte is self clearing)
	movlw   8		; multiply is 8 accumulate/rotates
	movwf   xCount		; set accumulate/rotate counter
	movf    multcnd,W	; restore multicand
	btfsc	multcnd,7	; is multicand negative?
	subwl	D'0'		; yes - make it positive by two's complimenting
MU10    
	rrf     multplr,f	; test multiplier LSB
	skpnc					; skip accumulate if LSB was zero
	addwf   H_Byte,f	; not zero - add multicand
	rrf     H_Byte,f	; right shift 16 bit result 1 place
	rrf     L_Byte,f	; 
	decfsz  xCount,f	; all 8 accumulate/rotates performed?
	goto    MU10		; no - repeat for next bit

	btfss	multcnd,7	; was multicand negative?
	return			; no - no further processing

	comf	L_Byte,f	; make positive result negative by two's complimenting
	comf	H_Byte,f	; invert all 16 bits...
	movlw	1		; ...and...
	addwf	L_Byte,f	; ...add 1
	skpnc				; adjust MS byte if carry from LS byte
	incf	H_Byte,f	;

	return

Integrate
;*****************************************************************
;
;	Sum the 16 bit result of K2 multiply result with
;	all previous results and add this integration to the PIDSum.
;
;	The integral is always positive but other addends are signed.
;       Determine overflow/underfow by comparing the msb's of the 
;       integral, addend, and addition result as follows:
;
;	Integral, Addend, Result - Conclusion - Action
;	    1       0       0      Overflow     Force Max
;	    0       1       1      Underflow    Force Min
;
;*****************************************************************

	movf	H_Integral,w	; get ms result
	movwf	PIDTemp		; save
	movf	H_Byte,w	; restore ms multiplication result
	addwf	H_Integral,f	; 16 bit accumulate	
	movf	L_Byte,w	; get ls result
	addwf	L_Integral,f	; 16 bit accumulate
	btfsc	STATUS,C	; lower byte addition carry?
	incf	H_Integral,f	; yes - adjust ms byte

; test for addition overflow

	btfss	PIDTemp,7	; test for pre-addition integral msb
	goto	IntegUnder	; zero - check for underflow
	
	btfsc	H_Byte,7	; is addend negative?
	goto	IGAccum		; yes - no overflow

	btfsc	H_Integral,7	; is result positive?
	goto	IGAccum		; no - no overflow
	
	movlw	0xff		; overflow detected...
	movwf	H_Integral	; ... force maximum
	movwf	L_Integral
	goto	IGAccum
	
; Test for addition underflow

IntegUnder
	btfss	H_Byte,7	; is addend positive?
	goto	IGAccum		; yes - no underflow

	btfss	H_Integral,7	; is result negative?
	goto	IGAccum		; no - no underflow
	
	clrf	H_Integral	; underflow detected...
	clrf	L_Integral	; ... force minimum

IGAccum	
; the integral is always positive 
;  accumulate integral and sum then check for over/under flow
;  the accumulation result must be positive

	movf	H_PIDSum,w	; get ms addend
	movwf	PIDTemp		; save
	movf	H_Integral,w	; restore ms integral
	addwf	H_PIDSum,f	; accumulate with sum
	movf	L_Integral,w	; restore ls byte of integral
	addwf	L_PIDSum,f	; sum with ls PIDSum
	btfsc	STATUS,C	; lower byte addition carry?
	incf	H_PIDSum,f	; yes - adjust ms byte

; test for addition overflow

	btfss	H_Integral,7	; test integral msb
	goto	IAUnder		; zero - check for underflow
	
	btfsc	PIDTemp,7	; is addend negative?
	goto	IntegExit	; yes - no overflow

	btfsc	H_PIDSum,7	; is result positive?
	goto	IntegExit	; no - no overflow
	
	movlw	0xff		; overflow detected...
	movwf	H_PIDSum	; ... force maximum
	movwf	L_PIDSum
	goto	IntegExit
	
; Test for addition underflow

IAUnder
	btfss	PIDTemp,7	; is addend positive?
	goto	IntegExit	; yes - no underflow

	btfss	H_PIDSum,7	; is result negative?
	goto	IntegExit	; no - no underflow
	
	clrf	H_PIDSum	; underflow detected...
	clrf	L_PIDSum	; ... force minimum

IntegExit
	return

Accumulate	
;*****************************************************************
;
;	Accumulate the 16 bit result of K3 PID multiply result
;
;	The sum accumulator (PIDSum) is assumed always positive
;
;*****************************************************************

	movf	H_PIDSum,w	; get pre-addition sum ms byte
	movwf	PIDTemp		; save
	movf	H_Byte,w	; get ms multiplication result
	addwf	H_PIDSum,f	; 16 bit accumulate
	movf	L_Byte,w	; get ls result
	addwf	L_PIDSum,f	; 16 bit accumulate
	btfsc	STATUS,C	; lower byte addition carry?
	incf	H_PIDSum,f	; yes - adjust ms byte
	
; test for accumulation overflow

	btfss	PIDTemp,7	; test pre-addition msb
	goto	ACUnder		; zero - check for underflow
	
	btfsc	H_Byte,7	; is addend negative?
	goto	AccumExit	; yes - no overflow

	btfsc	H_PIDSum,7	; is result positive?
	goto	AccumExit	; no - no overflow
	
	movlw	0xff		; overflow detected...
	movwf	H_PIDSum	; ... force maximum
	movwf	L_PIDSum
	goto	AccumExit
	
; Test for addition underflow

ACUnder
	btfss	H_Byte,7	; is addend positive?
	goto	AccumExit	; yes - no underflow

	btfss	H_PIDSum,7	; is result negative?
	goto	AccumExit	; no - no underflow
	
	clrf	H_PIDSum	; underflow detected...
	clrf	L_PIDSum	; ... force minimum

AccumExit
	return

InitPID
;************************************************************************************
;*
;* Initialize PID registers
;*
	movlw	Kp		; initialize PID multipliers
	movwf	K1
	movlw	Ki
	movwf	K2
	movlw	Kd
	movwf	K3
	clrf	DeltaV		; clear accumulators
	clrf	H_Integral
	clrf	L_Integral
	clrf	H_PIDSum
	clrf	L_PIDSum
	return

SetTarget
;************************************************************************
;*
;* take value passed in W and configure the target
;*

	movwf	Target		; set target
	bcf	STATUS,C	; clear carry for rotate
	rrf	Target,f	; convert to 7 bit signed
	
	return
	
	end

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲国产另类av| 日本一区二区电影| 欧美日韩精品一二三区| 欧美亚洲精品一区| 91国产成人在线| 色8久久人人97超碰香蕉987| 从欧美一区二区三区| av一二三不卡影片| 99精品久久99久久久久| 色哟哟日韩精品| 4438x成人网最大色成网站| 日韩一级黄色大片| 久久综合色播五月| 中文字幕在线观看一区二区| 亚洲欧美在线视频| 午夜精品一区二区三区三上悠亚| 蜜臀久久99精品久久久画质超高清 | 欧美调教femdomvk| 久久99精品国产.久久久久| 五月天激情综合| 国产欧美精品国产国产专区| 久久蜜桃av一区精品变态类天堂 | 成人免费视频一区| 亚洲国产中文字幕在线视频综合| 极品销魂美女一区二区三区| 久久97超碰国产精品超碰| 中文字幕在线播放不卡一区| 久久久蜜臀国产一区二区| 一区在线播放视频| 色哟哟在线观看一区二区三区| 国产综合色视频| 国产精品一二一区| 色综合久久中文综合久久97| 精品国产乱码久久久久久牛牛| 老司机精品视频一区二区三区| 国产凹凸在线观看一区二区| 7777女厕盗摄久久久| 经典一区二区三区| 欧美一级午夜免费电影| 国产精品拍天天在线| 精品在线你懂的| 激情文学综合丁香| 91欧美一区二区| 欧美卡1卡2卡| 中文字幕在线播放不卡一区| 国产乱子伦一区二区三区国色天香| 欧美日韩高清一区| 久久国产夜色精品鲁鲁99| 日韩视频一区二区三区| 久久精品av麻豆的观看方式| 亚洲精品一区二区三区在线观看| 捆绑调教一区二区三区| 国产日韩欧美在线一区| 波多野结衣一区二区三区| 亚洲一区影音先锋| 日韩一级欧美一级| 91在线码无精品| 青青青爽久久午夜综合久久午夜 | 欧美日韩久久久| 91在线视频官网| 亚洲欧美日韩成人高清在线一区| 亚洲成精国产精品女| 99re8在线精品视频免费播放| 日韩欧美国产一二三区| 偷拍日韩校园综合在线| 精品第一国产综合精品aⅴ| 一区二区三区欧美日| 午夜欧美在线一二页| 一本色道久久综合亚洲91 | 极品少妇xxxx偷拍精品少妇| 91黄视频在线| 久久电影网站中文字幕| 亚洲日本在线看| 久久欧美一区二区| 91精品国产手机| 99v久久综合狠狠综合久久| 久久精品国产在热久久| 亚洲电影激情视频网站| 亚洲情趣在线观看| 一区二区欧美国产| 精品久久一区二区三区| 欧美一区二区三区视频免费 | 国产亚洲制服色| 在线不卡a资源高清| 欧美性猛交xxxxxx富婆| 日本精品裸体写真集在线观看 | 欧美视频一区二区三区| 成人av在线影院| 成人午夜在线播放| av激情亚洲男人天堂| 成人va在线观看| 91国产福利在线| 欧美色视频在线| 精品久久久久av影院 | 国产伦精品一区二区三区免费| 久久99精品久久久久久国产越南| 久久精品国产99国产| 丁香六月综合激情| 在线精品视频一区二区| 欧美精品一二三| 国产欧美一区二区精品秋霞影院| 欧美国产亚洲另类动漫| 亚洲综合网站在线观看| 日本不卡视频在线观看| 大美女一区二区三区| 欧美夫妻性生活| 国产精品网站一区| 日本强好片久久久久久aaa| 国产91富婆露脸刺激对白| 日本乱人伦aⅴ精品| 精品福利二区三区| 亚洲国产综合在线| 成人黄色一级视频| 精品日韩av一区二区| 玉米视频成人免费看| 国内国产精品久久| 91.麻豆视频| 一区二区理论电影在线观看| 国产91精品精华液一区二区三区| 欧美日韩一级片在线观看| 国产精品不卡在线观看| 琪琪久久久久日韩精品| 欧美午夜精品久久久久久超碰| 国产精品麻豆久久久| 日韩二区三区四区| 正在播放亚洲一区| 日本三级亚洲精品| 欧美一级黄色片| 青青草97国产精品免费观看| 欧美肥妇毛茸茸| 三级成人在线视频| 欧美一区二区福利在线| 日韩精品免费视频人成| 欧美人与性动xxxx| 日韩avvvv在线播放| 欧美电视剧免费观看| 国产主播一区二区| 国产色爱av资源综合区| 成人国产在线观看| 亚洲午夜免费视频| 日韩欧美另类在线| 成人免费视频免费观看| 中文字幕一区二区三区在线观看| 91免费版在线| 偷窥国产亚洲免费视频| 亚洲精品在线一区二区| 成人v精品蜜桃久久一区| 视频在线在亚洲| 国产欧美综合在线| 欧美日韩成人高清| 国产电影一区在线| 图片区日韩欧美亚洲| 久久久综合视频| 欧美午夜电影在线播放| 激情综合色丁香一区二区| 中文字幕日韩av资源站| 欧美一级片在线看| 91网页版在线| 国产一区二区三区电影在线观看| 亚洲欧洲综合另类| 国产欧美日韩激情| 日韩一级大片在线| 欧美视频中文一区二区三区在线观看| 麻豆91在线看| 日本免费新一区视频| 一区二区三区四区国产精品| 2020国产精品自拍| 欧美一区二区三区在线观看视频| 成人aa视频在线观看| 国产精品亚洲人在线观看| 五月婷婷激情综合| 婷婷一区二区三区| 天堂精品中文字幕在线| 一区二区成人在线视频| 亚洲激情五月婷婷| 亚洲综合一二三区| 亚洲成人动漫av| 午夜久久久影院| 男男视频亚洲欧美| 久久精品国产亚洲a| 美女视频黄久久| 国产乱码字幕精品高清av| 国产麻豆精品视频| 99国产精品国产精品久久| 欧美性做爰猛烈叫床潮| 777亚洲妇女| 久久亚洲私人国产精品va媚药| 国产亚洲自拍一区| 亚洲一区二区三区三| 视频一区国产视频| 国产精品77777| 欧美中文字幕一区| 精品日韩一区二区三区| 国产精品久久三| 亚洲成人精品一区| 国产福利视频一区二区三区| 91精品国产综合久久小美女| 欧美成人激情免费网| 6080午夜不卡| 欧美高清激情brazzers|