智能化控制开关(有延时防止冲击智能继电器开关)
智能化控制开关(有延时防止冲击智能继电器开关)
放大电路图
下面是单片机控制程序
delay_time0 equ 180 ;3t
delay_time1 equ 10 ;10s
delay_time2 equ 5 ;5s
led bit p1.0
byq bit p3.7
jdq0 bit p1.7
jdq1 bit p1.6
jdq2 bit p1.5
jdq3 bit p1.4
jdq4 bit p1.3
ic_err bit 20h.0
use_time0 data 08h
use_time1 data 09h
delay_sum0 data 0ah
delay_sum1 data 0bh
org 0
ljmp reset
org 3h
reti
org 0bh
ajmp tim0
;reti
org 13h
reti
org 01bh
reti
org 23h
reti
Reset: movie,#00h ;关中断
clra
movb,a
movip,a
movpsw,a
movpcon,a
movscon,a
movtcon,a
movtmod,a
movsp,#07h
movp1,#0h
movp3,#7fh
movdptr,#ResNext ;中断清0
pushdpl
pushdph
reti
ResNext:movdptr,#ResRam
pushdpl
pushdph
reti
ResRam: movr0,#7fh
ResRam0:mov@r0,a ;内存清0
djnzr0,ResRam0
ResetEnd:
init: mov sp,#30h ;堆栈指针
mov tmod,#01h
mov ie,#82h
main: mov b,#2
acall delay ;调用延时子程序2秒
clr led
setb byq ;开变压器
setb tr0 ;led闪烁开关
mov b,#delay_time0;调用延时子程序3分钟
acall delay
setb jdq0 ;开继电器1
mov b,#delay_time1
acall delay
setb jdq1 ;开继电器2
mov b,#delay_time1
acall delay
setb jdq2 ;开继电器3
mov b,#delay_time1
acall delay
setb jdq3 ;开继电器4
mov b,#delay_time1
acall delay
setb jdq4 ;开继电器5
wait: jb p3.2,$ ;等待
mov b,#3
acall delay
jb p3.2,wait
clr tr0
clr led
mov ie,#0
mov b,#delay_time2
acall delay
clr jdq4 ;close 1
mov b,#delay_time2
acall delay
clr jdq3 ;close 2
mov b,#delay_time2
acall delay
clr jdq2 ;close 3
mov b,#delay_time2
acall delay
clr jdq1 ;close 4
mov b,#delay_time2
acall delay
clr jdq0 ;close 5
mov b,#150
acall delay
mov b,#150
acall delay
clr byq ;close 变压器
sjmp $ ;停止
delay: mov r6,#0
mov r7,#0
delay1:mov r5,#15
delay0:djnz r7,$
djnz r6,delay0
djnz r5,delay0
djnz b,delay1 ;当b等于1时,延时1秒
ret
tim0: mov th0,#0b1h; ;24M晶振-10ms
mov tl0,#0dfh; ;20000
jb ic_err,tim0_3
djnz delay_sum0,tim0_end
mov delay_sum0,#100 ;1s led闪烁频率
sjmp tim0_2
tim0_3: djnz delay_sum0,tim0_end
mov delay_sum0,#10 ;0.2s led闪烁频率
tim0_2: cpl led
tim0_end:reti
加入微信
获取电子行业最新资讯
搜索微信公众号:EEPW
或用微信扫描左侧二维码