How to design a RFID card application system?
1.Contactless IC Card Overview
Contactless lC Card, also known as RFID card, consists of lC chip and induction antenna. It is packaged in a standard PVC card. The chip and antenna have no exposed parts. It is a new technology developed in recent years. Since the RF IC card has the advantages of large storage capacity, strong anti-interference ability, portability, and high security, it has been widely used in many fields such as public transportation and finance. This paper mainly takes the access control management system of a tourist attraction as an example to introduce the development ideas and design process of the application system based on RF IC card.
2. system requirements and design ideas
At present, most of China's tourist attractions still follow the traditional management mode. Tickets generally use paper tickets. This method not only has large financial loopholes in the process of ticket sales and ticket inspection, but also is prone to stealing tickets, missing tickets, and reusing tickets. Phenomenon, it is also impossible to timely and accurately count the number of tourists, traffic and consumption in the region. The use of radio frequency IC cards in the issuance of tourist attractions tickets can not only effectively eliminate these hidden dangers, block loopholes, but also facilitate the issuance of annual and monthly cards. In addition, there are a lot of amusements in general attractions, especially on holidays. There will always be long people in front of the ticket booths in the playground. In order to avoid the wasted time for tourists to queue up for tickets and the possible loss of consumption, visitors to the attractions can Buy a temporary card for card rides when entering the market, and then return the card when you are on the scene. In this way, when the tourists are playing, they can save the trouble of queuing for ticket purchases, greatly increasing the enthusiasm for consumption and the intensity of consumption. It can be seen that the development of access control management system based on radio frequency IC card in large-scale tourist attractions can not only realize the automatic management of scenic spots, but also stimulate the consumption of tourists through the issuance of radio frequency IC cards, and realize the different entertainment projects of tourists. Automatic charge.
The tourist attraction has a main entrance, two card inspection channels, and four main playgrounds. Consider using five computers to form a local area network. Due to the large area of the scenic spots and the distance between the different playgrounds, the long distance connection cannot be achieved by the R5485 serial network. Therefore, the system is equipped with a computer and a card reader for each playground. Choose a computer A with better performance and put it at the entrance of the attraction to realize the card-swapping function of issuing and accessing the main door. The card reader and the card-issuing controller are respectively connected to its COM1 port and COM2 port: another four computers B , C, D and E are set in 4 playgrounds for card consumption, the corresponding card reader is connected to the COM1 port of the host computer, the recharge points are added in the two main playgrounds, and the two card issuers are respectively connected. Go to the COM2 port of the host computer. Since the system selects the radio frequency IC card with storage function, the deduction of the amount is completed on the radio frequency IC card, and the background database is mainly used for storing information to complete the query and statistics operations, and the real-time requirement is relatively low, so the computer A is considered as The server, which stores the information of the centralized database, the login verification of the computer B, C, D, E client programs, the verification of the validity of the IC card, etc., all need to access the database in the computer A to complete, and the local database is only stored in the designated playground. The information consumed by the card can be selected to update the information of the centralized database with relatively idle time.
According to the demand, we have roughly determined the main functions of the system implementation, namely card issuing function, card swipe function, card recharge, report loss and unhooking, query statistics, database maintenance, user management, etc. The execution process is: visitors can pass before entering the scenic spot. The card issuance function for permanent or temporary IC card, the relevant information is stored in the corresponding permanent or temporary IC card table in the centralized database; before entering the attraction or playing a certain amusement project, according to the permanent card or the temporary card to access the corresponding table, check whether the card is Is a valid card, if not, give the corresponding prompt information, refuse to enter, otherwise, through the credit card program according to the amount set in advance, determine whether the balance in the IC card is sufficient, if the balance is insufficient, the corresponding information is prompted, Allow entry, otherwise change the balance in the IC card, and record the card information in the local database, as the basis for updating the consumption table information in the centralized database in the future; the temporary card can be returned according to the balance when returning from the park, in order to facilitate the query statistics, After the card is returned, in addition to the corresponding record of the temporary card table, it should also be deleted. Record the operation in the corresponding consumption table.
3.1 Access IC card issuer and card reader
In VB, the upper computer can use the two methods to communicate with the serial port. One is to call the API function of Windows, and the other is to use the communication control of VB. The system uses the MSComm communication control provided by VB to realize access to the IC card issuer and the card reader. Note that since the design of the system involves the communication between the upper and lower machines, each lower machine must be assigned a unique machine number in advance, and the service of the card can be determined according to the machine number of the card machine during processing.
The MSComm control is placed on all program interfaces that provide communication functions with the lower computer. In order to realize the communication between the upper and lower machines, the MSComm control has many parameters to be set before use, such as determining which port of the lower computer and the upper computer is connected, setting the baud. Rate, etc., assuming that the name of the MSComm control is MSComml, and the IC card reader is connected to the serial port 2, the specific attribute settings refer to the following program segment:
MSComm1.CommPort=2 set the serial port number
MSComm1.SetTIngs = "9600, N, 8, 1" Properties of the serial port
When InputLen is set to 0, using Input will cause the MSComm control to read all the contents of the receive buffer.
MSComm1.InputLen = 0
MSComm1.InpulMode = comlnputModeBiary binary acceptance mode
MSComm1.RThreshold =1, every 1 byte response message
MSComm1.InBuferSize=1024 sets the byte length of the receive buffer
MSComm1.Po~Open=True, open the communication serial port
Generally, the above program segment is placed in the Load event of the form. When the card issuance function or the card swipe program is executed, the serial port can be opened by running the program. As long as the lC card is close to the card issuer or the card reader, they can be read out. Save the card number and balance information in the C card, MSComm control will automatically trigger the OnComm event process, in the process, you can read the data in the receive buffer, get the relevant card number and balance information, according to the requirements of the database Take action.
3.2 Access Control of Multiple Card Readers in Serial Networks
Since only one card reader is connected to the computer through the RS232 serial port for the card consumption of each amusement item, the passive mode is adopted during the card reader program control, and only after the card reader receives the information, the host computer is triggered to process it. If it is a large playground, you may need to set up multiple card readers to swipe at the same time. What should I do? If multiple tourists are swiping at the same time, what should I do? In this system, at the entrance of the attraction, due to the large traffic, the waiting is reduced. Time, improve the speed of ticket checking, set up two card reading channels, the two card readers are connected in parallel through the RS485 network, using the RS4851RS232 adapter and the serial port of the host computer. In order to prevent conflicts caused by simultaneous card reading, the control of multiple readers connected in parallel with the RS485 network generally does not passively wait for the reader trigger event, but uses active mode programming. We use the timer control TImerl to control the program to access multiple readers in sequence at a certain time interval, and achieve good processing results. The reference block is as follows:
Private Sub Command1_Click() ‘Access to the specified reader block
m = m + 1
‘o array saves the machine number of each card reader in the RS485 network, UBound(a) gets the number of card readers, and accesses each card reader in the specified order when reading the card.
If m 》 UBound(a)Then
m = 1
If Not MSComm1.PortOpen Then MSComm1.PortOpen= True
3.3 centralized database update processing
In order to improve the processing speed and reduce the impact of parallel access of multiple devices on system performance, the system saves the card information processed by each client program in the local database, but also brings a series of problems, such as centralized Database card data is updated in a timely manner, and abnormal conditions are handled during database update. In order to improve the security of the system, the update processing of the centralized database is implemented by a stored procedure. The client program implements the update operation of the remote database by calling a pre-programmed stored procedure. Different from the standard SQL statement, since the stored procedure is compiled and optimized by the database server, the running speed of the program can be effectively improved. In addition, the SQL statement in the stored procedure belongs to the transaction category, that is, all SQL statements in the stored procedure are executed. Either not executed, thus ensuring data integrity and consistency.
According to the needs of IC card business of a tourist attraction, this paper describes the design process and technology of the system in detail from the aspects of system design, access control of the card reader and update processing of the database. In addition to being applicable to access control management, the development technology of the Ic card application system introduced in this paper has certain popularity, and can be applied to parking lots, cinemas, campus cards, etc., and has broad application prospects. Judging from the operation and operation of existing systems, the development and use of the system have received good economic and social benefits.
Csm tech company provides IC cards, Contactless IC Card,RFID Card System. NXP MIFARE 1Kb 13.56Mhz, CPU contactless RFID big memory card,etc.