📄 detect.asm
字号:
;******************************************************
;name:mndetect
;function:用于各种A/D检测的切换
;input:
;output:
;register:
;*******************************************************
mndetect:
jb1 stoprunflag,mndetect90
jb0 operateflag,mndetect90 ;工作状态下,开启检测
jb1 abnormalvoltfalg,mndetect80 ;市电电压不正常只检测电压
jb0 havecookerflag,mndetect90 ;=1:锅符合,开始工作
jb0 cyclestartflag,mndetect90 ;=1:开始一个循环的检测
;----
mndetect80:
jb1 volADCflag,voltagedetect ;电压检测
jb1 abnormalvoltfalg,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
mov_ ADCcnt,#4
clr ADCvaluel
clr ADCvalueh
;-----
voltagedetect70:
call mnADconvert
ret
;-------------------------
;取出AD值,进行比较
voltagedetect80:
;-----
mov_ ADCvolbufl,ADCvaluel
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
mov_ ADCcnt,#4
clr ADCvaluel
clr ADCvalueh
;-----
currentdetect70:
call mnADconvert
ret
;-------------------------------
;取出AD值,进行比较
currentdetect80:
;-----
mov_ ADCcurbufl,ADCvaluel
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)
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
mov_ ADCcnt,#4
clr ADCvaluel
clr ADCvalueh
;-----
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 Igbttempdetect80 ;没有超温
bset overtempflag
;-----
mov_ seg2buf,#Errorvalue2
mov_ seg1buf,#Errorvalue
bset malfunctionflag
ret
;-----
Igbttempdetect80:
bclr overtempflag
;-----
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
mov_ ADCcnt,#4
clr ADCvaluel
clr ADCvalueh
;-----
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
;-----
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 ptcout
bclr fpwm1out
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,#10
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 abnormalvoltfalg
jmp cookercheck90 ;市电电压不正常
b0bts0 stopheatflag
jmp cookercheck90 ;间歇加热停止时,不检测锅
b0bts0 checkcookerflag
jmp cookercheck80
b0bts0 detecttimeflag
jmp cookercheck70
;------------------------
bset detecttimeflag
bclr checkingflag
bclr havecookerflag
bclr pulsetimeflag
bclr ADCstartflag
bclr ADCendflag
mov_ pulsetimer,#200 ;工作状态下,1秒钟检测一次
;------
mov_ tc1r,#cookerpwmvalue ;发试探信号,检测锅
bset fp01ien
bset fpwm1out
bset ftc1enb
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
mov_ ADCcnt,#4
clr ADCvaluel
clr ADCvalueh
;-----
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 checktimeflag
jmp checkingtime
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -