Share this

Design of a CAN bus-based power meter reading system

2026-04-06 03:12:54 · · #1
Abstract: This paper introduces a CAN bus-based power meter reading scheme, designs the system's hardware and software, and elaborates on its working principle. The system utilizes an AT89C52 microprocessor in conjunction with multiple 8259A interrupt controllers to achieve distributed real-time acquisition, transmission, storage, and display of meter data. To address the issue of low data accuracy, an interrupt-driven acquisition method is adopted, which not only improves the accuracy of the acquired data but also enhances the system's reliability. Keywords: CAN bus interrupt mode, power meter reading system, CAN bus introduction. CAN operates in a multi-master mode, allowing any node on the network to actively send information to other nodes at any time. Node information on the CAN network is divided into different priorities to meet different real-time requirements. CAN uses non-destructive bus arbitration technology. CAN can transmit and receive data in several ways, including point-to-point, point-to-multipoint, and global broadcast, simply by filtering messages. CAN's direct communication distance can reach up to 10km (at speeds below 5kbit/s), and the communication rate can reach up to 1Mbit/s (at which point the maximum communication distance is 40m). Each frame of CAN information has CRC verification and other error detection measures, ensuring an extremely low data error rate. CAN's communication medium can be twisted pair, coaxial cable, or optical fiber, offering flexible selection. System Design The system consists of the following parts: pulse electricity meter, power acquisition unit, CAN converter, modem, and host computer. The system block diagram is shown in Figure 1. Figure 1. Block Diagram of the Electricity Meter Reading System. As shown in Figure 1, the power acquisition unit collects the pulse signals output by the pulse meters in residential buildings in real time. These signals are transmitted to the CAN bus via the CAN interface, then converted by a CAN converter and communicated with the host computer via a modem. This enables data acquisition, storage, metering, and display, allowing real-time monitoring of each user's situation in the entire community. System Working Principle Electricity Measurement Based on the structure of the rotary meter, the number of pulses is proportional to the number of revolutions of the rotary disc. The accumulated pulse count multiplied by a coefficient yields the corresponding electricity measurement. To improve the accuracy of pulse metering, the software design employs a timed continuous sampling method. An effective pulse width is greater than 50ms, and the designed timing period is 16ms. For normal pulses, the number of times the pulse is continuously high-level during timed sampling is ≥2 (see Figure 2). If the pulse width is too small, and the number of measurements is less than 2, the pulse can be discarded. Figure 2. Schematic Diagram of Pulse Sampling Check. Power Acquisition Unit The main functions of the power acquisition unit are pulse data counting and communication with the host computer. Its core components are the AT89C52 microprocessor and the 8259A interrupt controller. In this system, there are more than eight interrupt sources, so the 8259A chips are cascaded. Each power acquisition unit has five cascaded 8259A chips, thus satisfying the input of 32 power signals. The block diagram of the power acquisition unit is shown in Figure 3. In the system, the 8259A is used to work with the AT89C52 to control external interrupt sources. The 8259A analyzes, judges, and determines the priority of interrupt request signals for the AT89C52. Interrupt signals from multiple meters are sent to the 8259A after passing through the input processing circuit. When one of the signals is high, the corresponding bit in the 8259A's IRR (Interrupt Request Register) is set. Next, the 8259A analyzes the information provided by its IRR and IMR (Interrupt Mask Register). If an interrupt source is not masked by the IMR and its priority is higher than the CPU's current task, pin 17 of the 8259A generates a high level. This high level is then passed through a dedicated interrupt request and response circuit to become low, thus requesting an interrupt from the AT89C52. The remaining interrupt signals are queued and stored. This prevents pulse signal loss and ensures the accuracy of the system's signal acquisition. Afterwards, the AT89C52, receiving the interrupt request, compares the priority of the currently running program with the interrupt request. The interrupt request and response circuit then sends an interrupt response signal back to the 8259A. At this point, the AT89C52 executes the interrupt service routine. A memory is used in the design to protect the acquired data. The storage area can be divided into two zones: a working zone that stores real-time electricity consumption data and refreshes it at regular intervals; and a backup zone that backs up six months' worth of electricity consumption data to prevent loss of useful information. For user convenience, a display circuit LCM103 can be designed in the data acquisition unit for local display. Its display function can be achieved by connecting its pins CS, WR, DA2TA to the relevant interfaces of the microcontroller. Data from multiple interrupt sources is displayed in turn in the LCM103. The 10 bits of the LCM03 can be defined as user type, meter type, and display data. The 10th bit represents the user type, the 8th bit represents the meter type, the remaining bits represent the energy consumption of each meter, and the 3rd bit is the decimal point. The 9th and 7th bits are blank for clear readings. During the design, a 511kΩ resistor is added between the VDD and VLCD pins of the LCM103 to ensure moderate display brightness. The CAN interface converter consists of a CAN controller SJA1000 and a CAN driver PCA82C250. The CAN converter is responsible for receiving commands from the host computer and transmitting the power consumption data of the local station. Up to 110 stations can be connected to one CAN bus, as shown in Figure 4. Figure 4: CAN Controller Interface Functional Block Diagram ( CAN Converter) To achieve communication between the microcontroller and the host computer, an interface for converting between TTL level and RS-232 was designed, as shown in Figure 5. The AT89C52 itself does not contain a controller, so the SJA1000 CAN controller and the PCA82C250 CAN driver were used. Figure 5: RS232/CAN Converter Functional Block Diagram (CAN Bus Communication Baud Rate) The calculated baud rate for communication between the host computer in the community control room and the microcontroller in the power acquisition unit is 40.5 Kbit/s. Taking 50 Kbit/s, the communication distance of the CAN bus reaches 1.5 km. If the control room is located in the load center, this communication distance meets the requirements. At this time, the bus timer registers BTR0 and BTR1 are BTR0=47H=01000111B and BTR1=2FH=0011111B respectively. In addition, in order to synchronize the operation of each station in the system, the host computer must issue a time synchronization command to each station at the top of the hour. Software Design The design of the main program of the data acquisition unit is briefly described. It includes two parts: initialization and data acquisition and processing. The initialization program includes the initialization of 8259A. In the data acquisition part, the main program of the data acquisition unit adopts the method of cyclic data acquisition, and classifies the received commands, and then transfers them to the corresponding command processing subroutine. The flowchart of the main program is shown in Figure 6. System anti-interference measures (1) In the system design, the X5045 chip was selected, which has a watchdog circuit. The watchdog circuit monitors the CPU in real time. If the CPU falls into an infinite loop, the watchdog circuit can detect it in time and reset the entire system. In the software programming, the watchdog circuit is accessed once every 1 second. If the program runs out of control or exceeds the set time (1.4s in this system) without accessing the watchdog chip, the X5045 chip will automatically output a reset pulse until the program runs normally. (2) The data acquisition unit is equipped with a filtering circuit to filter the electrical pulse signals generated by various meters to prevent interference that may occur during signal transmission. (3) The power monitoring function of the X5045 chip is used to set up a power monitoring circuit and a power failure protection circuit to prevent data loss after power failure. Conclusion The power meter reading system based on CAN bus adopts intelligent data acquisition and data communication exchange through CAN bus. The system has a fast response speed and strong anti-interference ability; the network has high reliability, high communication baud rate, and large data transmission volume; the structure is simple and easy to install and maintain. The system can easily realize functions such as real-time monitoring, high-speed data acquisition, table lookup and printing, and system monitoring, and has good application prospects.
Read next

CATDOLL Cici Hard Silicone Head

The head made from hard silicone does not have a usable oral cavity. You can choose the skin tone, eye color, and wig, ...

Articles 2026-02-22