Teste Teste Teste Teste Teste

Teste Teste Teste Teste Teste Teste Teste Teste Teste Teste Teste Teste Teste Teste Teste Teste Teste Teste Teste Teste Teste Teste Teste Teste Teste Teste Teste Teste Teste Teste

PIC16F84 LED mostram quatro modos de 8 prótons isis proteus

sábado, 10 de outubro de 20150 comentários


PIC16F84 LED circuito de controle 8 Led pode ser feita com o modo switch de 4 fases, ou com efeitos komitatör estão disponíveis para escolher e proteus isis simulação arquivo código-fonte é o prótonArquivos de origem: sov.zip PIC16F84 lideradaISIS imagem de simulação;





diagrama do circuito isis
Proton códigos




'****************************************************************
'* Name : Running-LEDs.BAS *
'* Author : F.San *
'* Date : 11.01.2004 *
'****************************************************************
@ device pic16F84, xt_osc, wdt_off, pwrt_on, protect_off

' PortB Leds
LD1 Con 1
LD2 Con 2
LD3 Con 4
LD4 Con 8
LD5 Con 16
LD6 Con 32
LD7 Con 64
LD8 Con 128

PB_Up var PortA.0
PB_Dn var PortA.1
PB_Auto var PortA.2

Up_Dn var bit
Mode var byte
ModeOld var byte
PBData var byte
Cnt1 var byte
Cnt2 var word

TrisA = %11111
TrisB = 000000
PortA = 0
PortB = 0

modeOld = 0
Up_Dn = 1 ' Count up
Cnt1 = 0

Main:
Mode = PortA >> 3 ' Read Mode Switch

if modeOld <> Mode then ' if mode switch changed then,
Modeold = Mode ' Save new mode and
PBData = 0 ' Clear PortB leds
Up_Dn = 1 ' Count up
Cnt1 = 0
endif

gosub Chk_PB_UpDn

if PB_Auto then
if Up_Dn = 1 then
gosub Run_Up
else
gosub Run_Dn
endif
endif

PortB = PBData

if PB_Auto then
pause 100
else
gosub DeBounce
endif

Goto Main

Chk_PB_UpDn:
if PB_Up then
Up_Dn = 1
if not PB_Auto then gosub Run_Up
else
if PB_Dn then
Up_Dn = 0
if not PB_Auto then gosub Run_Dn
endif
endif
return

Run_Up:
select case Mode
case 0
if Cnt1 = 16 then
if PB_Auto then
Up_Dn = 0
else
cnt1 = 0
endif
endif
Cnt1 = cnt1 + 1
gosub Mode0
case 1
if Cnt1 = 9 then
if PB_Auto then
Up_Dn = 0
else
cnt1 = 0
endif
endif
Cnt1 = cnt1 + 1
gosub Mode1
case 2
PBData = PBData + 1

case 3
if Cnt1 = 11 then
if PB_Auto then
Up_Dn = 0
else
cnt1 = 0
endif
endif
Cnt1 = cnt1 + 1
gosub Mode3
end select
return

Run_Dn:
select case Mode
case 0
if Cnt1 = 0 then
if PB_Auto then
Up_Dn = 1
else
cnt1 = 16
endif
endif
Cnt1 = cnt1 - 1
gosub Mode0
case 1
if Cnt1 = 0 then
if PB_Auto then
Up_Dn = 1
else
cnt1 = 9
endif
endif
Cnt1 = cnt1 - 1
gosub Mode1
case 2
PBData = PBData - 1

case 3
if Cnt1 = 0 then
if PB_Auto then
Up_Dn = 1
else
cnt1 = 11
endif
endif
Cnt1 = cnt1 - 1
gosub Mode3
end select
return

Mode0:
select case cnt1
case 00 : PBData = 0
case 01 : PBData = ld1
case 02 : PBData = ld1+ld2
case 03 : PBData = ld1+ld2+ld3
case 04 : PBData = ld1+ld2+ld3+ld4
case 05 : PBData = ld1+ld2+ld3+ld4+ld5
case 06 : PBData = ld1+ld2+ld3+ld4+ld5+ld6
case 07 : PBData = ld1+ld2+ld3+ld4+ld5+ld6+ld7
case 08 : PBData = ld1+ld2+ld3+ld4+ld5+ld6+ld7+ld8
case 09 : PBData = ld2+ld3+ld4+ld5+ld6+ld7+ld8
case 10 : PBData = ld3+ld4+ld5+ld6+ld7+ld8
case 11 : PBData = ld4+ld5+ld6+ld7+ld8
case 12 : PBData = ld5+ld6+ld7+ld8
case 13 : PBData = ld6+ld7+ld8
case 14 : PBData = ld7+ld8
case 15 : PBData = ld8
case 16 : PBData = 0
end select
return

Mode1:
select case cnt1
case 00 : PBData = 0
case 01 : PBData = ld1
case 02 : PBData = ld2
case 03 : PBData = ld3
case 04 : PBData = ld4
case 05 : PBData = ld5
case 06 : PBData = ld6
case 07 : PBData = ld7
case 08 : PBData = ld8
case 09 : PBData = 0
end select
return

Mode3:
select case cnt1
case 00 : PBData = 0
case 01 : PBData = ld1
case 02 : PBData = ld1+ld2
case 03 : PBData = ld1+ld2+ld3
case 04 : PBData = ld2+ld3+ld4
case 05 : PBData = ld3+ld4+ld5
case 06 : PBData = ld4+ld5+ld6
case 07 : PBData = ld5+ld6+ld7
case 08 : PBData = ld6+ld7+ld8
case 09 : PBData = ld7+ld8
case 10 : PBData = ld8
case 11 : PBData = 0
end select
return

DeBounce:
Cnt2 = 0
repeat
Cnt2 = Cnt2 + 1
pause 1
until (PB_Dn = 0) and (PB_Up = 0) or (Cnt2 > 200)
if Cnt2 < 50 then pause (50 - Cnt2) ' debounce
return

End

Share this article :

Postar um comentário

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. mlknaweb - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger