⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 detect.asm

📁 应用松翰母体写的一款电磁炉
💻 ASM
📖 第 1 页 / 共 2 页
字号:
;******************************************************
;name:mndetect
;function:用于各种A/D检测的切换
;input:
;output:
;register:
;*******************************************************
mndetect:
	jb1	stoprunflag,mndetect90
	jb0	operateflag,mndetect90		;工作状态下,开启检测
	jb1	abnormalvoltflag,mndetect80	;市电电压不正常只检测电压
	jb0	havecookerflag,mndetect90	;=1:锅符合,开始工作
	jb0	cyclestartflag,mndetect90	;=1:开始一个循环的检测
;----
mndetect80:
	jb1	volADCflag,voltagedetect    	;电压检测
	jb1	abnormalvoltflag,mndetect90	;市电电压不正常退出检测
	jb1	curADCflag,currentdetect    	;电流检测 
	jb1	IgbtADCflag,Igbttempdetect  	;IGBT温度检测 
	jb1	cookerADCflag,cookertempdetect	;锅底温度检测
;-----
;强制纠错
	bset	volADCflag
	bclr	ADCstartflag
	bclr	ADCendflag
;-----
mndetect90:
	ret

;******************************************************
;name:voltagedetect
;function:用于电压检测(包括市电电压过压、欠压检测)
;input:
;output:
;register:temp0,temp1
;*******************************************************
voltagedetect:
	b0bts0	malfunctionflag
	jmp	voltagedetect90	;有故障,退出
	b0bts0	ADCendflag
	jmp	voltagedetect80
	b0bts0	ADCstartflag
	jmp	voltagedetect70
;-----
	bset	ADCstartflag
	mov	a,#01h
	mov	p4con,a		;isolate an0
	mov	a,#00h
	mov	adm,a		;enable an0
	call	initADCbuf
;-----
voltagedetect70:
	call	mnADconvert
	ret
;-------------------------
;取出AD值,进行比较
voltagedetect80:
;-----
	mov	a,ADCvaluel
	and	a,#0f0h
	mov	ADCvolbufl,a
	mov_	ADCvolbufh,ADCvalueh	;push voltage ADC value
;-----
	bclr	volADCflag
	bset	curADCflag
	bclr	IgbtADCflag
	bclr	cookerADCflag
	bclr	ADCstartflag
	bclr	ADCendflag
	bclr	secondflag
;-----
;先市电过压、欠压检测
	call	voltageanalyse

voltagedetect90:
	ret
	
;******************************************************
;name:currentdetect
;function:用于检测负载电流
;input:
;output:
;register:temp0,temp1
;*******************************************************
currentdetect:
	b0bts0	malfunctionflag
	jmp	currentdetect90	;有故障,退出
	b0bts0	ADCendflag
	jmp	currentdetect80
	b0bts0	ADCstartflag
	jmp	currentdetect70
;-----
	bset	ADCstartflag
	mov	a,#02h
	mov	p4con,a		;isolate an1
	mov	a,#01h
	mov	adm,a		;enable an1
	call	initADCbuf
;-----
currentdetect70:
	call	mnADconvert
	ret
;-------------------------------
;取出AD值,进行比较
currentdetect80:
;-----
	mov	a,ADCvaluel
	and	a,#0f0h
	mov	ADCcurbufl,a
	mov_	ADCcurbufh,ADCvalueh
;-----
	bclr	volADCflag
	bclr	curADCflag
	bset	IgbtADCflag
	bclr	cookerADCflag
	bclr	ADCstartflag
	bclr	ADCendflag
;-----
;先过流检测
	call	currentanalyse
;-----
;pwm脉宽调整(功率P=U*I转化为
;功率P=ADCvolbufh,ADCvolbuflxADCcurbufh,ADCcurbufl)
	b0bts1	heattimeflag
	jmp	currentdetect90	;200ms调整一次PWM值
	call	ADC16x16bit
	call	mnpwmpulseset	
;-----
currentdetect90:
	ret
	
;******************************************************
;name:Igbttempdetect
;function:用于检测IGBT温度
;input:
;output:
;register:temp0,temp1
;*******************************************************
Igbttempdetect:
	b0bts0	malfunctionflag
	jmp	currentdetect90	;有故障,退出
	b0bts0	ADCendflag
	jmp	Igbttempdetect70
	b0bts0	ADCstartflag
	jmp	Igbttempdetect60
;-----
	bset	ADCstartflag
	mov	a,#08h
	mov	p4con,a		;isolate an3
	mov	a,#03h
	mov	adm,a		;enable an3
	call	initADCbuf
;-----
Igbttempdetect60:
	call	mnADconvert
	ret
;-----
;取出AD值,进行比较
Igbttempdetect70:
;-----
	bclr	volADCflag
	bclr	curADCflag
	bclr	IgbtADCflag
	bset	cookerADCflag
	bclr	ADCstartflag
	bclr	ADCendflag
;-----
;温度传感器开、短路分析
	call	sensoranalyse
;-----
	b0bts0	malfunctionflag
	jmp	Igbttempdetect90
	mov_	temp0,#ADCIGBTvalueL
	mov_	temp1,#ADCIGBTvalueH
;-----
;IGBT过热分析
	mov	a,ADCvaluel
	sub	a,temp0
	mov	a,ADCvalueh
	sbc	a,temp1		 ;ADCvalue-temp
	b0bts1	fc
	jmp	Igbttempdetect90 ;没有超温
;-----
	mov_	seg2buf,#Errorvalue2
	mov_	seg1buf,#Errorvalue
	bset	malfunctionflag
;-----
Igbttempdetect90:
	ret
	
;******************************************************
;name:cookertempdetect
;function:用于检测锅底的温度
;input:
;output:
;register:temp0,temp1
;*******************************************************
cookertempdetect:
	b0bts0	malfunctionflag
	jmp	currentdetect90	;有故障,退出
	b0bts0	ADCendflag
	jmp	cookertempdetect70
	b0bts0	ADCstartflag
	jmp	cookertempdetect60
;-----
	bset	ADCstartflag
	mov	a,#04h
	mov	p4con,a		;isolate an2
	mov	a,#02h
	mov	adm,a		;enable an2
	call	initADCbuf
;-----
cookertempdetect60:
	call	mnADconvert
	ret
;-----
;取出AD值,进行比较
cookertempdetect70:
;-----
	bset	onecycleflag
	bset	volADCflag
	bclr	cyclestartflag
	bclr	curADCflag
	bclr	IgbtADCflag
	bclr	cookerADCflag
	bclr	ADCstartflag
	bclr	ADCendflag
;-----
;温度传感器开、短路分析
	call	sensoranalyse
;-----
	b0bts0	malfunctionflag
	jmp	cookertempdetect90
;-----
;过热分析
	call	hotestanalyse
;-----
;干烧分析
;//	call	nowateranalyse
;-----
	b0bts0	malfunctionflag
	jmp	cookertempdetect90
;-----
;温度控制
	b0bts0	overtempflag
	jmp	cookertempdetect80
;-----
	mov_	temp0,ADCtempbufl
	mov_	temp1,ADCtempbufh
;-----
	mov	a,ADCvaluel
	sub	a,temp0
	mov	a,ADCvalueh
	sbc	a,temp1		   ;ADCvalue-temp
	b0bts1	fc
	jmp	cookertempdetect90 ;没有超温
;-----
;在哪一功能下
	mov	a,flag3
	and	a,#00011000b
	b0bts0	fz
	jmp	stopheat
	b0bts1	fourthstepflag
	jmp	cookertempdetect50
;-----------------------
stopheat:
	bset	overtempflag
	bclr	fpwm1out
	bclr	ftc1out
	bclr	ftc1enb		   ;stop t1 pwm
	bclr	ptpwm	
	ret	
;----------------------
cookertempdetect50:
	bset	tempcomeflag
	ret
;----------------------
cookertempdetect80:	
;-----
	mov_	temp0,ADCtempbufl  ;超温后,温度往下降个10点再加热
	mov_	temp1,ADCtempbufh
	mov	a,temp0
	sub	a,#51h
	mov	temp0,a
	mov	a,#0	
	mov	temp2,a
	mov	a,temp1
	sbc	a,temp2	
	mov	temp1,a
;-----
	mov	a,ADCvaluel
	sub	a,temp0
	mov	a,ADCvalueh
	sbc	a,temp1		   ;ADCvalue-temp
	b0bts0	fc
	jmp	cookertempdetect90
;---
	bclr	overtempflag
	bclr	Igbtstartupflag
;-----
cookertempdetect90:
	ret
	
;**********************************************
;Name	:cookercheck
;Function:无锅具、锅具材料不合、小物件检测
;Input  :
;Output	:
;Register Used:var3,var4
;***********************************************
cookercheck:
;-----
	b0bts1	operateflag
	jmp	cookercheck90
	b0bts0	stoprunflag
	jmp	cookercheck90
	b0bts0	malfunctionflag
	jmp	cookercheck90	;其他故障
	b0bts0	abnormalvoltflag
	jmp	cookercheck90	;市电电压不正常
	b0bts0	stopheatflag
	jmp	cookercheck90	;间歇加热停止时,不检测锅
	b0bts0	checkcookerflag
	jmp	cookercheck80
	b0bts0	detecttimeflag
	jmp	cookercheck70
;------------------------
	bset	detecttimeflag
	bclr	checkingflag
	bclr	havecookerflag
	bclr	ADCstartflag
	bclr	ADCendflag
	bset	fp01ien
	ret
;-----------------
cookercheck70:
;----
	b0bts0	ADCendflag
	jmp	cookercheckend
	b0bts0	ADCstartflag
	jmp	cookercheckagain
	bset	ADCstartflag
	mov	a,#02h
	mov	p4con,a		;isolate an1
	mov	a,#01h
	mov	adm,a		;enable an1
	call	initADCbuf
;-----
cookercheckagain:
	call	mnADconvert
	ret
;-----
cookercheckend:
	bset	cyclestartflag
	bset	checkcookerflag
	bclr	detecttimeflag
	bclr	ADCstartflag
	bclr	ADCendflag
	bclr	secondflag
	mov_	var3,#ADCnocookerl
	mov_	var4,#ADCnocookerh
;-----
;比较参数
	mov	a,ADCvaluel
	sub	a,var3
	mov	a,ADCvalueh
	sbc	a,var4
	b0bts0	fc
	jmp	havecookerdeal	
;-----
	b0bts0	abcookerflag
	jmp	waitcookernormal
;---------------
;无锅处理
nocookerin:
	bclr	noneedflag
	b0bts0	checktimeflag
	jmp	checkingtime
	bset	checktimeflag
	mov_	timer1m,#60
	bclr	oneminuteflag
	bclr	havecookerflag
;//	call	mnstopheat
;-----
	call	pushsegvalue
	mov_	seg1buf,#Errorvalue
	mov_	seg2buf,#Errorvalue1
	bset	nocookerflag
	bclr	startflag
	ret
;------
checkingtime:
	b0bts1	oneminuteflag
	jmp	cookercheck90
;----
	bclr	oneminuteflag
	bset	stoprunflag
	bset	buzzerflag
	mov_	buzzercnt,#120	;蜂鸣器鸣叫一分钟后关机
;-----
cookercheck60:
	call	mnstopheat
	ret
;-----------------
havecookerdeal:
;有锅处理
	bset	havecookerflag
	bset	abcookerflag
	bset	noneedflag
	bclr	Igbtstartupflag
	bclr	checktimeflag
	bclr	secondflag
;-----
	b0bts1	nocookerflag
	jmp	cookercheck90
	bclr	nocookerflag
	bclr	buzzerflag
	clr	buzzercnt		;解除报警
	mov_	pwmpulsebuf,#initpwmvalue
	call	popsegvalue
	ret	
;------
waitcookernormal:
	mov_	var3,#ADCnocooker1
	mov_	var4,#ADCnocooker2
;-----
;比较参数
	mov	a,ADCvaluel
	sub	a,var3
	mov	a,ADCvalueh
	sbc	a,var4
	b0bts0	fc
	jmp	ashavecooker
	bclr	abcookerflag
	jmp	nocookerin
;----
ashavecooker:
	bset	havecookerflag
	ret	
;------------------------
cookercheck80:
	b0bts1	onecycleflag
	jmp	cookercheck90
;-----
	bclr	onecycleflag	
	bclr	checkcookerflag

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -