Elektronik ve Teknoloji Merkezi Elektrotekno.com
Elektronik ve Teknoloji Merkezi




Click here to go to the original topic

Elektrotekno.com Ana Sayfa Microchip Pic Serisi
Yazar Mesaj
melih
Tarih: 11.01.2008, 14:55 Mesaj konusu: 16F877 ile seri kontrol devresi

merhaba arkadaşlar 16f877 kullanarak 2 pic arasında seri haberleşme gerçekleştirerek uzaktan motor kontrolu yapmak istiyorum.bazı kaynaklardan yararlanarak projeyi yaptım.ancak verici bölümündeki butona basınca alıcı bölümündeki led butona basıldığı sürece yanıyor.ben bunu butona basıldığında sürekli olarak yanmasını ve tekrar butona basıldığında sönmesini istiyorum.nasıl yapabilirim ?




alıcı.bas

ınclude "modedefs.bas"

trısb=%00000000
portb=%00000000
adcon1=7




oku var byte
oku=0

basla:
serın porta.0,n2400,["a"],#oku

ıf oku=0 then
portb=%00000000
endıf

ıf oku=1 then
portb=%00000001
endıf

ıf oku=2 then
portb=%00000010
endıf

ıf oku=3 then
portb=%00000100
endıf

ıf oku=4 then
portb=%00001000
endıf

ıf oku=5 then
portb=%00010000
endıf

ıf oku=6 then
portb=%00100000
endıf

ıf oku=7 then
portb=%01000000
endıf

ıf oku=8 then
portb=%10000000
endıf
ıf oku=9 then
portb=%00001001
endıf
ıf oku=10 then
portb=%00000101
endıf
ıf oku=11 then
portb=%00010001
endıf
ıf oku=12 then
portb=%00100001
endıf
ıf oku=13 then
portb=%01000001
endıf
ıf oku=14 then
portb=%10000001
endıf
ıf oku=15 then
portb=%00000110
endıf
ıf oku=16 then
portb=%00001010
endıf
ıf oku=17 then
portb=%00010010
endıf
ıf oku=18 then
portb=%00100010
endıf
ıf oku=19 then
portb=%01000010
endıf
ıf oku=20 then
portb=%10000010
endıf
ıf oku=21 then
portb=%00010100
endıf
ıf oku=22 then
portb=%00100100
endıf
ıf oku=23 then
portb=%01000100
endıf
ıf oku=24 then
portb=%10000100
endıf
ıf oku=25 then
portb=%00011000
endıf
ıf oku=26 then
portb=%00101000
endıf
ıf oku=27 then
portb=%01001000
endıf
ıf oku=28 then
portb=%10001000
endıf
ıf oku=29 then
portb=%01010000
endıf
ıf oku=30 then
portb=%10010000
endıf
ıf oku=31 then
portb=%01100000
endıf
ıf oku=32 then
portb=%10100000
endıf
goto basla
end


verici.bas


ınclude "modedefs.bas"

define lcd_dreg portb
defıne lcd_dbıt 0
defıne lcd_rsreg portc
defıne lcd_rsbıt 0
defıne lcd_ereg portc
defıne lcd_ebıt 1
defıne lcd_bıts 8
defıne lcd_lınes 2

adcon1=7

trısd=%11111111
output portc.2

m1sol var portd.0
m1sag var portd.1
m2sol var portd.2
m2sag var portd.3
m3sol var portd.4
m3sag var portd.5
m4sol var portd.6
m4sag var portd.7


gon var byte
gon=0


basla:

ıf m1sol=1 and m2sag=1 then
gon=9

lcdout $fe,1,"1. motor = sol"
lcdout $fe,$c0,"2. motor = sag"

endıf

ıf m1sol=1 and m2sol=1 then
gon=10

lcdout $fe,1,"1. motor = sol"
lcdout $fe,$c0,"2. motor = sol"
goto ser
endıf

ıf m1sol=1 and m3sol=1 then
gon=11

lcdout $fe,1,"1. motor = sol"
lcdout $fe,$c0,"3. motor = sol"
goto ser
endıf

ıf m1sol=1 and m3sag=1 then
gon=12
lcdout $fe,1,"1. motor = sol"
lcdout $fe,$c0,"3. motor = sag"
goto ser
endıf

ıf m1sol=1 and m4sol=1 then
gon=13
lcdout $fe,1,"1. motor = sol"
lcdout $fe,$c0,"4. motor = sol"
goto ser
endıf

ıf m1sol=1 and m4sag=1 then
gon=14
lcdout $fe,1,"1. motor = sol"
lcdout $fe,$c0,"4. motor = sag"
goto ser
endıf

ıf m1sag=1 and m2sol=1 then
gon=15
lcdout $fe,1,"1. motor = sag"
lcdout $fe,$c0,"2. motor = sol"
goto ser
endıf

ıf m1sag=1 and m2sag=1 then
gon=16
lcdout $fe,1,"1. motor = sag"
lcdout $fe,$c0,"2. motor = sag"
goto ser
endıf

ıf m1sag=1 and m3sol=1 then
gon=17
lcdout $fe,1,"1. motor = sag"
lcdout $fe,$c0,"3. motor = sol"
goto ser
endıf

ıf m1sag=1 and m3sag=1 then
gon=18
lcdout $fe,1,"1. motor = sag"
lcdout $fe,$c0,"3. motor = sag"
goto ser
endıf

ıf m1sag=1 and m4sol=1 then
gon=19
lcdout $fe,1,"1. motor = sag"
lcdout $fe,$c0,"4. motor = sol"
goto ser
endıf

ıf m1sag=1 and m4sag=1 then
gon=20
lcdout $fe,1,"1. motor = sag"
lcdout $fe,$c0,"4. motor = sag"
goto ser
endıf

ıf m2sol=1 and m3sol=1 then
gon=21
lcdout $fe,1,"2. motor = sol"
lcdout $fe,$c0,"3. motor = sol"
goto ser
endıf

ıf m2sol=1 and m3sag=1 then
gon=22
lcdout $fe,1,"2. motor = sol"
lcdout $fe,$c0,"3. motor = sag"
goto ser
endıf

ıf m2sol=1 and m4sol=1 then
gon=23
lcdout $fe,1,"2. motor = sol"
lcdout $fe,$c0,"4. motor = sol"
goto ser
endıf

ıf m2sol=1 and m4sag=1 then
gon=24
lcdout $fe,1,"2. motor = sol"
lcdout $fe,$c0,"4. motor = sag"
goto ser
endıf

ıf m2sag=1 and m3sol=1 then
gon=25
lcdout $fe,1,"2. motor = sag"
lcdout $fe,$c0,"3. motor = sol"
goto ser
endıf

ıf m2sag=1 and m3sag=1 then
gon=26
lcdout $fe,1,"2. motor = sag"
lcdout $fe,$c0,"3. motor = sag"
goto ser
endıf

ıf m2sag=1 and m4sol=1 then
gon=27
lcdout $fe,1,"2. motor = sag"
lcdout $fe,$c0,"4. motor = sol"
goto ser
endıf

ıf m2sag=1 and m4sag=1 then
gon=28
lcdout $fe,1,"2. motor = sag"
lcdout $fe,$c0,"4. motor = sag"
goto ser
endıf

ıf m3sol=1 and m4sol=1 then
gon=29
lcdout $fe,1,"3. motor = sol"
lcdout $fe,$c0,"4. motor = sol"
goto ser
endıf

ıf m3sol=1 and m4sag=1 then
gon=30
lcdout $fe,1,"3. motor = sol"
lcdout $fe,$c0,"4. motor = sag"
goto ser
endıf

ıf m3sag=1 and m4sol=1 then
gon=31
lcdout $fe,1,"3. motor = sag"
lcdout $fe,$c0,"4. motor = sol"
goto ser
endıf

ıf m3sag=1 and m4sag=1 then
gon=32
lcdout $fe,1,"3. motor = sag"
lcdout $fe,$c0,"4. motor = sag"
goto ser
endıf

ıf m1sol=1 then
gon=1
lcdout $fe,1,"1. motor = sol"
goto ser
endıf

ıf m1sag=1 then
gon=2
lcdout $fe,1,"1. motor = sag"
goto ser
endıf

ıf m2sol=1 then
gon=3
lcdout $fe,1,"2. motor = sol"
goto ser
endıf

ıf m2sag=1 then
gon=4
lcdout $fe,1,"2. motor = sag"
goto ser
endıf

ıf m3sol=1 then
gon=5
lcdout $fe,1,"3. motor = sol"
goto ser
endıf

ıf m3sag=1 then
gon=6
lcdout $fe,1,"3. motor = sag"
goto ser
endıf

ıf m4sol=1 then
gon=7
lcdout $fe,1,"4. motor = sol"
goto ser
endıf

ıf m4sag=1 then
gon=8
lcdout $fe,1,"4. motor = sag"
goto ser
endıf

gon=0

ser:
serout portc.6,n2400,[#gon,"a"]
pause 50

goto basla
end
-----------------------------------------------------

Elektrotekno.com Ana Sayfa Microchip Pic Serisi
1. sayfa (Toplam 1 sayfa)

16F877 ile seri kontrol devresi

Gizlilik Politikası

PLC programming