Final Project Report E3390 Electronic Circuits Design Lab RFID Access Control System
Final Project Report E3390 Electronic Circuits Design Lab RFID Access Control System
Submitted in partial fulfillment of the requirements for the Bachelor of Science Degree May 11, 2007 Department of Electrical Engineering Columbia University
Table of Contents
1. 2. 3. 4. 5. 6.
7.
Executive Summary Block Diagram, Design Targets, and Specifications Individual Block Descriptions Bill of Materials Health, Safety, & Environmental Issues Final Gantt Chart Criticism of This Course
1. Executive Summary RFID is a contactless identification technology based on the transmission of radio frequency waves. Its advantage over its predecessor, the barcode system, is its increased range and increased data storage capacity. The typical RFID system consist of three main components, the transponder (or tag), the reader, and the application. The tag is the data storage component. The tags we will use in this project will be passive tags, meaning they do not have an internal power supply. The reader activates, powers, and communicates with the tag using electromagnetic waves. Once activated, the tag will respond to the reader with the information that is stored in its memory. The reader extracts this information and sends it the application component for processing. Our project demonstrates a low-cost RFID access control application. Tags will be used as keys, with the system able to configure tags to be allowed or denied.
Block Diagram
Read Command
3. Individual Block Descriptions RFID Tag Atmel read-only TK5530 tags were chosen for this system. These tags respond to a 125 kHz wave with an 125 kHz AM wave containing a 64-bit rolling code at 3.9kbps. The code contains an 8 bit header followed by a unique ID code. The data is encoded using Manchester encoding. These tags were chosen because of our knowledge of how to demodulate AM compared to tags that use other kinds of schemes such as FSK or PSK. Also, our application did not require. Also, we did not require the increased functionalities of more expensive Read/Write tags.
RFID Tag Reader The purpose of the Reader component is to activate and power the tag, demodulate the response, and prepare the signal for the microcontroller. The components of this reader are: the antenna, signal generator, peak detector, low pass filter, and voltage comparator. Antenna Many antenna configurations were constructed for testing. Each had limited range and were difficult to use because the coils would come out of place. In the end, we settled on a pre-made antenna that consisted of two coils wrapped around a ferrite coil in a transformer configuration. The inductance of the coils were measured, and an appropriate capacitor was chosen to tune the antenna to the resonant frequency using the parallel tank circuit equation:
This antenna still had very limited range. The range was no farther than one. But with this configuration it was possible to rest the tag directly on the antenna, allowing for a consistently good signal. Signal Generator A 125 kHz square wave signal generator is required to drive the antenna. We generated a signal from the MCU for this purpose, but due to time constrictions we did not have time to build a circuit to make the signal have the necessary voltage. For now, we are using a function generator as the signal generator. It is set to output a square wave at 125 kHz, 10 Vpp. Peak Detector The peak detector is used to extract the envelop of the AM signal. Figures 3 and 4 show the antenna input without and with the tag in proximity. Figure 5 shows the signal after the peak detector.
Low Pass Filter A first order low pass filter with a cutoff of 10 kHz was constructed to reduce the carrier frequency. The data is at 3.9 kHz.
Voltage Comparator The envelop signal is converted to a square wave in preparation for sending to the microcontroller. The LM411 comparator was used. Notice the noise in the signal. This noise greatly affected what the MCU was reading, causing inconsistent results in our application.
Two inverted Schmitt triggers were used to smooth out the edges. The resulting output was sent into the MCU.
10
Microcontroller The PIC16F7X MCU was programmed in assembly language. The MCU is responsible for decoding the Manchester encoded data, extracting the data, controlling the LEDs that indicate the ID, and managing the access control.
ID Extraction The first step in reading the data is to find the header of the code. The Atmel chips have a header of E6 ( 11100110) We devised a scheme to find the header as follows:
11
- First, phase correction: -Keep sampling input pin (every two usec) until a high is read -Next, keep sampling input pin until a low is read - Finally, keep sampling input until a high is read - Second, wait just over half a period to adjust for Manchester encoding and sample there at 3.91 kHz -Sample 8-bits and check if all zeros; if not, rotate bits left and sample the next bit; repeat until all zeros - Now keep shifting 8-bit window until the first high-level is found; this bit and the next 7 bits make up the header - After the header, sample another 8-bits: this is the unique tag ID
Figure 9: Manchester Encoding Once decoded and extracted, the data is output to the LEDs. See code and Schematics for more detail.
12
13
14
15
# 5 1 1 2 2 3 4
LM411
7414 Schmitt Trigger
Approx. 38.70
5. Health, Safety, and Environmental Issues a. Product Dangers No dangers related to the use of our project are noted. Care should be taken to hook up the circuit properly and use of correct voltages. b. Health Hazards No health hazards associated with RFID technology have been noted. c. Environmental Hazards i. FCC regulations cover RFID devices ranging in frequency from 9kHz to 64 GHz. According to FCC Part 15, Section 15.209, the maximum E field for a device operating between .009-.490 Mhz at a measuring distance of 300m is 2400/f uV/m. ii. Electric Shock Problems. All wires are insulated,
16
6. Gantt Chart
RFID Reader Jeffrey Mok, Joseph Kim 30Jan 1 Research RFID Types, Existing Apps (Jeff, Joe) 6-Feb 2 13Feb 3 20Feb 4 27Feb 5 6-Mar 6 13Mar 7
17
7. Criticism of this Course The most positive thing about this course was the sense of achievement when the project was complete. We took a kind of technology that we did not any experience with before, but were able to use relatively simple ideas from our classes to implement commercial technology. We may have spent too much time at the beginning of the semester defining our project. Perhaps this is good in that it reflects the detailed planning required in industry before a project is undertaken. But I think we would have benefited from a stricter schedule. Also, the possibility of this course becoming a two semester course should solve that problem. A review of some electronic circuits material would have helped too. Again, a two semester course would help with this. It would also be interesting to see how some of the material from the other EE tracks could be part of the projects.
18
Appendix Software Code LIST P=16F74 title "Main Operator" __CONFIG B'11111110110010' ;********************************** ; ; RFID MCU Program ; 3-2007 Joseph Sungee Kim ; [email protected] ; ;********************************** ; OSC1 freq (clock in) = 4MHz ; Instruction cycle approx 1 usec ; ; ;********************************** #include ; ; ; <P16F74.INC>
Variable Declarations 20h 21h 22h 23h equ equ equ 27h equ equ org 00h 28h 29h ;Reset Vector 24h 25h 26h
Count equ Temp equ State equ TagID equ Cycle1 Cycle2 Cycle3 Tag1 equ Count2 Count3
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ; Port Initialization ; initPort clrf PORTD ; LED displays (OUT) clrf PORTC ; Push buttons (IN) clrf PORTB ; DIN(b0-OUT),DOUT(b1-IN) bsf STATUS,RP0 clrf TRISB ; set all PORTB as output bsf TRISB,1 ; set DOUT as input movlw B'11111111' movwf TRISC ; Port C - all inputs clrf TRISD ; Port D - all outputs bcf STATUS,RP0 clrf Count clrf Temp movwf Tag1 ;default: Tag1 = '11111111' finished ; ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ; ; main driver call cycleLED ; SCNTRL HIGH (slck ; green led off ; red led off ; check config ;if config high ;if config low
ModeSelect ; bsf PORTB,2 high) bcf PORTB,3 bcf PORTB,4 btfsc PORTC,1 goto cMode goto initComm ;****** cMode btfss PORTC,1 goto initComm
20
btfss PORTC,0 goto cMode call SwitchDelay call getTagID movfw TagID movwf Tag1 bcf PORTB,4 movf Tag1,W movwf PORTD bsf call bcf call bsf call bcf call bsf call bcf call goto IDreject bcf bsf PORTB,3 PORTB,4 PORTB,3 tDelay PORTB,3 tDelay PORTB,3 tDelay PORTB,3 tDelay PORTB,3 tDelay PORTB,3 tDelay cMode
initComm ; first, flash LEDs on/off twice to indicate initComm start btfsc PORTC,1 goto cMode btfss PORTC,0 goto initComm call SwitchDelay call getTagID movfw Tag1 subwf TagID,F incf TagID,F decfsz TagID,F ;check green button ;if low, cycle ;debounce
21
goto IDreject bcf PORTB,4 bsf PORTB,3 goto initComm ;;;;;;; getTagID ; ; movlw movwf movlw movwf bcf B'11111111' Cycle1 9Bh Cycle2 State,1
movlw B'11111111' movwf PORTD call tDelay movlw B'00000000' movwf PORTD call tDelay movlw B'11111111' movwf PORTD call tDelay movlw B'00000000' movwf PORTD seq2 ;;SYNCHRONIZE Hscroll btfsc PORTB,1 goto Hscroll Lscroll btfss PORTB,1 goto Lscroll movlw D'64' movwf Count2 ;;move forward a half-period (manchester) call hDelay call grabByte ; goto check4header ; goto readTag ;DIAGNOSTIC! goto diag1
22
;;;;;;; nextBit decfsz Count2 goto ModeSelect movf Temp,TagID rlf TagID,F call c2Delay bcf TagID,0 btfsc PORTB,1 bsf TagID,0 call c2Delay check4header movlw b'11001110' movf TagID,Temp subwf TagID,F incf TagID,F decfsz TagID,F goto nextBit call c2Delay ;;;;;;; ;Scroll until byte is all zeroes: diagNB rlf TagID,F call c2Delay bcf TagID,0 btfsc PORTB,1 bsf TagID,0 diag1 incf TagID,F decfsz TagID,F goto diagNB goto diag2 ;;find first high: diagNB2 rlf TagID,F call c2Delay bcf TagID,0 btfsc PORTB,1 bsf TagID,0 diag2 btfss TagID,0 goto diagNB2
23
;HEADER
;;next 7: call call call goto diag3 movlw movwf diagNB3 rlf TagID,F call c2Delay bcf TagID,0 btfsc PORTB,1 bsf TagID,0 decfsz Count3 goto diagNB3 goto dispID ;;;;;; ;256 cycles <==> 1/(125000/32) readTag call call ;checkID ; ; tagFound ; ; ; ; dispID movlw B'10101010' movwf PORTD call tDelay movlw B'01010101' movwf PORTD call tDelay movlw B'10101010' movwf PORTD
24
;DIAGNOSTIC ;DIAGNOSTIC
grabByte cDelay ; increment TagID ; if TagID was not all high, set ; if tagFound bit cleared, loop ; else display ID
incfsz TagID,W bsf State,1 btfsc State,1 goto dispID decfsz Cycle1, F goto seq2
call tDelay movlw B'01010101' movwf PORTD movf TagID,W movwf PORTD return ;;;;;;;;;;;;;;;;;;;;; cycleLED movlw B'00000001' movwf PORTD call tDelay movlw B'00000010' movwf PORTD call tDelay movlw B'00000100' movwf PORTD call tDelay movlw B'00001000' movwf PORTD call tDelay movlw B'00010000' movwf PORTD call tDelay movlw B'00100000' movwf PORTD call tDelay movlw B'01000000' movwf PORTD call tDelay movlw B'10000000' movwf PORTD call tDelay movlw B'00000000' movwf PORTD call tDelay return ; debounce switch: SwitchDelay movlw ; move TagID to W ; display on LEDs
D'20'
25
movwf delay
decfsz Temp,F goto delay return ;~tenth-second delay: tDelay movlw 01h movwf Cycle1 movlw 98h movwf Cycle2 tloop decfsz Cycle1, F goto tloop decfsz Cycle2, F goto tloop return ;~255 cycles cDelay movlw movwf cloop decfsz Cycle3, F goto cloop return c2Delay movlw movwf c2loop decfsz Cycle3, F goto c2loop return c3Delay movlw movwf c3loop decfsz Cycle3, F goto c3loop return D'83' Cycle3 D'81' Cycle3 D'84' Cycle3
26
;half a period hDelay movlw movwf hloop decfsz Cycle3,F goto hloop return grabByte clrf btfsc bsf call btfsc bsf call btfsc bsf call btfsc bsf call btfsc bsf call btfsc bsf call btfsc bsf call btfsc bsf return ;;;;; Fault bsf PORTB,3 bsf PORTB,4 goto Fault ;green LED ;red LED TagID PORTB,1 TagID,7 cDelay PORTB,1 TagID,6 cDelay PORTB,1 TagID,5 cDelay PORTB,1 TagID,4 cDelay PORTB,1 TagID,3 cDelay PORTB,1 TagID,2 cDelay PORTB,1 TagID,1 cDelay PORTB,1 TagID,0 ; clear TagID ; if DIN low, skip next ; if DIN low, skip next ; if DIN low, skip next ; if DIN low, skip next ; if DIN low, skip next ; if DIN low, skip next ; if DIN low, skip next ; if DIN low, skip next D'41' Cycle3
27
28