present, measuring instruments and the direction of positive development of the network, every single instrument will be embedded become a node on the Internet. This system is the way in ARM + RTOS to achieve the electronic energy meter of the network, and hardware platform for the LPC2104 ARM-core MCU core, the software system is in mC / OS-II operating system development. P>
system hardware design
LPC2104 is a company launched by Philips ARM7TDMI-S core 32-bit micro-controller. LPC2104 integrates a lot of features, including high-speed 128k bytes of Flash memory, dual UART, multiple 32-bit timer, and SPI, I2C serial interface and the RTC and so on. One UART1 with full modem interface, can be used for networking products.
CS5460 Cirrus Logic is the companys single-phase power / energy measurement IC with a serial interface. CS5460 high degree of integration, which includes two △ ΣADC, high / low pass digital filter, the energy calculation unit, serial interface and digital - frequency converters. CS5460 it measured and calculated results were stored in its various registers, and the energy values through the pulse output to the CPU, you can drive electromechanical counter.
The network instrument works: First, the sampling circuit input high current / voltage into the CS5460 can receive a small voltage signal. CS5460 based on sampled current / voltage to calculate the power, then current, voltage, power and power through the three-wire bidirectional serial interface to send to the CPU (through the pulse output energy value), CPU under the keyboard input commands displayed on the LCD or through the serial port will send the results to the Internet. LPC2104 controller itself, both as CS5460, and as an embedded gateway, the remote meter to achieve the communication function. The hardware structure of the system shown in Figure 1.
CS5460 can only receive a small voltage signal is less than 150mV, the sampling circuit section should select the appropriate current / voltage transformer, the input current / voltage conversion to be able to receive the voltage range of CS5460.
The voltage sampling circuit, taking into voltage through the step-down voltage transformer, isolation, and then low-pass filter. Finally, the capacitor C1 side showed great resistance, to take voltage. Current sampling circuit more than the voltage sampling circuit sampling resistor R5. R5 is used out of the current from the current transformer is converted to voltage. Sampling circuit shown in Figure 2, Figure 3.
CS5460 and LPC2104 as a standard SPI interface, very easy. The CS5460 is a fixed-width frequency pulse output energy value, so will its energy output pin LPC2104 connected to an external interrupt pin, used to collect energy.
As well as cumulative value of energy needs to be saved to the EEPROM calibration constants, so the expansion of an 24C16 to store these values. LPC2104 I2C interface, with its extended EEPROM is very easy.
LPC2104 the UART1 port with full modem interface. Internet access as needed to meter the amount of data is not, so you can use low-speed modem chip, OKI used here, the companys MSM7512B. MSM7512B is 1200bps half duplex FSK modem. With 3 ~ 5V single power supply, low power consumption.
Also note that the CS5460 input / output signals are 5V, while the LPC2104 signal is 3.3V, so need to add between the level conversion circuit. P>
system software design
ARM applications can be based on embedded operating system platform, you can not use the operating system, directly through the boot code starts. To facilitate the realization of network functions, the system selection is based on embedded operating system platform approach. Embedded real time operating system mC / OS-II is only 50KB or so after the cut, taking into account the LPC2104 128K of Flash memory inside there, so you can choose in which transplanted mC / OS-II.
First need to mC / OS-II operating system to LPC2104 microprocessor. In order to facilitate migration, mC / OS-II source code is mostly written in C language, the migration process requires only a small number of rewriting the file directly with the processor on it. LPC2104 on the transplant mC / OS-II has been successful examples can be obtained from the Internet.
MC / OS-II does not support networking. In order to achieve energy meter networks, also need to transfer TCP / IP protocol. Because the function of the embedded system itself relatively simple, so you can choose simple embedded protocol stack, the protocol will not need to use to remove. The power meter the amount of data is not required, but the high reliability requirements, and therefore reliable data transport layer should use the Transmission Control Protocol TCP, the basic data used in the network layer protocol IP.
Software components to achieve the following main features:
1. Data collection and calculation. Calculated by the CS5460 to complete some of the major, when the start conversion command issued after the appropriate time delay to the corresponding register can read out the required measurements. Pulse energy value is transmitted to the CPU. Effective power is measured by counting 1 second pulses to achieve. For example, control the CS5460 can be programmed to convert 10 per joule of energy generated when a pulse, then pulse count multiplied by 10 to calculate the effective power. Every few minutes, the current total energy is written 24C16 Serial EEPROM. After this period of time can save all the energy. Calibration constants are stored in the 24C16. When the system is re-powered, these calibration constants are read from the 24C16 and write back to the CS5460.
2. Key management and LCD display. As LPC2104 bus is not open to the liquid crystal display driver bring some inconvenience, but an ordinary I / O port analog bus timing to operate.
3. System calibration. In the calibration, you should enable the effective operation of CS5460 in the state, and through the SPI receives a valid command, clear the status register data ready bit (DRDY); then, to the voltage and current of the input channels to impose the corresponding calibration signal; followed by SPI interface to send 8-bit CS5460 calibration command word; Finally, in the corresponding calibration registers store the calibration results, and set the calibration DRDY bit to inform the end of CS5460. Calibration module mainly provides a management interface, users can use this interface to the current meter voltage, current, power and other parameters of correction, and the corrected data storage.
4. Network. Need to issue AT commands for modem control, and that meets the communication protocol data stream. Send data, the application data sent by the TCP / IP protocol stack package, the re-use the lower of the PPP protocol encapsulation as PPP frames, and then through the asynchronous serial port driver will send PPP frames. When receiving data from the asynchronous serial port driver is responsible for receiving data. And then by the TCP module and IP protocol module to process data, the user data to the application.
MC / OS-II is denied based preemptive real-time kernel, always ensure the highest priority ready task to run. mC / OS-II can be completed between the various task scheduling and synchronization, coordination of hardware resources. Between the various tasks through semaphores, mailboxes, message queues and other communication mechanism for data sharing and communication tasks. Based mC / OS-II embedded operating system platform programming is the key to the division of tasks and priorities identified. Division of tasks of the system shown in Figure 4.
Priority of each task: over-voltage protection over-current data processing > > > real-time clock data storage > telecommunications. P>
This article describes the network power meter software system is developed under embedded operating system platform, easy debugging a single task, single task of the error does not result in total collapse. Traditional embedded network products require specialized network gateway to achieve data transmission, the system implements the embedded gateway and measurement control part of the integration, which is the future trend of embedded Internet products. ■ P>
All right reserved:icfull.com © 2010-2016 Certificate