Leitor RFID

July 27, 2019 | Author: jandrade1br | Category: Rede Elétrica, Identificação de Radiofrequência, Indutor, Eletricidade, Informática
Share Embed Donate


Short Description

Leitor eletrônico de rfid...

Description

Leitor RFID Cartões RFID são normalmente usados para controle de acesso e tickets de ônibus e metrôs. Eles são convenientes porque não precisam de contato direto para transferir informações depara o cartão. Como estes cartões são alimentados pelos pr!prios leitores" dispensam o uso de baterias que precisariam ser recarre#adas. $ara os meus e%perimentos estou usando catrões da &ID I'$ro%. Estes cartões são os mais simples de toda a lin(a de cartões RFID" que somente arma)enam um n*mero de s+rie e não usam cripto#rafia. , frequ-ncia da portadora + de /0k&). 1 primeiro passo + descobrir como desenvolver um leitor simples. 2!s sabemos que o cartões RFID + alimentado pelo campo ma#n+tico emitido pelo leitos. ,s tags3 RFID transferem informação de volta ao leitor consumindo este campo ma#n+tico" que + detectado pelo leitor como uma variação no campo. 3 'ão c(amados de 4 tags5 RFID todos os elementos que arma)enam informações e são m!veis" como o cartão" neste caso espec6fico.

1 pro7eto mais comum de um leitor RFID fa) uso de um circuito ressonante s+rie. Ele consiste de um indutorsimples e um capacitor" e%citados por uma fonte de tensão de bai%a imped8ncia. 'e o 9 do circuito for alto o suficiente" a tensão no ponto de amostra#em :;sample< vai e%ceder a tensão de alimentação. 9uando o RFID + alimentado por este campo ma#n+tico o 9 do circuito cai. 1 resultado + uma pequena alteração na tensão de amostra#em :;sample no circuito mostrados e redesen(ar todo o circuito. Com um a7uste simples eu verifiquei quais alterações aconteciam quando a ta# RFID era submetida a A ou 0 ciclos de frequ-ncia da portadora. =ma ve) que o sinal precisa ser ,C e não DC" eu assumi que a frequ-ncia de transmissão seria 0@k&B  B.0k&) ou 0@k&)@  0k&). Este detal(e eu encontrei em um site que foi realmente *til por conter boas informações sobre RFID?(ttp?instruct.cit.cornell.educourseseeAFinal$ro7ectss/@@c7rGebsiteinde%.(tm RFID?(ttp?instruct.cit.cornell.educourseseeAFinal$ro7ectss/@@c7rGebsiteinde%.(tm.. , tag  aparentemente  aparentemente codifica o dado usando F'H. ,s duas frequ-ncias representam o @ e  l!#icos. Com esta informações em mãos" eu avancei e iniciei o pro7eto do meu pr!prio indutorantena. =ma ve) que eu mantive a id+ia de usar 0@k&) como frequ-ncia da portadora" eu fi) o c>lculo e fiquei com uma indut8ncia de @u& e um capacitor de @nF. Eu utili)ei a se#uinte equação para estimar o n*mero de

voltas que precisaria em min(a bobina?

1nde %" J são o comprimento e a lar#ura da bobina" ( + a altura e b + a espessura da parte condutora. Eu utili)er %Jcm" (cm e b@.cm. 1 n*mero encontrado foi A. Eu enrolei a bobina em uma cai%a de  papel que encontrei" de onde eu e%trai o % e J. J. Depois de enrolada" a bobina foi e%tra6da e presa com fita adesiva.

$ara um a7uste fino da frequ-ncia ressonante do sistema todo eu decidi brincar com o valor da capacit8ncia. =sando o #erador de função para variar a frequ-ncia e visuali)ando o pico da sa6da com um oscilosc!pio" eu variei os valores dos capacitores at+ que o pico da resposta ressonante fosse a 0@k&). 1 capacitor final foi de @.@0uF. =ma ve) que o meu capacitor precisa ser um valor de mercado" a bobina que eu constru6 precisa ter uma indut8ncia maior que @u&.

1 pr!%imo est>#io era pro7etar o circuito anal!#ico. Eu usei o confi>vel c onfi>vel ,K$1$ LM@/ :eu 7> possuia v>rios desses em casatica do cartão

Desenvolvido por Rick &uan#.

,daptado para o portu#u-s por Eletronica.or#" com autori)ação do autor.

,ne%os FirmOare Meitor RFID Revisão / FirmOare Meitor RFID Revisão  • •

PVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV

PVV PVV RFID reader section" #enerate 0@H&) carrier frequencJ PVV and decode t(e basic data stream PVV PVV Gritten bJ Rick &uan#" CopJri#(t :C< /@@ PVV Revision KKDD PVV Rev . /@@@A/W  Initial release PVV Rev /. /@@@0@0  ,dd automatic card detect PVV PVV Command Functions PVV XX Uasic decode" binarJ data output PVV X/X Debu# capture" Bbit data output PVV XX Full capture and decode PVV XAX &e% test  ec(o anJ (e% input PVV XX ,uto card detect mode PVV XX PVV PVV PVV L(is pro#ram is free softOareP Jou can redistribute it andor modifJ PVV it under t(e terms of t(e Y2= Yeneral $ublic Micense as publis(ed bJ PVV t(e Free 'oftOare FoundationP eit(er version / of t(e Micense" or  PVV :at Jour option< anJ later version. PVV PVV L(is pro#ram is distributed in t(e (ope t(at it Oill be useful" PVV but GIL&1=L ,2 G,RR,2LP Oit(out even t(e implied OarrantJ of  PVV KERC&,2L,UIMIL or FIL2E'' F1R , $,RLIC=M,R $=R$1'E. 'ee t(e PVV Y2= Yeneral $ublic Micense for more details. PVV PVV ou s(ould (ave received a copJ of t(e Y2= Yeneral $ublic Micense PVV alon# Oit( t(is pro#ramP if not" Orite to t(e Free 'oftOare PVV Foundation" Inc." 0W Lemple $lace" 'uite @" Uoston" K, @/@ =', PVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV PVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV PVV 21LE? Disable t(e GDL O(en debu##in# t(e code" (oOever" make sure PVV t(e GDL is enabled O(en puttin# t(e sJstem into lift time test PVV L(e timeout for GDL is about / seconds Oit( /B? prescaler  PVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV include Zpf/B.inc[  \\confi# \&'\1'C  \$GRLE\12

] \GDL\12 ] \M;$\1FF ] \U1DE2\12 ] \KCMRE\12 ]

PVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV PVV ;ariables LempG E9= @( P UitMocation E9= ( CounterU E9= /(  2e%tF'R E9= ( P CounterG E9= A(

UitCount MastUit;al Data@ Data Data/ Data DataA ^ero 'erData Lemp 1utput Counter LKRsample UinCnt Lo##le L(reeLrJ FCData@ FCData FCData/ FCData FCDataA GrittenUit

E9= E9= E9= E9= E9= E9= E9= E9=

0( ( ( B( W( a( /( b( E9=

E9= E9=

P ^ero is @%@@ c(

d( e( E9=

E9= E9= E9= E9=

f( @( ( ( A(

E9= E9= E9= E9= E9= E9=

P Final data output

0( ( ( B( W(

P First data captured

a(

_define _define _define _define _define _define _define _define

\$1,' $1RLU"  \D1=L $1RLU"  \HE $1RLU" 0 \UEE$$1RLU" A \$GK\1 $1RLU"  \L`D $1RLU" / \R`D $1RLU"  \=2= $1RLU" @

_define

Decision;al

P $oOer 12 ,uto 'tart P P HeJ #ood output P Ueeper output P $GK  0@k&) P =,RL P =,RL P =nused

dX@X P&ard decision" @  0W cJcle"   WB cJcle

PVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV PVV $ro#ram code (ere #oto 'tart 1RY A POaitin# for Z@@@A[ Pinterrupt vector  P#oto Interrupt 1RY 0 PVVVVVVVVVVVVVVVVVVVVVVVVVVVVV 'trin#'tart? $GelcomeKs#? addOf $CM" F DL Gelcome DL &X@dX" &X@aX" &X@@X $CommandKs#? DL Command Error

D,L,

DL &X@dX" &X@aX" &X@@X $$arameterKs#? DL $arameter Error DL &X@dX" &X@aX" &X@@X $2o,ckKs#? DL Kissin# ,ck DL &X@dX" &X@aX" &X@@X 'trin#End? GelcomeKs# E9= @ CommandKs# E9= $CommandKs#    0 $arameterKs#E9= $$arameterKs#    0 P 'trin#s start  2o,ckKs# E9= $2o,ckKs#    0 &e%Lable? addOf $CM" F DL @/A0BW,UCDEF

PVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV PVVVVVVVVVVVVVVVVVVVV $ro#ram 'tarts (ere 'tart? PVVVVVVVVVVVVVVVVVVVVV 'etup GDL PVVVVVVVVVVVVVVVVVVVVVV 'ettin# up LKR@" used to decode F'H   bcf \UEE$ clrOdt  bsf 'L,L='" R$@ movlO bX@@@@X P$rescaler to GDL" ?/B movOf 1$LI12\REY clrOdt PVVVVVVVVVVVVVVVVVVVVV 'ettin# up environment movlO bX@@@@@@X P'erial port in too movOf LRI'U P'et port U I1 movlO bX@@@@@X movOf LRI', P'et port , I1  bcf 'L,L='" R$@ clrf $1RL, PVVVVVVVVVVVVVVVVVVVVVV Disable f/B specific features movlO bX@@@@@@X P'etup comparator movOf CKC12 PVVVVVVVVVVVVVVVVVVVVVV 'ettin# up $GK module for 0@H&) si#nal movlO bX@@@@@@X PEnable $GK module" dutJ  / movOf CC$C12 movlO bX@@@@@@@X P=sin# source frequencJ  /K&) movOf CC$RM movlO bX@@@@@@X P'ettin# up LKR/" $rescale  ?A movOf L/C12  bsf 'L,L='" R$@ movlO bX@@@@@@@X movOf $R/ P'ettin# t(e period  A

P 0 is t(e offset O(ere t(e

 bcf 'L,L='" R$@ PVVVVVVVVVVVVVVVVVVVVVV 'etup =,RL  bsf 'L,L='" R$@ movlO dX/X P0@@ for /K&) Clock" &i#( speed movOf '$URY PL(e onlJ rate Oit( loO mismatc( movlO bX@@@X P,sJnc Bbit  &i#( speed movOf L`'L,  bcf 'L,L='" R$@ movlO bX@@@@@X PEnable serial port movOf RC'L, clrf ^ero movlO GelcomeKs# PDisplaJ Oelcome strin# on startup call 'end'trin# P Debu# insert #oto 'kipDebu# movlO @a@( movOf F'R  movlO bX@@@@@@X movOf I2DF incf F'R" F movlO bXX movOf I2DF incf F'R" F movlO bX@@X movOf I2DF incf F'R" F movlO bX@@@X movOf I2DF incf F'R" F movlO bX@@@@@@X movOf I2DF incf F'R" F movlO bX@@@@X movOf I2DF incf F'R" F movlO bX@@@X movOf I2DF incf F'R" F movlO bX@@@@@X movOf I2DF incf F'R" F #oto FD\DecodeEntrJ 'kipDebu#? P Gait for command GaitKore?  btfsc \$1,' #oto ,utoDecode clrOdt  btfsc RC'L," 1ERR 

#oto ClearError   btfss $IR" RCIF #oto GaitKore movfORCREY movOf 'erData movOf L`REY call ''pace movlO XX %orOf 'erData" G  btfsc 'L,L='" ^ #oto ,ttempt'ample movlO X/X %orOf 'erData" G  btfsc 'L,L='" ^ #oto Debu#'ample movlO XX %orOf 'erData" G  btfsc 'L,L='" ^ #oto FullDecode movlO XAX %orOf 'erData" G  btfsc 'L,L='" ^ #oto &e%Lest movlO X0X %orOf 'erData" G  btfsc 'L,L='" ^ #oto UinLest movlO XX %orOf 'erData" G  btfsc 'L,L='" ^ #oto ,utoDecode movlO XX %orOf 'erData" G  btfsc 'L,L='" ^ #oto LestUeep movlO XBX %orOf 'erData" G  btfsc 'L,L='" ^ #oto DummJ2oO DummJ2oO? movlO CommandKs# call 'end'trin# #oto GaitKore PVVVVVVVVVVVVVVVVVVVVV ClearError? movfORCREY movfORCREY

P'end it back out

PDecode command

P'tart a RFID sample

PDebu# run" output sampled data

PFullJ capture and decode data

PLestin# &E` routine

PLestin# Uin dump routine

P2o Debu# messa#e" auto card detection

PFor all command not in use P'end error command messa#e

Clear recevin# overrun error 

 bcf RC'L," CRE2  bsf RC'L," CRE2 #oto GaitKore P Commands e%ecution PVVVVVVVVVVVVVVVVVVVVVV Command ? ,ttempt'ample? PCommand ? 'ample RFID data" do @/A bits call CompC(eck PDummJ read once to setup condition movlO @a@( movOf F'R P=se F'R to store data movlO dXB@X PDo t(is for B@ bJtes movOf Counter  'ampleMoop? call CaptureUJte incf F'R" F P, bJte is full" move to t(e ne%t one decfs) Counter" F #oto 'ampleMoop P 'Oitc( memorJ bank  movlO @/@( movOf F'R P=se F'R to store data movlO dXAX PDo t(is for A bJtes movOf Counter  'ampleMoop/? call CaptureUJte incf F'R" F decfs) Counter" F #oto 'ampleMoop/ P movlO dXB@X movOf Counter  movlO @a@( movOf F'R

P, bJte is full" move to t(e ne%t one

Data is full" noO dump t(e data out PDo t(is for B@ bJtes

P=se F'R to access data

'ampleMoop@? movfOI2DF call 'endUin incf F'R" F decfs) Counter" F #oto 'ampleMoop@ P movlO dXAX movOf Counter  movlO @/@( movOf F'R 'ampleMoop? movfOI2DF

'Oitc( bank  PDo t(is for A bJtes

P=se F'R to access data

call incf decfs) #oto

'endUin F'R" F Counter" F 'ampleMoop

call #oto

2eOMine GaitKore

PVVVVVVVVVVVVVVVVVVVVVVV Command / Debu# mode Debu#'ample? call CompC(eck movlO @a@( movOf F'R movlO dXB@X movOf Counter 

PCommand /? 'ample RFID data" debu# mode PDummJ read once to setup condition P=se F'R to store data PDo t(is for B@ bJtes

Debu#'Moop?   call CompC(eck  movfO LKRsample movOf I2DF incf F'R" F decfs) Counter" F #oto Debu#'Moop

P, bJte is full" move to t(e ne%t one

P 'Oitc( memorJ bank  movlO @/@( movOf F'R P=se F'R to store data movlO dXAX PDo t(is for A bJtes movOf Counter  Debu#'Moop/? call CompC(eck   movfO LKRsample movOf I2DF incf F'R" F decfs) Counter" F #oto Debu#'Moop/ P movlO dXB@X movOf Counter  movlO @a@( movOf F'R Debu#'Moop@? movfOI2DF call 'end&e% call 2eOMine

P, bJte is full" move to t(e ne%t one

Data is full" noO dump t(e data out PDo t(is for B@ bJtes

P=se F'R to access data

incf F'R" F decfs) Counter" F #oto Debu#'Moop@ P movlO dXAX movOf Counter  movlO @/@( movOf F'R

'Oitc( bank  PDo t(is for A bJtes

P=se F'R to access data

Debu#'Moop? movfOI2DF call 'end&e% call 2eOMine incf F'R" F decfs) Counter" F #oto Debu#'Moop

call #oto

2eOMine GaitKore

PVVVVVVVVVVVVVVVVVVVVVVV Command  Full capture and decode FullDecode? PGait for start sequence" t(an start capture call CompC(eck PDummJ read once to setup condition call GaitLill'tart PGait for start movlO @a@( movOf F'R movlO dXB@X movOf Counter  FDMoop? call incf decfs) #oto

CaptureUJte F'R" F Counter" F FDMoop

P movlO dXB@X movOf Counter  movlO @a@( movOf F'R FDMoop@? movfOI2DF call 'endUin incf F'R" F decfs) Counter" F #oto FDMoop@

P=se F'R to store data PDo t(is for B@ bJtes

P, bJte is full" move to t(e ne%t one

Data is full" noO dump t(e data out PDo t(is for B@ bJtes

P=se F'R to access data

call 2eOMine FD\DecodeEntrJ? P Collaspe data bits movlO dXBX P'et up for bit read movOf UitMocation movlO @a@( movOf 2e%tF'R  P 'tart e%traction clrf Data@ PClear data (older   clrf Data clrf Data/ clrf Data clrf DataA clrf Lo##le FD\UitMoop^? call YetUitCount movfO UitCount movlO dX/@X subOf UitCount" G  btfsc 'L,L='" C #oto FD\DoneDecode movlO dXX subOf UitCount" G  btfss 'L,L='" C #oto FD\'end/bit movlO XVX call 'endC(ar   call 'endC(ar    bsf 'L,L='" C call Mon#'(ift call Mon#'(ift #oto FD\2e%tUit FD\'end/bit? movlO X\X call 'endC(ar    bcf 'L,L='" C call Mon#'(ift FD\2e%tUit? movlO @ef( subOf 2e%tF'R" G  btfss 'L,L='" C #oto FD\UitMoop^ call 2eOMine

P Uitcount  0  $ositive" Mooped alreadJ" 'L1$

P2e#ative"  bits P$ositive" / bit

P2e%tF'R  G P2e#ative" keep loopin# P$ositive" 2e%tF'R [ @%ef  

P Final data output FD\DoneDecode?

call 2eOMine movfODataA call 'end&e% movfOData call 'end&e% movfOData/ call 'end&e% movfOData call 'end&e% movfOData@ call 'end&e% call #oto

2eOMine GaitKore

PVVVVVVVVVVVVVVVVVVVVVVV Command ? ,uto detection of card ,utoDecode? clrOdt movlO @( PL(ree trJs movOf L(reeLrJ ,D\Capture,#ain? clrf GrittenUit clrOdt call CompC(eck PDummJ read once to setup condition call GaitLill'tart PGait for start condition movlO @a@( movOf F'R movlO dXB@X movOf Counter  ,DMoop? call incf decfs) #oto

CaptureUJte F'R" F Counter" F ,DMoop

P=se F'R to store data PDo t(is for B@ bJtes

P, bJte is full" move to t(e ne%t one

,D\DecodeEntrJ? P Collaspe data bits movlO dXBX P'et up for bit read movOf UitMocation movlO @a@( movOf 2e%tF'R  P 'tart e%traction clrf Data@ PClear data (older   clrf Data clrf Data/ clrf Data

clrf clrf

DataA Lo##le

,D\UitMoop^? call YetUitCount movlO dX/@X subOf UitCount" G  btfsc 'L,L='" C #oto ,D\DoneDecode movlO dXX subOf UitCount" G  btfss 'L,L='" C #oto ,D\'end/bit  bsf 'L,L='" C call Mon#'(ift call Mon#'(ift #oto ,D\2e%tUit ,D\'end/bit?  bcf 'L,L='" C call Mon#'(ift ,D\2e%tUit? incf GrittenUit" F movlO @ef( subOf 2e%tF'R" G  btfss 'L,L='" C #oto ,D\UitMoop^ #oto

,utoDecode

P Uitcount  0  $ositive" 'tart condition a#ain" 'L1$

P2e#ative"  bits P$ositive" / bit

P2e%tF'R  G P2e#ative" keep loopin# P$ositive" 2e%tF'R [ @%ef" error  PRestart...

P C(eck data is t(e same for t(ree times ,D\DoneDecode? movlO dX@X PError c(eck" if too manJ )ero bits" restart subOf UitCount" G  btfsc 'L,L='" C #oto ,utoDecode PLoo manJ bits movlO (XAX subOf GrittenUit" G  btfss 'L,L='" C #oto ,utoDecode

PC(eck number of bit Oritten" too little" restart

movlO (X00X subOf GrittenUit" G  btfsc 'L,L='" C #oto ,utoDecode

PC(eck number of bit Oritten" too manJ" restart

movlO dXX %orOf L(reeLrJ" G  btfss 'L,L='" ^

PFirst trJ indicator 

#oto ,D\2otFirstLrJ movfOData@ movOf FCData@ movfOData movOf FCData movfOData/ movOf FCData/ movfOData movOf FCData movfODataA movOf FCDataA decf L(reeLrJ" F #oto ,D\Capture,#ain ,D\2otFirstLrJ? movfOData@ %orOf FCData@" G  btfss 'L,L='" ^ #oto ,utoDecode P2ot matc(ed" restart movfOData %orOf FCData" G  btfss 'L,L='" ^ #oto ,utoDecode P2ot matc(ed" restart movfOData/ %orOf FCData/" G  btfss 'L,L='" ^ #oto ,utoDecode P2ot matc(ed" restart movfOData %orOf FCData" G  btfss 'L,L='" ^ #oto ,utoDecode P2ot matc(ed" restart movfODataA %orOf FCDataA" G  btfss 'L,L='" ^ #oto ,utoDecode P2ot matc(ed" restart decfs) L(reeLrJ" F #oto ,D\Capture,#ain P Final data output call 2eOMine movfODataA call 'end&e% movfOData call 'end&e% movfOData/ call 'end&e% movfOData call 'end&e% movfOData@ call 'end&e% call

2eOMine

call #oto

Ueep GaitKore

PVVVVVVVVVVVVVVVVVVVVVVV Command A"0 'erial debu# &e%Lest? call Rcv&e% movfO 1utput call 'end&e% call 2eOMine #oto GaitKore UinLest? call Rcv&e% movfO 1utput call 'endUin call 2eOMine #oto GaitKore LestUeep? call call #oto

Ueep 2eOMine GaitKore

PCommand A? &e% test

PCommand 0? Uin test

PCommand ? Lest beep

PVVVVVVVVVVVVVVVVVVVVVVVVVVVVV '=UR1=LI2E P P Mon#'(ift" '(ift  bit of t(e data into Data@?A re#ister  P '(ift onlJ  bit per tOo calls P Input? C Mon#'(ift?  btfss Lo##le" @ #oto Lo##le2ot'et rlf Data@" F rlf Data" F rlf Data/" F rlf Data" F rlf DataA" F  bcf Lo##le" @ return Lo##le2ot'et?  bsf return

Lo##le" @

P P CaptureUJte" Capture a sin#le bJte of data P 1utput? I2DF CaptureUJte?

  call CompC(eck  movlO Decision;al subOf LKRsample" G rlf I2DF" F

P&ard decision" @  0W cJcle"   WB cJcle P'tore t(e data into pointed address

call CompC(eck PDo t(is for B times to fill up a bJte movlO Decision;al subOf LKRsample" G rlf I2DF" F   call CompC(eck  movlO Decision;al subOf LKRsample" G rlf I2DF" F   call CompC(eck  movlO Decision;al subOf LKRsample" G rlf I2DF" F

  call CompC(eck  movlO Decision;al subOf LKRsample" G rlf I2DF" F   call CompC(eck  movlO Decision;al subOf LKRsample" G rlf I2DF" F   call CompC(eck  movlO Decision;al subOf LKRsample" G rlf I2DF" F   call CompC(eck  movlO Decision;al subOf LKRsample" G rlf I2DF" F return P P GaitLill'tart" Gait until t(e start sequence is detected P L(is is marked bJ /@ or more )eros GaitLill'tart? movlO dX/@X movOf CounterG

GL'\ne%t? clrOdt call CompC(eck   movlO Decision;al subOf LKRsample" G  btfsc 'L,L='" C PC(eck for a @ value #oto GaitLill'tart PIf " restart decfs) CounterG" F #oto GL'\ne%t PMoop until done return

P P CompC(eck" C(eck t(e comparator output and store t(e informtion in P 1utput? LKRsample CompC(eck? P$rocess? Moop until a transition" clear LKR@" POait till ne%t @ transition 'C'ampleM?  btfsc CKC12" C1=L #oto 'C'ampleM 'C'ampleM/? PGas a loO" Oait for a (i#(  btfss CKC12" C1=L #oto 'C'ampleM/ movfOLKR@ movOf LKRsample clrf LKR@ return

P'tore t(e result in LKRsample PClear LKR@ for t(e ne%t bit

P P YetUitCount" Count number of bits until t(e ne%t c(an#e P 1utput? UitCount P ,ddress? UitMocation" 2e%tF'R  P =se? MastUit;al" UitCount" 2e%tF'R" UitMocation" LempG YetUitCount? clrf UitCount  btfss MastUit;al" @ #oto YUC\lastbit@ P #oto YUC\lastbit PMast bit is a  YUC\loop? call Yet2e%tUit  btfss 'L,L='" ^ #oto YUC\done incf UitCount" F PContinue if value is a )ero #oto YUC\loop YUC\done? PDone if bit c(an#e to one  bcf MastUit;al" @ return

YUC\lastbit@? PMast bit is a @ YUC\loop@? call Yet2e%tUit  btfsc 'L,L='" ^ #oto YUC\done@ incf UitCount" F PContinue if value is a one #oto YUC\loop@ YUC\done@? PDone if bit c(an#e to one  bsf MastUit;al" @ return P P Yet2e%tUit" Yet a bit from t(e buffer  P 1utput? ^ P ,ddress? UitMocation" 2e%tF'R" UitMocation   for M'U Yet2e%tUit? movfO 2e%tF'R  movOf F'R  movfO UitMocation movOf CounterU decfs) UitMocation" FPYo to t(e ne%t bit #oto Y2U\ne%t'tep movlO dXBX movOf UitMocation incf 2e%tF'R" F PRollover for t(e ne%t read Y2U\ne%t'tep? clrf LempG  bsf 'L,L='" C Y2U\loop? rlf LempG" F PLempG contain bit mask   decfs) CounterU" F #oto Y2U\loop movfO LempG andOf I2DF" G PResult in ^ return PVVVVVVVVVVVVVVVVVVVVVVVVVVVVV '=UR1=LI2E P P 'end&e%" 'end a sin#le bJte out of serial port" (e% format P Input? data stored in G 'end&e%? movOf Lemp sOapf Lemp" G andlO @@f( call &e%Lable &e%GaitMoop?  btfss $IR" L`IF PGait till buffer is emptJ #oto &e%GaitMoop movOf L`REY

movf Lemp" G andlO @@f( call &e%Lable &e%GaitMoop/?  btfss $IR" L`IF PGait till buffer is emptJ #oto &e%GaitMoop/ movOf L`REY return

P P 'endUin" 'end a sin#le bJte out of serial port" binarJ format P Input? data stored in G 'endUin? movOf Lemp movlO B( movOf UinCnt UinGaitMoop?  btfss $IR" L`IF PGait till buffer is emptJ #oto UinGaitMoop movlO X@X  btfsc Lemp"  movlO XX movOf L`REY rlf Lemp" F decfs) UinCnt" F #oto UinGaitMoop return

P P Rcv&e%" Receive a sin#le bJte from serial port in (e% format P 1utput? data stored in 1utput Rcv&e%?  btfss $IR" RCIF #oto Rcv&e% movfORCREY movOf 'erData movOf L`REY P 'end it back out movlO @( subOf 'erData" F movlO @( subOf 'erData" G  btfsc 'L,L='" C #oto Metter RtnMetter?

PFG P $ositive means letter input

sOapf 'erData" G movOf 1utput Rcv&e%Moop?  btfss $IR" RCIF #oto Rcv&e%Moop movfORCREY movOf 'erData movOf L`REY movlO @( subOf 'erData" F movlO @( subOf 'erData" G  btfsc 'L,L='" C #oto Metter/ RtnMetter/? movfO'erData iorOf 1utput" F call ''pace return Metter? movlO @( subOf 'erData" F movlO @( subOf 'erData" G  btfsc 'L,L='" C #oto MetterE #oto RtnMetter MetterE? movlO dX/X subOf 'erData" F #oto RtnMetter Metter/? movlO @( subOf 'erData" F movlO @( subOf 'erData" G  btfsc 'L,L='" C #oto Metter/E #oto RtnMetter/ Metter/E? movlO dX/X subOf 'erData" F #oto RtnMetter/

P 'end it back out

PFG P $ositive means letter input

P $ositive means bad input

P $ositive means bad input

P P Mon#DelaJ" 0 cJcles" inscJcle //.0u' for BK() clock  lon#\delaJ? movlO dX0X movOf Counter 

lon#\delaJ\M? decfs) Counter" F #oto lon#\delaJ\M return P P 'end'trin#" send t(e strin# out to serial port P Input? 'trin# location in G 'end'trin#? movOf Counter  'endMoop?  btfss $IR" L`IF PGait till buffer is emptJ #oto 'endMoop call 'trin#'tart iorOf ^ero" G  btfsc 'L,L='" ^ P^ero is t(e end of strin# return movOf L`REY incf Counter" F movfO Counter  #oto 'endMoop P P 2eOMine" send s neOline c(aracter into serial port P Input? 2one  2eOMine?  btfss $IR" L`IF PGait till buffer is emptJ #oto 2eOMine movlO @d( movOf L`REY movlO @a(  2eOMineMoop?  btfss $IR" L`IF PGait till buffer is emptJ #oto 2eOMineMoop movOf L`REY return P P 'pace" send a space c(aracter into serial port P Input? 2one ''pace?  btfss $IR" L`IF PGait till buffer is emptJ #oto ''pace movlO X X movOf L`REY return P P 'endC(ar" send a c(aracter into serial port P Input? G

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF