Share this

Design of contactless IC card prepaid electricity meter

2026-04-06 06:23:54 · · #1
Abstract: The working principle and hardware circuit of the contactless IC card prepaid electricity meter are introduced, its working process is discussed, and a program flowchart is given. Keywords: contactless IC card prepaid electricity meter, microcontroller, user electricity metering accuracy depends on the accuracy of the current transformer and the electricity meter. Contact IC card prepaid electricity meters have emerged, which transforms the charging from the cumbersome manual meter reading and manual pricing to user card purchase of electricity, realizing the automation of electricity fee collection and management. However, it cannot solve the problems of passive (no power supply in the card) and contactless [2-8]. Contactless IC card (also known as radio frequency card) is a new technology developed abroad in recent years [1]. It successfully combines radio frequency identification technology and IC card technology, solving the problems of passive and contactless. Radio frequency card does not require a dedicated power supply; it has no mechanical contact with the reader, avoiding contact failure; its surface has no exposed chip, is waterproof, and is not prone to problems such as electrostatic discharge and bending damage; radio frequency card has no front or back when in use. In summary, contactless IC cards are characterized by high reliability, ease of use, and fast operation. This paper presents a successful smart prepaid electricity meter developed using contactless IC cards. 1 Working Principle 1.1 Working Principle of Contactless IC Cards The contactless IC card system consists of two parts: a reader/writer and a contactless IC card. The application system operates the card through the reader/writer; the reader synchronously performs short-range communication via radio frequency signals and provides energy to the chip on the card; the contactless IC card responds to the reader/writer's instructions and reports the processing results. The contactless IC card obtains high-voltage energy through coupling in a specific alternating magnetic field via a coil connected to the IC chip. The contactless IC card reader/writer emits a strong alternating magnetic field through a transmitting coil, empowering the IC card with energy. Data is written by intermittent encoding of the magnetic field, and the data sent by the IC card is read by sensing the magnetic field generated by the IC card through the coil. The IC card obtains energy through the alternating magnetic field, obtains the data written by the reader/writer by checking the continuity of the magnetic field, encodes and modulates it according to the set pattern, and sends the data to the reader/writer. The communication between the contactless IC card and the reader includes reset response, anti-collision, card selection, mutual authentication, data block operation, and abort. 1.2 Working Principle of Prepaid Electricity Meters Prepaid electricity meters can be divided into electronic and electromechanical types, differing in their energy conversion components. The former performs A/D conversion on voltage and current, then multiplies and accumulates the sampled values ​​to obtain the user's electricity consumption; the latter uses the mechanism of the original induction meter, reading the data from the rotating disk through a photoelectric sensor to obtain the user's electricity consumption. To save costs, an electromechanical meter is selected. This system uses the AT89C52 as the host, adding a pair of infrared transmitters and receivers to the original ordinary single-phase electricity meter to count the rotation of the rotating disk. The host completes the recording, accumulation, display, and control functions of the user's electricity consumption. A contactless IC card is added to complete the currency conversion and electricity consumption information transmission between the power supply management department and the user. The working principle of this system is as follows: (1) When a user pays for electricity at the power supply department with an IC card, the power supply department places the user's IC card on a reader connected to a PC, and the card writing program writes a certain amount of electricity on the IC card that matches the amount paid by the user. (2) When the user takes the IC card home, he/she swipes the card across the prepaid electricity meter at home, and the amount of electricity on the card is read by the host and added to the remaining amount of electricity in the prepaid electricity meter. Since the machine uses a backup battery, it is not afraid of losing data when the power is off. (3) When the meter dial rotates, the infrared transmitter and receiver tube converts the dial number into electrical pulses and sends them to the microcontroller. The microcontroller records the number of rotations of the dial. When the number of rotations is equal to the meter constant, the microcontroller controls the remaining amount of electricity in the memory to be reduced by one degree. (4) The microcontroller monitors at any time whether the remaining amount of electricity in the memory is less than 15 degrees. If so, it lights up the LED indicator that the electricity consumption is about to run out, prompting the user to take the card to the power supply department to purchase electricity again. (5) When the microcontroller detects that the remaining electricity in the user's meter is completely used up, it controls the relay to cut off the user's power supply. (6) This device is a secondary instrument, and its accuracy mainly depends on the primary instrument. As long as the dial rotates normally, the secondary instrument will not introduce errors. 2 Hardware Circuit The hardware circuit structure diagram of the contactless IC card prepaid electricity meter is shown in Figure 2. The main control unit in the figure uses the AT89C52 microcontroller, which has 8K bytes of fast erase and write memory (FLASH) and does not require an external program memory (EPROM). The external circuit mainly includes: a four-digit LED display circuit, a meter dial detection circuit, a relay circuit for controlling power supply, a ringing control circuit, an RS232 serial communication circuit, a watchdog reset circuit, a power control circuit, and an SHC1701 read and write module for controlling the contactless IC card. The SHC1701 RF module is the core unit of the IC card reader and writer. It consists of an SHC1501 dedicated circuit and an RF circuit, covering all access operations to the contactless IC card SHC1101. Figure 3 shows the interface between the IC card reader/writer module, display circuit, and microcontroller. A 4-digit common-anode dynamic digital display tube is used. The displayed characters are sent from the microcontroller's P0 port to the 74LS374 latch, then driven by the ULN2003 display driver chip. P1.0 to P1.3 control the dynamic display of each digit. The display circuit shows the available electricity usage. An error message is displayed when a card reading error occurs. When depositing electricity with the power company, the amount of electricity stored on the card is displayed. The pulse signal generated by the meter's rotating reading head (infrared transmitter/receiver) is output to the microcontroller's P1.4 port via a NOT gate. The microcontroller monitors the P1.4 port in real time. The RS232 serial communication circuit uses the MAX232 chip to realize data exchange between the microcontroller and the microcomputer. The microcomputer mainly uses VB communication controls to communicate with the microcontroller via RS232, controlling the microcontroller through pre-defined characters. When the internal electricity consumption is exhausted, the microcontroller sets port P1.5 to low level, and the relay control circuit cuts off the user's power supply. The watchdog circuit is composed of a 4538 monostable circuit. When powered on for the first time, the CLR terminal is low level, making the output Q low level, thereby resetting the system. During normal operation, the microcontroller sends a low-level pulse during each main program loop to trigger the monostable circuit; when the program is disturbed and runs out of control, the monostable circuit is reset because it does not receive the trigger pulse. At this time, the output Q=0, causing the system to reset. 3 Software Design 3.1 User-side electricity meter billing program 3.1.1 Main functions of the microcontroller system program (1) Reading valid contactless IC card function. Perform anti-collision, password authentication, card number authentication, etc. on the card, and read the data stored in the card, then clear the card and stop the card. (2) Completing the pre-charge function of the electricity meter. Add the electricity consumption reading from the IC card to the remaining electricity consumption in the microcontroller memory, and store it back in memory. (3) Display function. The system periodically scans and dynamically displays the remaining electricity in the machine. In addition, when an error occurs while reading or writing the IC card, an error signal is displayed. (4) Serial communication interrupt function. When the microcomputer sends a data acquisition command to the microcontroller, the microcontroller executes the serial communication interrupt service subroutine, authenticates the user's number, sends the user's electricity consumption and remaining electricity back to the microcomputer, and then returns from the interrupt. (5) Electricity counting function. The system monitors the pulse signal sent by the meter's rotary reading head (infrared transmitter and receiver tube) in real time. When the pulse signal changes from high level to low level, the counter COUNT is incremented by 1; when the COUNT value is equal to the meter constant (revolutions/degree), the remaining electricity is decremented by 1, the electricity consumption is incremented by 1, and COUNT is cleared to zero. (6) Alarm power-off function. When the remaining electricity in the machine is less than 15 degrees, the LED indicator that indicates that the electricity consumption is about to run out is lit, prompting the user to bring the card to the power supply department to purchase electricity again. When the remaining electricity in the user's meter is completely used up, the control relay cuts off the user's power supply. The user can only continue to receive power after depositing the electricity amount again. The microcontroller system program consists of the main monitoring program, IC card processing subroutine, electricity counting subroutine, serial interrupt service subroutine, etc., and their block diagrams are shown in Figure 4 (a), (b), (c), and (d). 3.1.2 Main functions of the VB user interface program (1) Display. Display the corresponding user information according to the input user number. (2) Acquisition. Send the user number to the microcontroller through the communication control. After the microcontroller authenticates the user number, it returns the user's electricity consumption and remaining electricity amount. (3) Writing. Add the user number and date to the collected data and write it to the database for query. (4) Viewing. View the electricity consumption and remaining electricity amount of each user; view all electricity consumption. 3.2 Power supply department deposit and management program 3.2.1 Main functions of the microcontroller system program (1) System initialization settings. Set the register address, interrupt source entry, load the IC card authentication password, and set the working mode of the serial port, timer 0 and timer 1, etc. (2) Receive control characters sent by the microcomputer. Execute the serial interrupt service subroutine. If the control character is R, perform operations such as querying the IC card, anti-collision, card selection, and authentication, and return the card number to the microcomputer. If the control character is W, write the electricity purchased by the user into the IC card, read out the written electricity, and then stop the card. (3) Display function. Display the electricity stored in the IC card. If there is any error during the operation of the IC card, the error message will be displayed to prompt the user. The program consists of the main program and the serial interrupt service subroutine, etc. Their block diagrams are shown in Figure 5(a) and (b). 3.2.2 Main functions of the VB user interface program (1) IC card deposit function. When the user deposits the card at the power supply department, the staff will place it on the reader and press the "read card" button. The microcomputer sends the character "R" to the microcontroller. The microcontroller performs the corresponding interrupt processing and returns the card number. The system displays the corresponding user information according to the returned card number. After confirming that there is no error, the user enters the amount paid by the user, and the system automatically converts it into electricity. Press the "Deposit" button to deposit the electricity consumption into the IC card, and at the same time write the relevant deposit information into the database for query. (2) Query function. Query user information, IC card information and user electricity consumption. You can selectively query according to the entered user number or electricity card number. (3) Maintenance function. Database maintenance includes adding new records, deleting unnecessary records and updating existing records. The database used in this system is built by MSAccess and is associated with the user interface through VB data object controls. All operations on the data update the associated database in real time. This paper combines contactless IC card technology with computer technology to develop a multi-functional electricity metering and charging device. This system realizes the electronic charging of electricity consumption, changes the unreasonable situation of charging after electricity consumption, and promotes the scientific management of electricity metering and charging. The device utilizes the function and structure of the old mechanical meter, reduces the cost of transformation, and is suitable for widespread use.
Read next

CATDOLL Miho Soft Silicone Head

You can choose the skin tone, eye color, and wig, or upgrade to implanted hair. Soft silicone heads come with a functio...

Articles 2026-02-22