This blog provide Free Circuit Design with or without Microcontroller with a descriptions so any student and electronic hobbies can learn how the circuit work.
Pulse Generator Source Code
; http://freecircuitdesign.blogspot.com/2012/11/multi-fixed-pulse-generator-mfpg.html
;
$MOD51
$NOPAGING
MODE data 40H
kedip data 41h
SW1 EQU P1.2 ; pin 14 as input
SW2 EQU P1.3 ; pin 15 as input
SW3 EQU P1.4 ; pin 16 as input
OUT1 EQU P1.5 ; pin 17 as output
OUT2 EQU P1.6 ; pin 18 as output
OUT3 EQU P1.7 ; pin 19 as output
ORG 00H ; Reset
AJMP MAIN
D200us: MOV r7, #87 ; 200uS delay
D200: DJNZ R7, D200
RET
D800uS: MOV R6, #2 ; 800uS delay
MOV R7, #102
D800: DJNZ R7, D800
DJNZ R6, D800
NOP
RET
PUL_O1: SETB OUT1 ; Pulse for out1, out2 and out3
SETB OUT2
SETB OUT3
ACALL D200US
CLR OUT1
CLR OUT2
CLR OUT3
ACALL D800US
RET
PUL_O2: SETB OUT2 ; Pulse for out2 and out3
SETB OUT3
ACALL D200US
CLR OUT2
CLR OUT3
ACALL D800US
RET
PUL_O3: SETB OUT3 ; Pulse for out3
ACALL D200US
CLR OUT3
ACALL D800US
RET
;--------------------------------
delayms: mov R6,#230
d: nop
nop
djnz R6,d
djnz R7,delayms
ret
MAIN: MOV R7,#200 ; 1 sec delay
ACALL DELAYMS ; for make sure
MOV R7,#200 ; everything
ACALL DELAYMS ; alright
MOV R7,#200
ACALL DELAYMS
MOV R7,#200
ACALL DELAYMS
MOV R7,#200
ACALL DELAYMS
SETB P3.7 ; led on
MOV MODE, #0 ; default mode
mov kedip, #0
CLR OUT1 ; turn to low state
CLR OUT2 ; out1, out2 and out3
CLR OUT3 ;
LOOP: SETB P3.7 ; turn LED on
JB SW1, L1 ; if SW1 not push than jump to L1
SJMP KON1 ; else jump to KON1
L1: JB SW2, L2 ; same as above but this is for SW2
SJMP KON2
L2: JB SW3, LOOP ; same as above but this is for SW3
SJMP KON3
kon2: jnb sw2, $ ; if sw2 on hold state than wait here
MOV R7,#300 ; else move data 300(dec) to register7
ACALL DELAYMS ; call a delay about 300ms (reg7)
jnb sw2, kon2 ; make sure sw2 release completely
ajmp eswe2 ; if sw2 release than jump to sub routine sewe2
kon3: jnb sw3, $ ; same as above but this is for SW3
MOV R7,#300
ACALL DELAYMS
jnb sw3, kon3
ajmp eswe3
KON1: JNB SW2, KE_MODE ; if sw2 on hold than jump ke_mode
KON1A: JB SW1, KE_kedip ; else if sw1 not on hold than jump ke_kedip
JNB SW3, RESET1 ; else if sw3 on hold than RESET to the default mode
SJMP kon1 ; else jump to kon1
RESET1: CLR P3.7 ; turn off LED
MOV MODE, #0 ; mode default 0
MOV KEDIP, #20 ; move data 20 (dec) to register kedip
rs: JNB SW3, $ ; if sw3 on hold than wait here
MOV R7,#500 ; call delay 500mS
ACALL DELAYMS
jnb sw3, rs ; to make sure sw3 release comlpletely
setb p3.7 ; turn on LED again
MOV R7,#100 ; call delay 100mS
ACALL DELAYMS
SJMP KON1 ; Jump to Kon1
KE_MODE: CLR P3.7 ; turn off LED
JNB SW2, $ ; if sw2 on hold, wait here
MOV R7,#500 ; call delay 500mS if sw2 release
ACALL DELAYMS
jnb sw2, ke_mode
SETB P3.7 ; turn on LED
INC MODE ; increase mode data
inc kedip ; increase kedip data
mov r0, mode ; move mode data to register 0
CJNE r0, #13, BLM_O ; compare data on regeiter 0 with 13
MOV MODE, #0 ; if not equal than jump to BLM_O
mov kedip, #0 ; else move data 0 to register MODE and kedip
BLM_O: MOV R7,#100
ACALL DELAYMS ; call delay for 100mS
SJMP KON1A
ke_kedip: jnb sw1, kon1 ; if sw1 still on hold than jump to kon1
MOV R7,#100
ACALL DELAYMS ; call 100mS
jnb sw1, kon1
mov r0, kedip
cjne r0, #0, lagis
sjmp ke_out
lagis: cjne r0, #20, lgg1
sjmp lgl
lgg1: mov r0, mode
lg11: clr p3.7
MOV R7,#150
ACALL DELAYMS
MOV R7,#250
ACALL DELAYMS
SETB p3.7
MOV R7,#150
ACALL DELAYMS
MOV R7,#250
ACALL DELAYMS
djnz r0, lg11
lgl: mov kedip, #0
ajmp loop
KE_OUT: CLR P3.7
mov r7, mode
CJNE r7, #0, SATU ; utk sw1 500p
mov r0, #2
oo1: mov r1, #250
o1: acall pul_o1
djnz r1, o1
djnz r0, oo1
MOV R7,#50
ACALL DELAYMS
ajmp loop
SATU: CJNE r7, #1, DUA ; sw1 2000p
mov r0, #8
oo11: mov r1, #250
o11: acall pul_o1
djnz r1, o11
djnz r0, oo11
MOV R7,#50
ACALL DELAYMS
ajmp loop
DUA: CJNE r7, #2, TIGA ; sw1 3500p
mov r0, #14
oo111: mov r1, #250
o111: acall pul_o1
djnz r1, o111
djnz r0, oo111
MOV R7,#50
ACALL DELAYMS
ajmp loop
TIGA: CJNE r7, #3, EMPAT ; sw1 5000p
mov r0, #20
oo1111: mov r1, #250
o1111: acall pul_o1
djnz r1, o1111
djnz r0, oo1111
MOV R7,#50
ACALL DELAYMS
ajmp loop
EMPAT: CJNE r7, #4, LIMA ; 6500p
mov r0, #26
oo11111: mov r1, #250
o11111: acall pul_o1
djnz r1, o11111
djnz r0, oo11111
MOV R7,#50
ACALL DELAYMS
ajmp loop
LIMA: CJNE r7, #5, ENAM ; 8000p
mov r0, #32
oo111111: mov r1, #250
o111111: acall pul_o1
djnz r1, o111111
djnz r0, oo111111
MOV R7,#50
ACALL DELAYMS
ajmp loop
ENAM: CJNE r7, #6, TUJUH ; 10000p
mov r0, #40
oo1111111: mov r1, #250
o1111111: acall pul_o1
djnz r1, o1111111
djnz r0, oo1111111
MOV R7,#50
ACALL DELAYMS
ajmp loop
TUJUH: CJNE r7, #7, DELAPAN ; o1=500 o2=1000 o3=1500
mov r0, #2
oo2: mov r1, #250
o2: acall pul_o1
djnz r1, o2
djnz r0, oo2
mov r0, #2
oo21: mov r1, #250
o21: acall pul_o2
djnz r1, o21
djnz r0, oo21
mov r0, #2
oo211: mov r1, #250
o211: acall pul_o3
djnz r1, o211
djnz r0, oo211
MOV R7,#50
ACALL DELAYMS
ajmp loop
DELAPAN: CJNE r7, #8, SEMBILAN ; o1=5000 p2=5500 o3= 6000
mov r0, #20
oo2a: mov r1, #250
o2a: acall pul_o1
djnz r1, o2a
djnz r0, oo2a
mov r0, #2
oo21a: mov r1, #250
o21a: acall pul_o2
djnz r1, o21a
djnz r0, oo21a
mov r0, #2
oo211a: mov r1, #250
o211a: acall pul_o3
djnz r1, o211a
djnz r0, oo211a
MOV R7,#50
ACALL DELAYMS
ajmp loop
SEMBILAN: CJNE r7, #9, SEPULUH ; o1=9500 o2=10000 o3=10500
mov r0, #38
oo2aa: mov r1, #250
o2aa: acall pul_o1
djnz r1, o2aa
djnz r0, oo2aa
mov r0, #2
oo21aa: mov r1, #250
o21aa: acall pul_o2
djnz r1, o21aa
djnz r0, oo21aa
mov r0, #2
oo211aa: mov r1, #250
o211aa: acall pul_o3
djnz r1, o211aa
djnz r0, oo211aa
MOV R7,#50
ACALL DELAYMS
ajmp loop
SEPULUH: CJNE r7, #10, SEBELAS ; 100.000 x3
mov r2, #2
ooos: mov r0, #200
oos: mov r1, #250
os: acall pul_o1
djnz r1, os
djnz r0, oos
djnz r2, ooos
MOV R7,#50
ACALL DELAYMS
ajmp loop
SEBELAS: CJNE r7, #11, DUABELAS ; 400.000 x3
mov r2, #8
ooos1: mov r0, #200
oos1: mov r1, #250
os1: acall pul_o1
djnz r1, os1
djnz r0, oos1
djnz r2, ooos1
MOV R7,#50
ACALL DELAYMS
ajmp loop
DUABELAS: CJNE r7, #12, keluar
mov r2, #10
ooos11: mov r0, #200
oos11: mov r1, #250
os11: acall pul_o1
djnz r1, os11
djnz r0, oos11
djnz r2, ooos11
mov r2, #10
ooos12: mov r0, #200
oos12: mov r1, #250
os12: acall pul_o2
djnz r1, os12
djnz r0, oos12
djnz r2, ooos12
mov r2, #10
ooos121: mov r0, #200
oos121: mov r1, #250
os121: acall pul_o3
djnz r1, os121
djnz r0, oos121
djnz r2, ooos121
MOV R7,#50
ACALL DELAYMS
keluar: ajmp loop
eswe2: CLR P3.7
mov r7, mode
CJNE r7, #0, SATU5 ; utk sw2 1000p
mov r0, #4
oo15: mov r1, #250
o15: acall pul_o1
djnz r1, o15
djnz r0, oo15
MOV R7,#50
ACALL DELAYMS
ajmp loop
SATU5: CJNE r7, #1, DUA5 ; sw2 2500p
mov r0, #10
oo115: mov r1, #250
o115: acall pul_o1
djnz r1, o115
djnz r0, oo115
MOV R7,#50
ACALL DELAYMS
ajmp loop
DUA5: CJNE r7, #2, TIGA5 ; sw2 4000p
mov r0, #16
oo1115: mov r1, #250
o1115: acall pul_o1
djnz r1, o1115
djnz r0, oo1115
MOV R7,#50
ACALL DELAYMS
ajmp loop
TIGA5: CJNE r7, #3, EMPAT5 ; sw2 55000p
mov r0, #22
oo11115: mov r1, #250
o11115: acall pul_o1
djnz r1, o11115
djnz r0, oo11115
MOV R7,#50
ACALL DELAYMS
ajmp loop
EMPAT5: CJNE r7, #4, LIMA5 ; 7000p
mov r0, #28
oo111115: mov r1, #250
o111115: acall pul_o1
djnz r1, o111115
djnz r0, oo111115
MOV R7,#50
ACALL DELAYMS
ajmp loop
LIMA5: CJNE r7, #5, ENAM5 ; 8500p
mov r0, #34
oo1111115: mov r1, #250
o1111115: acall pul_o1
djnz r1, o1111115
djnz r0, oo1111115
MOV R7,#50
ACALL DELAYMS
ajmp loop
ENAM5: CJNE r7, #6, TUJUH5 ; 10000p
mov r0, #80
oo11111115: mov r1, #250
o11111115: acall pul_o1
djnz r1, o11111115
djnz r0, oo11111115
MOV R7,#50
ACALL DELAYMS
ajmp loop
TUJUH5: CJNE r7, #7, DELAPAN5 ; o1=500 o2=1000 o3=1500
mov r0, #8
oo25: mov r1, #250
o25: acall pul_o1
djnz r1, o25
djnz r0, oo25
mov r0, #2
oo215: mov r1, #250
o215: acall pul_o2
djnz r1, o215
djnz r0, oo215
mov r0, #2
oo2115: mov r1, #250
o2115: acall pul_o3
djnz r1, o2115
djnz r0, oo2115
MOV R7,#50
ACALL DELAYMS
ajmp loop
DELAPAN5: CJNE r7, #8, SEMBILAN5 ; o1=5000 p2=5500 o3= 6000
mov r0, #26
oo2a5: mov r1, #250
o2a5: acall pul_o1
djnz r1, o2a5
djnz r0, oo2a5
mov r0, #2
oo21a5: mov r1, #250
o21a5: acall pul_o2
djnz r1, o21a5
djnz r0, oo21a5
mov r0, #2
oo211a5: mov r1, #250
o211a5: acall pul_o3
djnz r1, o211a5
djnz r0, oo211a5
MOV R7,#50
ACALL DELAYMS
ajmp loop
SEMBILAN5: CJNE r7, #9, SEPULUH5 ; o1=9500 o2=10000 o3=10500
mov r0, #44
oo2aa5: mov r1, #250
o2aa5: acall pul_o1
djnz r1, o2aa5
djnz r0, oo2aa5
mov r0, #2
oo21aa5: mov r1, #250
o21aa5: acall pul_o2
djnz r1, o21aa5
djnz r0, oo21aa5
mov r0, #2
oo211aa5: mov r1, #250
o211aa5: acall pul_o3
djnz r1, o211aa5
djnz r0, oo211aa5
MOV R7,#50
ACALL DELAYMS
ajmp loop
SEPULUH5: CJNE r7, #10, SEBELAS5 ; 100.000 x3
mov r2, #4
ooos5: mov r0, #200
oos5: mov r1, #250
os5: acall pul_o1
djnz r1, os5
djnz r0, oos5
djnz r2, ooos5
MOV R7,#50
ACALL DELAYMS
ajmp loop
SEBELAS5: CJNE r7, #11, DUABELAS5 ; 400.000 x3
mov r2, #10
ooos15: mov r0, #200
oos15: mov r1, #250
os15: acall pul_o1
djnz r1, os15
djnz r0, oos15
djnz r2, ooos15
MOV R7,#50
ACALL DELAYMS
ajmp loop
DUABELAS5: CJNE r7, #12, keluar5
mov r2, #20
ooos115: mov r0, #200
oos115: mov r1, #250
os115: acall pul_o1
djnz r1, os115
djnz r0, oos115
djnz r2, ooos115
MOV R7,#50
ACALL DELAYMS
keluar5: ajmp loop
eswe3: CLR P3.7
mov r7, mode
CJNE r7, #0, SATU53 ; utk sw3 1500p
mov r0, #6
oo153: mov r1, #250
o153: acall pul_o1
djnz r1, o153
djnz r0, oo153
MOV R7,#50
ACALL DELAYMS
ajmp loop
SATU53: CJNE r7, #1, DUA53 ; sw3 2500p
mov r0, #12
oo1153: mov r1, #250
o1153: acall pul_o1
djnz r1, o1153
djnz r0, oo1153
MOV R7,#50
ACALL DELAYMS
ajmp loop
DUA53: CJNE r7, #2, TIGA53 ; sw2 4000p
mov r0, #18
oo11153: mov r1, #250
o11153: acall pul_o1
djnz r1, o11153
djnz r0, oo11153
MOV R7,#50
ACALL DELAYMS
ajmp loop
TIGA53: CJNE r7, #3, EMPAT53 ; sw2 55000p
mov r0, #24
oo853: mov r1, #250
o853: acall pul_o1
djnz r1, o853
djnz r0, oo853
MOV R7,#50
ACALL DELAYMS
ajmp loop
EMPAT53: CJNE r7, #4, LIMA53 ; 7000p
mov r0, #30
oo953: mov r1, #250
o953: acall pul_o1
djnz r1, o953
djnz r0, oo953
MOV R7,#50
ACALL DELAYMS
ajmp loop
LIMA53: CJNE r7, #5, ENAM53 ; 8500p
mov r0, #36
oo111153: mov r1, #250
o111153: acall pul_o1
djnz r1, o111153
djnz r0, oo111153
MOV R7,#50
ACALL DELAYMS
ajmp loop
ENAM53: CJNE r7, #6, TUJUH53 ; 10000p
mov r0, #120
oo253a: mov r1, #250
o253a: acall pul_o1
djnz r1, o253a
djnz r0, oo253a
MOV R7,#50
ACALL DELAYMS
ajmp loop
TUJUH53: CJNE r7, #7, DELAPAN53 ; o1=500 o2=1000 o3=1500
mov r0, #14
oo253: mov r1, #250
o253: acall pul_o1
djnz r1, o253
djnz r0, oo253
mov r0, #2
oo2153: mov r1, #250
o2153: acall pul_o2
djnz r1, o2153
djnz r0, oo2153
mov r0, #2
oo21153: mov r1, #250
o21153: acall pul_o3
djnz r1, o21153
djnz r0, oo21153
MOV R7,#50
ACALL DELAYMS
ajmp loop
DELAPAN53: CJNE r7, #8, SEMBILAN53 ; o1=5000 p2=5500 o3= 6000
mov r0, #32
oo2a53: mov r1, #250
o2a53: acall pul_o1
djnz r1, o2a53
djnz r0, oo2a53
mov r0, #2
oo21a53: mov r1, #250
o21a53: acall pul_o2
djnz r1, o21a53
djnz r0, oo21a53
mov r0, #2
oo211a53: mov r1, #250
o211a53: acall pul_o3
djnz r1, o211a53
djnz r0, oo211a53
MOV R7,#50
ACALL DELAYMS
ajmp loop
SEMBILAN53: CJNE r7, #9, SEPULUH53 ; o1=9500 o2=10000 o3=10500
mov r0, #50
oo2aa53: mov r1, #250
o2aa53: acall pul_o1
djnz r1, o2aa53
djnz r0, oo2aa53
mov r0, #2
oo21aa53: mov r1, #250
o21aa53: acall pul_o2
djnz r1, o21aa53
djnz r0, oo21aa53
mov r0, #2
oo211aa53: mov r1, #250
o211aa53: acall pul_o3
djnz r1, o211aa53
djnz r0, oo211aa53
MOV R7,#50
ACALL DELAYMS
ajmp loop
SEPULUH53: CJNE r7, #10, SEBELAS53 ; 100.000 x3
mov r2, #6
ooos53: mov r0, #200
oos53: mov r1, #250
os53: acall pul_o1
djnz r1, os53
djnz r0, oos53
djnz r2, ooos53
MOV R7,#50
ACALL DELAYMS
ajmp loop
SEBELAS53: CJNE r7, #11, DUABELAS53 ; 400.000 x3
mov r2, #6
ooos153: mov r0, #200
oos153: mov r1, #250
os153: acall pul_o1
djnz r1, os153
djnz r0, oos153
djnz r2, ooos153
mov r2, #8
ooos1533: mov r0, #200
oos1533: mov r1, #250
os1533: acall pul_o2
djnz r1, os1533
djnz r0, oos1533
djnz r2, ooos1533
mov r2, #10
ooos1537: mov r0, #200
oos1537: mov r1, #250
os1537: acall pul_o3
djnz r1, os1537
djnz r0, oos1537
djnz r2, ooos1537
MOV R7,#50
ACALL DELAYMS
ajmp loop
DUABELAS53: CJNE r7, #12, keluar538
mov r2, #40
ooos11538: mov r0, #200
oos11538: mov r1, #250
os11538: acall pul_o1
djnz r1, os11538
djnz r0, oos11538
djnz r2, ooos11538
MOV R7,#50
ACALL DELAYMS
keluar538: ajmp loop
END
Subscribe to:
Posts (Atom)
No comments:
Post a Comment