📄 detect.asm
字号:
;******************************************************
;name:mndetect
;function:用于各种A/D检测的切换
;input:
;output:
;register:
;*******************************************************
mndetect:
jb0 operateflag,mndetect90 ;工作状态下,开启检测
jb1 volADCflag,voltagedetect ;电压检测
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 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_ var1,#4
clr ADCvaluel
clr ADCvalueh
;-----
voltagedetect70:
call mnADconvert
ret
;-------------------------
;取出AD值,进行比较
voltagedetect80:
bclr volADCflag
bset curADCflag
bclr IgbtADCflag
bclr cookerADCflag
bclr ADCstartflag
bclr ADCendflag
;-----
mov_ temp0,ADCvolbufl
mov_ temp1,ADCvolbufh
call mnpwmpulseset
;-----
voltagedetect90:
ret
;******************************************************
;name:currentdetect
;function:用于检测负载电流
;input:
;output:
;register:temp0,temp1
;*******************************************************
currentdetect:
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_ var1,#4
clr ADCvaluel
clr ADCvalueh
;-----
currentdetect70:
call mnADconvert
ret
;-------------------------------
;取出AD值,进行比较
currentdetect80:
;-----
bclr volADCflag
bclr curADCflag
bset IgbtADCflag
bclr cookerADCflag
bclr ADCstartflag
bclr ADCendflag
;-----
mov_ temp0,ADCcurbufl
mov_ temp1,ADCcurbufh
call mnpwmpulseset
;-----
currentdetect90:
ret
;******************************************************
;name:Igbttempdetect
;function:用于检测IGBT温度
;input:
;output:
;register:temp0,temp1
;*******************************************************
Igbttempdetect:
b0bts0 ADCendflag
jmp Igbttempdetect80
b0bts0 ADCstartflag
jmp Igbttempdetect70
;-----
bset ADCstartflag
mov a,#04h
mov p4con,a ;isolate an2
mov a,#02h
mov adm,a ;enable an2
mov_ var1,#4
clr ADCvaluel
clr ADCvalueh
;-----
Igbttempdetect70:
call mnADconvert
ret
;-----
;取出AD值,进行比较
Igbttempdetect80:
;-----
bclr volADCflag
bclr curADCflag
bclr IgbtADCflag
bset cookerADCflag
bclr ADCstartflag
bclr ADCendflag
;-----
mov_ temp0,#ADCIGBTvalueL
mov_ temp1,#ADCIGBTvalueH
;-----
mov a,ADCvaluel
sub a,temp0
mov a,ADCvalueh
sbc a,temp1 ;ADCvalue-temp
b0bts1 fc
jmp Igbttempdetect90 ;没有超温
bset overtempflag
;-----
Igbttempdetect90:
ret
;******************************************************
;name:cookertempdetect
;function:用于检测锅底的温度
;input:
;output:
;register:temp0,temp1
;*******************************************************
cookertempdetect:
b0bts0 ADCendflag
jmp cookertempdetect80
b0bts0 ADCstartflag
jmp cookertempdetect70
;-----
bset ADCstartflag
mov a,#8h
mov p4con,a ;isolate an3
mov a,#03h
mov adm,a ;enable an3
mov_ var1,#4
clr ADCvaluel
clr ADCvalueh
;-----
cookertempdetect70:
call mnADconvert
ret
;-----
;取出AD值,进行比较
cookertempdetect80:
;-----
bset volADCflag
bclr curADCflag
bclr IgbtADCflag
bclr cookerADCflag
;-----
cookertempdetect90:
ret
;**********************************************
;Name :cookercheck
;Function:无锅具、锅具材料不合、小物件检测
;Input :
;Output :
;Register Used:
;***********************************************
cookercheck:
;-----
cookercheck90:
ret
;**********************************************
;Name :mnADconvert
;Function:A/D转换四次,然求四次的平均值
;Input :
;Output :
;Register Used:var1
;***********************************************
mnADconvert:
;// mov_ var1,#4
;// clr ADCvaluel
;// clr ADCvalueh
b0bset fgchs ;enable ain
b0bset fadenb ;enable ad
call delay100us ;stable ad circuit
;----
convert_again:
b0bset fads ;start convert
waitadchigh:
b0bts1 feoc ;check finish convert or not
jmp waitadchigh
bclr feoc
;----
mov a,adr
and a,#0fh
mov ADCtemp,a
swap adb
and a,#0f0h
or a,ADCtemp
add ADCvaluel,a
swap adb
and a,#0fh
adc ADCvalueh,a
decms var1
jmp convert_again ;check again
;----
bset ADCendflag ;set A/D convert over
b0bclr fgchs ;disable ain
b0bclr fadenb ;disable ad
clr p4con ;release AIN pin
;----
bclr fc
rrcm ADCvalueh
rrcm ADCvaluel
;---
bclr fc
rrcm ADCvalueh
rrcm ADCvaluel ;AD/4
ret
;**********************************************
;Name :mnpwmpulseset
;Function:pwm adjust
;Input :
;Output :
;Register Used:temp0,temp1
;***********************************************
mnpwmpulseset:
mov a,ADCvaluel
sub a,temp0
mov a,ADCvalueh
sbc a,temp1 ;ADCvalue-temp
b0bts1 fc
jmp incvolpwm ;<
;----- ;>
mov a,pwmpulsebuf ;dec pwm pulse width
b0bts0 fz
jmp sendvolvalue
decms pwmpulsebuf
nop
jmp sendvolvalue
;----
incvolpwm:
mov a,pwmpulsebuf
sub a,#31
b0bts0 fc
jmp beyondrange
incms pwmpulsebuf
nop
jmp sendvolvalue
;----
beyondrange:
mov_ pwmpulsebuf,#31
;----
sendvolvalue:
mov_ tc1c,pwmpulsebuf
ret
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -