有个程序,实在看不懂,哪位帮忙看下,帮我详细解释解释
'(
故障代码:
E0:燃气泄露
E1:风机
E2:点火器
E3:小火电磁阀(v1)
E4:大火电磁阀(v2)
E5:残火
E6:燃气超压
E7:意外熄火(保留)
E8:点火失败
E9:漏电
F1:火焰检测线对地短路(保留)
运行代码:
Aa:风机预扫和系统自检
00:正常燃烧
Cc:手动状态 (保留)
')
$regfile = "m16def.dat"
$crystal = 4000000
Ddra = &B000000111
Porta = &B11110110
Ddrb = &B11111111
Portb = &B00000000
Ddrc = &B11011110
Portc = &B00111101
Ddrd = &B00000011
Portd = &B00111100
'/**************************************************************
Config Timer0 = Timer , Prescale = 1024
Enable Timer0
On Ovf0 6s
Tcnt0 = &H06
'/==============================================================
'Config Timer1 = Timer , Prescale = 1024
'Enable Timer1
'On Ovf1 miao
'Timer1 = &H06
'/==============================================================
Config Timer2 = Timer , Prescale = 1024
Enable Timer2
Enable Interrupts
On Ovf2 Led_display
Tcnt2 = &H190
'/==============================================================
Config Adc = Single , Prescaler = Auto , Reference = Avcc
'/**************************************************************
Dim Dh_time As Byte , Dh_isr As Byte '点火相关
Dim Fans_isr As Byte '风机相关
Dim Lou_dian As Word '漏电相关
Dim D_h_q As Byte '点火器相关
Dim Xie_lou As Word '燃气泄露
Dim B As Byte
Dim E_e As Byte
Dim Dh As Word
Dim Fans As Word : Fans = 0
Dim Yu_sao As Word
Dim F_m As Byte '/buzzer
Dim X_l As Word
Dim Y_j As Word
Dim A(14)as Byte , M_1 As Byte , M_2 As Byte
Dim T_2 As Byte
Dim Miao As Byte
Dim Fen As Byte , Fen_1 As Byte , Fen_10 As Byte
Dim Shi As Byte
'/--------------------------------------------------------------
Const On = 1
Const Off = 0
Buzzer Alias Portc.7
'/--------------------------------------------------------------
Waitms 10
Start Timer0
Start Timer2
Restore Daima
For M_1 = 1 To 14
Read A(m_1)
Next M_1
M_1 = 13
M_2 = 13
Waitms 10
'/--------------------------------------------------------------
'/自检
Do
If Pina.4 = 0 Then '/选择风机
If Pind.4 = 1 Then
Incr Fans
Else
Fans = 0
End If
If Fans > 800 Then '/ 风机
M_1 = 2
M_2 = 11
Fans = 800
Else
M_1 = 13
M_2 = 13
End If
If Fans < 800 And Yu_sao > 20 Then Exit Do
Else
Exit Do
End If
Loop
'/--------------------------------------------------------
If Pina.4 = 0 Then Portd.1 = 1 '/FANS
Waitms 100
Do
If Pinc.5 = 1 Then '/漏电
M_1 = 10
M_2 = 11
Portd.1 = 0
Waitms 400
End If
If Pind.5 = 1 Then '/点火器
Incr Dh
Else
Dh = 0
End If
If Dh > 800 Then '/点火器
M_1 = 3
M_2 = 11
Dh = 1000
Waitms 400
Else
End If
If Pind.6 = 0 Then '/苗火阀
M_1 = 4
M_2 = 11
Waitms 400
Else
End If
If Pind.7 = 0 Then '/主火阀
M_1 = 5
M_2 = 11
Waitms 400
Else
End If
If Pinc.0 = 1 Then '/残火
M_1 = 6
M_2 = 11
Waitms 400
Else
End If
If Pind.3 = 1 Then '/燃气压力
M_1 = 7
M_2 = 11
Waitms 400
Else
End If
If M_2 = 13 And M_1 = 13 Then E_e = 12 '/退出循环
If E_e = 12 And Yu_sao > 350 Then Exit Do
If Y_j >= 150 Then Exit Do
Loop
'/HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
If Y_j >= 150 Then
M_1 = 14
M_2 = 14
Portd.1 = 1
Waitms 600
Portd.0 = 1
Waitms 500
Portc.1 = 0
Portc.2 = 0
Portc.4 = 0
Portc.3 = 1
Wait 3
Portc.3 = 0
Waitms 400
Do
Buzzer = 0
Portc.1 = 1
Portc.2 = 1
Portc.3 = 0
Portc.4 = 0
Wait 5
Portd.0 = 0
Buzzer = 1
Waitms 500
M_1 = 14
M_2 = 14
Loop
Else
Porta.2 = 1
Portc.1 = 0
Portc.2 = 1
Portc.3 = 1
Portc.4 = 1
End If
''/==================================================================
'/手动程序
'/主程序
'Portd.1 = 1
'Waitms 300
Portd.0 = 1
Dh_time = 0
Start Adc '/START ADC
Do
If Dh_time < 70 Then '/安全点火时间
Yu_sao = 0
If Pinc.0 = 0 Then Waitms 5
If Pinc.0 = 0 Then
Portd.0 = 1
Portc.2 = 0
Portc.1 = 0
Porta.2 = 1
Portc.3 = 1
Waitms 500
Portc.4 = 0
'Portc.3 = 1
Dh_isr = 0
M_1 = 13
M_2 = 13
Else
Buzzer = 0
Dh_time = 35 '/减少重点火时间
'M_1 = 1
'M_2 = 1
Portd.0 = 0
Portc.4 = 0
Porta.2 = 0
Waitms 800
Portc.3 = 0
'/-------------------------------------------------------------------
If Pina.5 = 1 Then '/电压切换
If Dh_isr > 50 Then '/低压维持
Portc.2 = 1
Portc.1 = 1
Dh_isr = 220
Else
End If
Else '/高压维持
Portc.1 = 0
Portc.2 = 0
End If
'/===================================================================
If Miao => 30 Then '计时
Incr Fen_1
'Porta.2 = Not Porta.2
Miao = 0
Else
End If
If Fen_1 = 25 Then
Incr Fen
Fen_1 = 0
'Porta.2 = Not Porta.2
Else
End If
If Fen = 10 Then
Incr Fen_10
Fen = 0
Else
End If
If Fen_10 = 6 Then
Incr Shi
Fen_10 = 0
If Shi > 9 Then Shi = 0
Else
End If
'/-------------------------------------------------------------------
'/显示
If Miao < 10 Then '/显示"00"
M_1 = 1
M_2 = 1
Else
End If
If Miao > 10 And Miao < 20 Then '/显示"xH"
M_1 = 14
M_2 = Shi + 1
Else
End If
If Miao > 20 And Miao < 30 Then '/显示"xx"
M_1 = Fen + 1
M_2 = Fen_10 + 1
Else
End If
'/====================================================================
End If
Else
Portd.0 = 0
Portc.2 = 1
Portc.3 = 1
Portc.4 = 1
Portc.1 = 0
'Portd.1 = 0
Dh_time = 200
M_1 = 9
M_2 = 11
Waitms 300
'/--------------------------------------------------------------------
If Pinc.0 = 1 Then Waitms 5 '/余火检测
If Pinc.0 = 1 Then
M_1 = 6
M_2 = 11
Waitms 300
Else
End If
'/--------------------------------------------------------------------
If Yu_sao > 3000 Then '/风机后扫
Portd.1 = 0
Else
'Portd.1 = 1
End If
End If
'/-----------------------------------------------------------
Xie_lou = Getadc(7) '/燃气泄露
If X_l > 1400 And Xie_lou > 540 Then Waitms 5
If X_l > 1400 And Xie_lou > 540 Then
Do
M_1 = 1
M_2 = 11
Portd.0 = 0 : Portd.1 = 1 : Porta.2 = 1
Portc.1 = 0 : Portc.2 = 1 : Portc.3 = 1 : Portc.4 = 1
Loop
Else
End If
'/------------------------------------------------------------
If Pinc.5 = 1 Then Waitms 5 '漏电检测
If Pinc.5 = 1 Then
Do
M_1 = 10
M_2 = 11
Portd.0 = 0 : Portd.1 = 0 : Porta.2 = 1
Portc.1 = 0 : Portc.2 = 1 : Portc.3 = 1 : Portc.4 = 1
Loop
Else
End If
'/-----------------------------------------------------------
Loop
End
'/HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
Daima:
Data &H90 , &HFC , &H52 , &H58 , &H3C , &H19 , &H11 , &HF8 , &H10 , &H18
Data &H13 , &H33 , &H30 , &H34
'/===================================================================
6s:
Tcnt0 = &H06
Incr Dh_time
Incr Dh_isr
Incr Yu_sao
Incr X_l
Incr Miao
If X_l > 1400 Then X_l = 1500 '/MQ-2上电延时 1400=90S
If M_1 <= 10 And M_2 = 11 Then '/报警音
Incr F_m
If F_m = 16 Then
Buzzer = Not Buzzer
Elseif F_m = 20 Then
Buzzer = Off
F_m = 0
End If
Else
'Buzzer = Off
End If
If Pina.3 = 0 Then
Incr Y_j
Else
End If
Return
'/===========================================================
'J_sh:
'Timer1 = &H06
'/============================================================
'/LED处理
Led_display:
Tcnt2 = &H3E8
'portc.6 = 1
Incr T_2
Select Case T_2
Case 1
Portb = A(m_1) : Porta.0 = 0 : Porta.1 = 1
Case 2
Portb = A(m_2) : Porta.0 = 1 : Porta.1 = 0
Case Else
Porta.0 = 1 : Porta.1 = 1
T_2 = 0
End Select
Return