TK19 ALICI SENSORLE YAPILMIS BİR PIC DEVREM VAR,
KUMANDA KODLARINI CIKARTIYORUM.BASKA BI DEVRE DAHA YAPTIM IR LED ILE SAYI YADA HARF GONDERMEK ICIN AMA BASARILI
OLAMADIM.
SEROUT kumutu ile gonderıyorum verileri,alıcı devrem ledin calıstıgını onaylıyor fakat verıler gelmıyor. hangı komutla nasıl Ir led ile veri gonderirim??
herkese
iyi calısmalar dilerim
.
.
pic16f84a kullanıyorum, bi kodla cozdum ilgilenenlere gonderebılırım
Hangi PIC'i kullanıyorsun?
Sinyali almak için hangi komutu kullanıyorsun?
Alıcı kısımdaki devre seri port
protokolüne uyuyor mu?
Bazi IR moduller (icinde IC olanlar) 30Khz civarinda IR sinyallere cevap verir.
Elinizdeki sensorun datalarina detayli
bakin.
Klasik seriport cikisina surucu baglayip IR ledi surmek suretiyle data aktariminda
problem yasarsin. Alici bir seyler alir ama alinan data klasik seri dataya
benzemez.
Benzer durum RF data aktariminda da yasanir.
Bu nedenle seri rs232 yada (TTL) sinyalini modulasyona tabii tutmaniz gerekir.
ornegin 20khz kare dalga ile
andlemek, orlamak gibi.
Alici devrenizde de bu modulasyondan kurtulmaniz gerekir.
Yaygin modulasyon tekniklerinden birisi de 1 seviyesi ile 0 seviyesinde birbirinden farkli
uzunlukta puls yollamaktir. (Bu modulasyonun ismini hatirlamiyorum)
Protokoller için adres. (http://www.ustr.net)
Bir
uygulama, fikir verebilir. (http://www.antrak.org.tr/gazete/062000/barbar.htm)
bunalmis'a katılıyorum, IR led ten göndereceğimiz DATA yı 38KHz lik başka bir sinyalle OR lamamız gerekiyor, RF deki
gibi 38KHz lik hamal sinyalin üzerine bizim data'ları bindirmemiz gerekli. Bu işi HPWM i olan herhangi bir picle çözdüklerini duymuştum, HPWM ucunu bir NPN transistörün kollektörüne
girip DATA ucunuda beyz ucuna girerek moduleli sinyal gönderiyorlarmış. Bu arada HPWM den 38KHz lik sinyal almak için ne yapmak gerekli tam olarak bilmiyorum.
TK19 (TSOP)
da üzerine gelen 38KHz lik hamal sinyali ayırıp data ucundan gönderdiğimiz bilgiyi bize verir fakat bildiğim kadarıyla bu gelen sinyal gönderdiğimiz sinyalin değillenmişi...
buyrun arkadaşlar. ne HPWM nede baska birşey size TK19 ile calışan source kodlar.
IR alıcı için source
KOD;
Include "Modedefs.Bas"
Define OSC 4
Define DEBUG_REG PortB ' Debug
PORTB
Define DEBUG_BIT 0 ' *** Debug pin 0 ***
Define DEBUG_BAUD 9600 ' *** Debug Baud Rate ***
Define DEBUG_MODE 0 ' Set Serial Mode
0=True, 1=Inverted
Define DEBUG_PACING 100 ' Delay 'in us' between characters sent
SI Var PortB.1 ' Set Serin Pin to PORTB.1
IR_Rcv
Var Byte ' Received Value
' Declare Constants
Baud Con T1200 ' Set the Baud rate to match transmitter
' And the Mode, Opposite the
transmitter
Pause 400 ' Wait for Pic to Initialize
Debug 254,1:Pause 30 ' Clear the LCD
Main:
Serin SI,Baud,IR_Rcv ' Receive the Data from the
IR-Sensor
Debug IR_Rcv ' Send the Data to the LCD
Goto Main ' Repeat Forever
IR verici source
kod;
Include "Modedefs.Bas"
Include "Irserout.Bas" ' Load in the New Subroutine
' ** Set Xtal
Value in Mhz **
Define OSC 4 ' Set Xtal Frequency
' ** New Defines for IRSEROUT **
Define IRSEROUT_PORT PortB ' Set IRSEROUT Port
Define
IRSEROUT_PIN 0 ' Set IRSEROUT Pin
Define IRSEROUT_BAUD 1200 ' Set IRSEROUT Baud Rate
' ** Start of Program **
Start:
Pause
400 ' Wait For the Pic to Initialize
Main:
IR_Byteout = 254 ' Send the Control Code
Gosub IRSerout
IR_Byteout = 1 ' Send the Code for
Clear LCD
Gosub IRSerout
Pause 30 ' Wait for Serial LCD to Recover
IR_Byteout = "R" ' Load the letter "R" into
IR_ByteOut
Gosub IRSerout ' Send the Byte
IR_Byteout = "E" ' Load the letter "E" into IR_ByteOut
Gosub IRSerout ' Send the Byte
IR_Byteout
= "C" ' Load the letter "C" into IR_ByteOut
Gosub IRSerout ' Send the Byte
IR_Byteout = "E" ' Load the letter "E" into IR_ByteOut
Gosub
IRSerout ' Send the Byte
IR_Byteout = "I" ' Load the letter "I" into IR_ByteOut
Gosub IRSerout ' Send the Byte
IR_Byteout = "V" ' Load the
letter "V" into IR_ByteOut
Gosub IRSerout ' Send the Byte
IR_Byteout = "E" ' Load the letter "E" into IR_ByteOut
Gosub IRSerout ' Send the
Byte
IR_Byteout = "D" ' Load the letter "D" into IR_ByteOut
Gosub IRSerout ' Send the Byte
IR_Byteout = " " ' Load a Space into
IR_ByteOut
Gosub IRSerout ' Send the Byte
Pause 500 ' A Long Delay
Goto Main ' Infinite Loop
ve işte 38KHz i de pic içinde üreten verici source koduna include ile eklenen
IRSEROUT.bas;
' Define Variables
Dlctr Var Byte ' Counter For Serial Delay Routines
Bctr Var Byte
' Number Of Transmitted Bits
Tr_B Var Byte ' Variable Used In Transmitter
Ir_Byteout Var Byte ' Value To Be Send Out
IR_Bit Var Bit ' Pulse ON or OFF
Dl_Temp Var Byte ' Counter2 For Serial Delay Routines
ON_Delay Var DL_Temp
Off_Delay Var DL_Temp
' ******************************
' ** Jump Over
the Subroutine **
' ******************************
Goto Over_IRSEROUT
IRSerout:
Asm
#Define IR_LED IRSEROUT_PORT , IRSEROUT_PIN;' Get
the Port and Pin from the two new Defines
;' Set Defaults for IRSEROUT_PORT and IRSEROUT_PIN to PORTA BIT 0
Ifndef
IRSEROUT_PORT
IRSEROUT_PORT = PortA
endif
Ifndef IRSEROUT_PIN
IRSEROUT_PIN = 0
endif
;' Set Default to 1200 Baud
Inverted
Ifndef IRSEROUT_BAUD
IRSEROUT_BAUD = 1200
endif
Bcf IRSEROUT_PORT,IRSEROUT_PIN ;' Clear the appropriate
pin
Bsf Status,5 ;' Set to Bank1
Bcf IRSEROUT_PORT,IRSEROUT_PIN ;' Make the appropriate pin an Output
Bcf Status,5 ;' Back to Page 0
;'
Send out the Data serially at Various bauds, Inverted
Mov w,_Ir_Byteout ;' Move the Value into the W register
Clrwdt ;' Walk the Dog
Movwf _TR_B
Movlw
08
Movwf _Bctr ;' Eight Bits In A Byte!.
Bsf _IR_Bit
Call Send_Bit ;' Send the Start Bit at Approx 39Khz.
SIRXmt Rrf _Tr_B ;' Rotate Right Moves the Data
Bits Into the Carry
;' Starting With Bit 0.
Btfsc Status,0 ;' Test the Carry Flag
Bcf _IR_Bit ;' Send a Zero
Btfss Status,0 ;' Test the Carry Flag
Bsf
_IR_Bit ;' Send A One
Call Send_Bit ;' Send the Data Bit at Approx 39 Khz.
Decfsz _Bctr ;' Not Eight Bits Yet? Send the Next Data Bit
Goto SIRXmt
Bcf
_IR_Bit ;' Set LO
Call Send_Bit ;' Send the stop bit at Approx 39khz
;' Delay for X amount of time
Clrwdt ;' Walk the Dog
Movlw
255
Movwf _DlCtr
IRSInner Clrwdt ;' Walk the Dog
Nop
Nop
Nop
Nop
Nop
Nop
Decfsz _DlCtr ;' Do the Inner
Loop
Goto IRSInner
Return
;' This Routine Sends a Pulse modulated at Approx 39Khz
;' Out of the Appropriate pin within a Delay of 1 bit
time
Send_Bit
;' Assemble this code if the Baud rate is 300
If (IRSEROUT_BAUD == 300)
Movlw 128 ;' Set the Delay Time for 300
Baud
endif
;' Assemble this code if the Baud rate is 600
If (IRSEROUT_BAUD == 600)
Movlw 64 ;' Set the Delay Time for 600 Baud
endif
;'
Assemble this code if the Baud rate is 1200
If (IRSEROUT_BAUD == 1200)
Movlw 32 ;' Set the Delay Time for 1200 Baud
endif
;' Assemble this code if the Baud
rate is 2400
If (IRSEROUT_BAUD == 2400)
Movlw 16 ;' Set the Delay Time for 2400 Baud
endif
Pulse_Bit Movwf _Dlctr ;' Store it
Irlp1
Clrwdt ;' Walk The Dog
Btfsc _Ir_Bit ;' If Ir_Bit=1 Then
Bsf IR_LED ;' Turn the IR_Led On
Btfss _Ir_Bit ;' If Ir_Bit=0 Then
Bcf
IR_LED ;' Turn the IR_Led Off
;' Assemble this code if the Xtal is 4Mhz
if (OSC == 4)
Movlw 3
Movwf _On_Delay
Inner1 Decfsz _On_Delay
Goto Inner1
endif
;' Assemble this code if the Xtal is
8Mhz
if ( OSC == 8 )
Movlw 8
Movwf _On_Delay
Inner1 Decfsz _On_Delay
Goto Inner1
endif
;' Assemble this code if the
Xtal is 10Mhz
if (OSC == 10)
Movlw 12 ;' *****Not Sure Untested ***
Movwf _On_Delay
Inner1 Decfsz _On_Delay
Goto
Inner1
endif
;' Assemble this code if the Xtal is 12Mhz
if (OSC ==
12)
Movlw 17
Movwf _On_Delay
Inner1 Decfsz _On_Delay
Goto Inner1
endif
Bcf IR_LED ;' Turn the IR_LED
Off
;' Assemble this code if the Xtal is 4Mhz
if (OSC == 4)
Nop
Nop
Nop
Nop
Nop
Nop
endif
;' Assemble this code if the
Xtal is 8Mhz
if ( OSC == 8 )
Movlw 5
Movwf _Off_Delay
Inner2 Decfsz _Off_Delay
Goto Inner2
endif
;' Assemble this code
if the Xtal is 10Mhz
if (OSC == 10)
Movlw 5
Movwf _Off_Delay
Inner2 Decfsz _Off_Delay
Goto Inner2
endif
;' Assemble
this code if the Xtal is 12Mhz
if (OSC == 12)
Movlw 5
Movwf _Off_Delay
Inner2 Decfsz _Off_Delay
Goto Inner2
endif
Decfsz
_Dlctr
Goto Irlp1
Return
Endasm
Over_IRSEROUT:
Şema ve code ların
tamamını;
http://groups.yahoo.com/group/PicProjeUP2/files/Nonstradam/IR.rar
upload ettim umarım yardımcı olur basarılar...
yahoo da boyle bir gurup yok
Sevgili Atacan,
Öncelikle hoşgeldin. :)
Böyle bir grup var, İstersen buradan bir bak; ;)
http://groups.yahoo.com/group/PicProjeUP2/files/Nonstradam/
Seni direkt dosyaya götürecektir. :D :D :D