Tuesday, February 22, 2011

【 Weak current College 】 bus non-contact IC card reader application design 】

Summary: use the PHILIPS Mifare card company for IC card, design by RF technology as the core, MCU controller IC card reader on the bus automatic toll collection system. Manufacture of IC card reader can implement system card, card, features such as automatic toll, with safe, practical, convenient, fast, high-reliability features of the urban public transport service is frequent and trivial fees and management issues that have broad application prospects. Keywords: SCM contactless smart card reader and smart card reader overview now often come into contact with IC card has two kinds: contact and contactless IC card. Contact-type IC card through mechanical contact from the reader Gets the energy and the exchange of data; a non-contact IC card through the Induction coil RF from the reader gets energy and Exchange data, also known as RF cards. Currently common in society is the contactless IC card.  It has a storage capacity (in megabytes), the privacy feature strong (there are multiple password settings and authentication functionality), you can implement smart card. However, this type of card read/write operation is slow, is also not convenient, per-read and write, you must put the card correctly inserted into the reader of the estuary trough to complete data exchange so that, in public transport, attendance, and so frequently read and write to the card of occasions is inconvenient, and reader-contact and card IC card touch foot exposed, easily damaged and get dirty and bad. Non-contact IC card is based on radio frequency electromagnetic induction principle. It reads or writes the card in the reader within a certain distance away near to implement data exchange, without any contact, use a very convenient, fast, and not easily damaged. Accordingly, in public transport, access control, campus, enterprises and institutions, such as personnel management, entertainment and other aspects of broad application prospects. At present, China's introduction of RF IC card hasthe PHILIPS corporate Mifare and ATMEL company of Temic card. Following to PHILIPS Mifare card-based company, introduces automatic ticketing urban public transport IC card reader implementation. Second, the principle of non-contact IC card reader/writer for radio frequency identification technology as the core, used primarily in Reader 1 tablet Mifare card dedicated read-write processing chip – MMM micro module. It is a small maximum operation distance up to 20 ~ 30mm of Mifare read/write device for the core components, its features include modulation, demodulate, produce RF signal, security management and collision avoidance system. Internal structure is divided into radio frequency area and interface: RF zone contains the modem and the power supply circuit, connected directly with the antenna; interface areas and MCU port connected with RF area linked to transmit/receive, 16-byte data buffer with, store, transmit key 64 on ROM, store, 3 sets of keys for a write-only memory and three confirmed and data encryption cipher machine, collision with anti-collision module and control unit. This is the RF card for wireless communication of core modules, and also the reader to read and write Mifare card key interface chips. Reader work, unceasingly to issue a set of fixed frequency of electromagnetic waves (13.6MHz), when the card close to the card with a LG series resonant circuit, their frequency and the reader of the same frequency, so that the electromagnetic wave excitation, LG resonant circuit produces resonance, so that there is a charge capacitor charging. At the other end the capacitances, a one-way conductive e pump, the capacitor within the charge to another within the storage capacitor. When the capacitor charging to 2V, this capacitor is used as power for a card for other circuits provide working voltage, the card data launches out or receive data and issued by the reader. III. hardware bus fare system structure more complex, link, public and non-contact IC card readers at least should include public transit vending machine, car and bus transit system card machine three reader. In addition to the vending machine requires keyboard, all hardware components in much the same. Figure 1 is a non-contact IC card and its reader hardware circuit schematics, mainly by MMM micro module, MCU, keyboard, display, memory, antenna and control circuit and PC communication TC232 serial communication interface circuit. (1) single-chip system SCM 89C52. It has within the Tablet 8 KB ROM, 256 bytes of RAM and 32 I/O port. P1 port and serial devices 24C64 and displays, alarm circuit connection; P0 port and MMM-module, used as a data cable; P2 estuary as a 4 × 4 keypad; P3 port is used to read and write control and interrupts. (2) keyboard circuit keyboard interface circuit with P2 port pick up into 4 × 4 structure, a total of 16 key.  Which digital key 10, 2 function keys, backspace and enter each one, there are 2 key temporarily not available.  Function keys with query and communication two keys. Query keys: sale of card member you can use this key query sale card amount and sales card records. Communication: the amount of storage as the reader is limited, so the reader card per sales for a period of time, the data in the reader through the RS-232 serial interface for communication with PC for playback and empty the reader. Data playback to a PC, through the analysis process, forming a variety of reports to bus companies grasp the card sale. (3) display circuit shows part of the digital display, use the serial input BCD code--decimal decoding driven display MC14499 to complete and display interface chip, to show the reader working state, entered data or read the remaining in the IC card as well as error messages, etc. This device mainly 1 20 and displacement-bit registers, 1 latch, 1 multiple output devices. Multi-channel output for output in BCD code decoding by segment decoder, replaced seven yards (abcdefg) and decimal DP to paragraph drive output. (4) memory reader designed storage. Memory selection 24CXX series serial E2PROM. Sales in the main storage card, card number, the sale of card member number, amount, sale sold card card date, sales amount and sales kazong kazong records; in a major repository of on-board machine IC card, passengers, drivers, and credit card number and other information. Displays MC14499 driving 4-Yin digital tube. Normally, each time you want to put the reader to the transit center will reader stored information playback to save PC. The reader can use in memory, its storage 24C64 as 8KB, if necessary you can also use larger memory such as 24C128 or 24C256, etc. (5) monitoring circuit monitoring circuit adopts DS1232L chip. It is a watch dog timer, its function is: when you power on and power-down RESET signal to produce 89C52; watchdog on the system for monitoring, prevention of panic. (6) the non-contact IC card contactless IC card Mifare card selection.  Its operating frequency as 13.6MHz, storage 1 KB-16 zones, each zone 2 set of password, each area of the storage area are independent of each other, so each zone can be used for a purpose (generally 0) for a smart card. Because of the Mifare card password authentication mechanism and strict, saved information relatively reliable security, can be erased tens of times. Mifare card 16 zones, each zone is divided into 4 blocks, each block of 16 bytes. In vending machines with 1 zone for users stored blocks consisting of 0 blocks hold identity number, 1-2 blocks stored value, 3 blocks kept two sets of 6 bytes of the password and a 4-byte read-write access.
IV. programming the following to sales card machine-based presentation software design method. Taking into account the amount of the security sold card management, public transport company prior to making a good two IC ticket: one user IC ticket, and a member of the ticket sale card IC card. The two cards you can use the same area code, password and access conditions completely different, without confusion. Sale of card member you want to sell card requires you to go through a public transport company IC card, ticket sale card. Ticketing IC card memory on the sale of card Member ID number, allows sales to the maximum amount of cards, two sets of 6 bytes of the password and a 4-byte read-write access. Sale of card member sales card, prepaid card must from their ticket sales of IC card card amount subtracted, the IC card added to the user. When selling tickets to minimize the amount of IC card, to zero bus company billing, and then on ticketing IC card prepaid billing. In this way, the bus company's sales card distribution more outlets without chaos, and convenient user charge plus card, you can effectively prevent the ticketing service accounts are not caused by the capital loss. Programs include IC card read-write operation, the keyboard, scanner, display, memory, reading, writing and communications programs. 1. main program master key to complete the system variables of the initialization, circular scanning keyboard detection operation IC card, will the operation result storage and display. In the vending machine uses 8 KB for memory, main 24C64 content stored are: vending machine number (1 byte), sale amount kazong (3 bytes) and total (2 bytes). Sold per card record includes: user card identification number (4 bytes), sale card date (2 bytes), plus card amount (1 byte) and sale of card numbers (1 byte). Therefore the maximum energy storage 1023 Zhang sale card records. The main process as shown in Figure 2, the reader on the IC card operation process as shown in Figure 3. 2. keyboard scanner keyboard scan uses the reverse method reading keys: from P2 port high 4-output zero level, from P2 port low 4 bits read keyboard status; then from the P2 port low 4 bits output zero level, from P2 port high 4-bit read keyboard status, will be the result of two times read together can get the current key signature (see the table in TABLE). This table can be programmed to be converted to order code. With the current read signatures to order look-up table, use a unit record lookups. When in a table to have the signature, it's location (i.e. lookups) is the corresponding sequence code. Corresponding keyboard check key programs are as follows: P2, KEY: MOV; use reverse # 0FH method checks key
MOV P2,#0F0H
RET; no key is pressed
KEY1: MOV A, B; a key is pressed, the key code
MOV R3, # 0FFH; save order code module initialization
CJNE A, B, KEY3; outsourcing key code, please order codes
MOV A, R3; if it finds a key code, order code
KEY3: CJNE A, # 0FFH, KEY2; whether you have contracted for enquiries
RET; also see the key code is not found, no press processing
TABLE: DB 77H, 7BH, 0BBH; press the signature table
DB 0E7H, 0C7H, 0FFH3. display program according to figure 1, in the show circuit, P1-3 root I/O port line (P1.0, P1.1, P1.2) provide clock (CLK), serial data (DA) and enable signal (EN). MC14499 each receive 20-bit serial input data, the first 4 bits for the control of the decimal point of display digital tube, after a 16-bit is 4 digital tube of BCD code input data. In each frame data transfer, you must reset the EN 0; then transfer 20-bit data, data transfer finished, then 1 EN reset. Display program: DISP: CLR P1.0; Qing CLK
CLR P1.2; Qing EN
MOV R2, # 04; reset routing digits
MOV A,# 00
LCALL W14499; count display transfer sent
MOV R1, @ A; read the number to be displayed
MOV R2, # 08; reset routing digits
LCALL W14499
MOV R2, # 08; reset routing digits
LCALL W14499
SETB P1.2; reset EN bit
W14499: SETB P1.0; Qing CLK
RLC A; prepare bitwise sent count displayr>MOV P1.1, C; few moved into DA
CLR P1.0; Qing CLK
DJNZ R2,W14499
RET4. serial E2PROM, reading and writing programs for I2C bus 24C64 E2PROM. SCL-400kHz clock line, SDA is bi-directional data cable, A2, A1, A0 three digits of the selected address, that is, sliced I2C buses up to parallel 8 serial E2PROM chip. On the operation method by E2PROM read/write control command Word decided, as shown in Figure 4. Where "1010" for 4-bit read/write control code, R/W = read/write control bit: "0" for the write operation, "1" for read operations. So combined with Figure 1 shows the A2H is write control command words, read control command A3H. On memory and writing, first of all, the microcontroller to a START command 24C64 fat, start conditions. Then, the write command control word (such as A2H).  When 24C64 received the order, enter a write cycle, and then send the stored by the microcontroller, which determines the address data written to memory in which address, subsequently, the SCM will be stored in data feeds to SDA data line. Write cycle ends, the microcontroller and then issued a stop bit (STOP). Read operations on memory, first of all, the microcontroller to a START command 24C64 fat, start conditions. And then the write command control word (such as A2H). When 24C64 received the order, enter a write cycle, and then send the stored by the SCM. Store addresses sent successfully, the microcontroller to a START command 24C64 fat, start condition, then sends a read command control word (A3H). When 24C64 received the order, enter a read cycle, single-chip from SDA data line reads the specified data is stored in the address. Read cycle ends, the microcontroller and then issued a stop bit (STOP). (A) it is important to note that the memory operation, each read-write a byte, single-chip must send a response bits (ACK) to release the SDA line so that memory can continue to receive data. 5. the communication program in the reader, chip and PC communication is accomplished primarily by TC232 TTL level (0 ~ 5V) and RS232 level (+ 10 ~-10V) conversion (circuit shown in Figure 1), to complete the sale card machine saved sale card record of delivery. Communication format as: serial works 1, baud rate 9600baud, 1 start bit, 8 data bits, 1 stop bit, and validation.  The reader, the MCU program may use the C programming language. C language has a rich library functions, operation speed, compile, high efficiency, portability, and a software readable, easy to improve and expand (program). To increase the adaptability of the transit system, including the user's special requirements, anti-interference, rugged, in addition to the hardware on the use of monitoring circuit, the software also adopted a directive redundant and software traps.

No comments:

Post a Comment