Design of networked electric energy meter based on ARM chip

Publisher:平静的33号Latest update time:2012-07-09 Source: IC37 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

introduction

At present, measuring instruments are developing towards networking, and each individual embedded instrument will become a node on the Internet. This system realizes the networking of electronic energy meters in the form of ARM+RTOS. The hardware platform is based on the ARM core microcontroller LPC2104, and the software system is developed under the uC/OS-II operating system.

System hardware design

LPC2104 is a 32-bit microcontroller based on ARM7TDMI-S launched by Philips. LPC2104 integrates many functions, including 128k bytes of high-speed Flash memory, dual UARTs, multiple 32-bit timers, SPI, I2C serial interfaces and RTC, etc. Among them, UART1 has a complete modem interface and can be used in network products.

CS5460 is a single-phase power/electric energy metering chip from Cirrus Logic with a serial interface. CS5460 is highly integrated and contains two ADCs, high/low pass digital filters, energy calculation units, serial interfaces, and digital-to-frequency converters. CS5460 stores its measured and calculated results in its various registers, and the energy value is output to the CPU through pulses, and can also drive the meter.

The working principle of the networked meter is: first, the sampling circuit converts the input large current/voltage into a small voltage signal that can be received by CS5460. CS5460 calculates the electric energy based on the sampled current/voltage, and then transmits the current, voltage, electric energy and power to the CPU through a three-wire bidirectional serial interface (the energy value is output through pulses). The CPU displays the results on the LCD according to the input instructions of the keyboard or transmits the results to the Internet through the serial port. LPC2104 itself serves as both the controller of CS5460 and the embedded gateway, realizing the remote communication function of the electric energy meter. For the hardware structure diagram of this system, please refer to "Electronic Design Applications" 2004.8.

CS5460 can only receive small voltage signals less than 150mV. In the sampling circuit part, an appropriate current/voltage transformer should be selected to convert the input current/voltage to the voltage range that CS5460 can receive.

In the voltage sampling circuit, the input voltage is stepped down and isolated by the voltage transformer, and then low-pass filtered. The capacitor C1 at the end shows a large impedance and is used to sample the voltage. The current sampling circuit has an additional sampling resistor R5 compared to the voltage sampling circuit. R5 is used to convert the current from the current transformer into voltage. For the sampling circuit diagram, see "Electronic Design Applications" 2004.8.

CS5460 and LPC2104 use standard SPI interface, which is very easy. Since CS5460 outputs energy value in fixed-width variable pulse, its energy output pin is connected to an external interrupt pin of LPC2194 to collect energy value.

Since the accumulated value of electric energy and calibration constants need to be saved in EEPROM, a 24C16 is added to save these values. LPC2104 itself has an I2C interface, so it is very easy to expand EEPROM.

The 4UART1 port of LPC210 has a complete modem interface. Since the amount of data required to transmit when the energy meter is connected to the Internet is not large, a low-speed modem chip can be selected. Here, the MSM7512B of OKI Company is selected. MSM7512B is a 1200bps half-duplex FSK modem. It uses a single 3-5V power supply and has low power consumption.

It should also be noted that the CS5460 input/output signals are both 5V, while the LPC2104 signals are 3.3V, so a level conversion circuit is required between the two. [page]

System software design

ARM application system can be based on embedded operating system platform, or can be started directly through startup code without using operating system. In order to realize networking function conveniently, this system chooses the method based on embedded operating system platform. After cutting down, embedded real-time operating system uC/OS-II has only 128K Flash memory, so uC/OS-II can be transplanted into it.

First, you need to port the uC/OS-II operating system to the LPC2104 microprocessor. To facilitate porting, most of the uC/OS-II source code is written in C language. During the porting process, only a few files directly related to the processor need to be rewritten. There are successful examples of porting uC/OS-II to LPC2104, which can be found on the Internet.

uC/OS-II itself does not support network functions. In order to realize the networking of the energy meter, the TCP/IP protocol needs to be transplanted. Since the functions of this embedded system itself are relatively simple, a simple embedded protocol stack can be selected to remove unnecessary protocols. Since the amount of data that the energy meter needs to transmit is not large, but the reliability requirement is high, the reliable data transmission control protocol TCP should be selected at the transport layer, and the basic data transmission protocol IP should be selected at the network layer.

The software part mainly realizes the following functions:

1. Data acquisition and calculation. The calculation part is mainly completed by CS5460. After the command to start the conversion is issued, the required measurement value can be read from the corresponding register after a proper delay. The electric energy value is transmitted to the CPU in the form of pulses. The measurement of effective power is achieved by counting pulses of 1 second. For example, the CS5460 can be programmed to generate a pulse every time 10 joules of energy are converted, and then the effective power is calculated by multiplying the pulse count by 10. Every few minutes, the current accumulated energy will be written to the 24C16 serial EEPROM. In this way, all the energy over the elapsed time can be saved. The calibration constants are also stored in the 24C16. However, when the system is powered on again, these calibration constants will be read from the 24C16 and written back to the CS5460.

2. Button management and LCD display. Since the bus of LPC2104 is not developed, it brings some inconvenience to driving the LCD display, but it can be operated by simulating the bus timing of the ordinary I/O port.

3. System calibration. Before calibration, the CS5460 should be in a valid operating state, and receive valid commands through SPI, clear the data ready bit (DRDY) in the status register; then, apply the corresponding calibration signals to the voltage and current input channels; then, send an 8-bit calibration command word to the CS5460 through the SPI interface; finally, save the calibration results in the corresponding calibration register, and set the DRDY bit to notify the CS5460 that the calibration is complete. The calibration module mainly provides a management interface, through which the user can calibrate the voltage, current, power and other parameters of the ammeter, and save the calibrated data.

4. Network communication. It is necessary to send AT commands to control the modem and generate data streams that comply with the communication protocol. When sending data, the data sent by the application is encapsulated by the TCP/IP protocol, and then encapsulated into PPP frames using the lower-layer PPP protocol, and then the PPP frames are sent out through the asynchronous serial port driver. When receiving data, the asynchronous serial port driver is responsible for receiving the data. Then the TCP module and the IP protocol module process the data and hand over the user data to the application.

uC/OS-II is a preemptive real-time kernel that always ensures the highest priority ready task to run. uC/OS-II can complete the scheduling and synchronization between tasks and coordinate hardware resources. Tasks share data and communicate with each other through communication mechanisms such as semaphores, mailboxes, and message queues. The key to programming based on the uC/OS-II embedded operating system platform lies in the division of tasks and the determination of priorities. The task division diagram of this task can be found in "Electronic Design Applications" 2004.8.

The priority of each task is: over-current and over-voltage protection > data processing > real-time clock > data storage > remote communication.

Conclusion

The networked electric energy meter software system introduced in this article is developed under the embedded operating system platform, which is convenient for debugging a single task, and the error of a single task will not cause the collapse of the entire system. Traditional embedded network products require a special gateway to realize network transmission of data. This system realizes the integration of embedded gateway and measurement control part, which is the trend of realizing the Internet access of embedded products in the future.

Reference address:Design of networked electric energy meter based on ARM chip

Previous article:Design of embedded power parameter detection system based on ARM920T
Next article:Two CAN bus expansion methods based on ARM920T

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号