0Introduction
The low-voltage power distribution data acquisition and monitoring system consists of two parts: the on-site transformer remote data acquisition terminal and the monitoring center. The on-site transformer remote data acquisition terminal is installed at the transformer site. It collects data from the multi-function energy meter through the RS485 communication interface, processes and stores data on the electrical parameters of the transformer, and then controls the GPRS communication module through the RS232 communication interface to realize remote wireless data sampling and monitoring. The server host of the monitoring center is installed with the low-voltage distribution network area real-time monitoring software, which can communicate with the data acquisition terminal through the GPRS Modem. The data acquisition terminal adopts three data transmission modes: timing, real-time, and fault. The timing and real-time data acquisition modes are mainly realized through the real-time clock DS12887. In the real-time data acquisition mode, the current data of the multi-function energy meter is collected by refreshing the minute register of DS12887; in the timing data acquisition mode, whether the minute register of DS12887 is zero is used to determine whether it has arrived every hour. 24 groups of data are collected and stored every day to generate a data packet. The data acquisition terminal determines whether the day has come according to whether the hour and minute are zero, so as to clear the data storage unit for the new day; the data acquisition terminal stores 7 days of data according to the change of the date of DS12887. The realization of the above data acquisition function is inseparable from the clock and calendar of DS12887. The clock and calendar run through the entire data acquisition and play a vital role. With the advantages of high timing accuracy, power-off protection, powerful functions, and flexible use, the real-time clock DS12887 is increasingly favored by users.
1 Structure and functional features of DS12887
DS12887 is an 8-bit parallel interface real-time clock/calendar chip launched by DALLAS, USA, made using CMOS technology. It uses a 24-pin dual in-line package and is composed of an oscillation circuit, a frequency division circuit, a periodic interrupt/square wave selection circuit, a 14-byte clock and control unit, a 114-byte user non-volatile RAM, a decimal/binary accumulator, a bus interface circuit, an internal lithium battery, etc. Based on the internal circuit structure of DS12887, its main functional features are as follows:
⑴ A built-in lithium battery can operate for more than ten years without losing data after power failure.
⑵ It has the information of seconds, minutes, hours, day, month, year and week, and has the function of leap year compensation.
⑶ Can be programmed to use binary code or BCD code to represent time, calendar and alarm.
⑷ The programmable time is 12-hour or 24-hour.
⑸ It has two bus timing selection modes: Motorola and Intel.
⑹ It has 128 bytes of RAM, including 10 clock registers, 4 control registers and 114 bytes of general RAM units. All RAM units have power-off protection function and can be used as non-volatile RAM.
⑺ Programmable square wave signal output.
⑻ It has alarm interrupt, periodic interrupt and clock update cycle end interrupt. The three interrupt sources can be masked by software respectively.
2 How to use the 4 control registers of DS12887
2.1 Register A (except D 7 which is read only, all other bits are readable and writable), as listed in Table 1.
Table 1 Register A
D 7 |
D 6 |
D 5 |
D 4 |
D 3 |
D 2 |
D 1 |
D 0 |
UIP |
DV 2 |
DV 1 |
DV 0 |
RS 3 |
RS 2 |
RS 1 |
RS 0 |
UIP: Refresh flag. UIP=1 means refresh is in progress; UIP=0 means refresh will not occur within 244µs, and the RAM area can be read and written at this time.
When DV 2 DV 1 DV 0 = 010, the crystal oscillator is turned on and the clock is allowed to start timing.
RS 3 RS 2 RS 1 RS 0 is used to select periodic interrupt or square wave output frequency. When they are 0111, 1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111, the corresponding output frequencies are 512Hz, 256Hz, 128Hz, 64Hz, 32Hz, 16Hz, 8Hz, 4Hz, 2Hz. When RS 3 RS 2 RS 1 RS 0 = 0000, periodic interrupt and square wave output are disabled.
2.2 Register B (readable and writable), as listed in Table 2.
Table 2 Register B (table 2 b register)
D 7 |
D 6 |
D 5 |
D 4 |
D 3 |
D 2 |
D 1 |
D 0 |
|
SET |
PIE |
AIE |
UIE |
SQWE |
DM |
24/12 |
DSE |
|
SET=0, count once per second; SET=1, disable refresh.
When the PIE, AIE, and VIE bits are all 1, it means that periodic interrupts, alarm interrupts, and clock data refresh end interrupts are allowed respectively;
When both are 0, it means that interrupts are prohibited.
When SQWE=1, the SQW terminal outputs a square wave frequency signal set by RS 3 to RS 0 ; when SQWE=0, the SQW terminal maintains a low level.
DM=1, the calendar clock uses binary format; DM=0, uses BCD code format.
24/12=1, the time mode uses the 24-hour system; 24/12=0, the time mode uses the 12-hour system.
DSE=1, allows daylight saving time to occur; DSE=0, prohibits it.
2.3 Register C (read only), as listed in Table 3.
Table 3 Register C (table 3 c register)
D 7 |
D 6 |
D 5 |
D 4 |
D 3 |
D 2 |
D 1 |
D 0 |
|
IRQF |
PF |
AF |
UF |
0 |
0 |
0 |
0 |
|
When the PF, AF, and UF bits are all 1, it means that a periodic interrupt, an alarm interrupt, and a refresh end interrupt have occurred respectively; when they are all 0, it means that no interrupt has occurred.
IRQF: interrupt request flag. IRQF=PF×PIE+AF×AIE+UF×UIE
IRQF=0, no interrupt request is generated; IRQF=1, an interrupt request is generated. The IRQ terminal outputs a low level, reads register C or
After reset, all flag bits are cleared.
2.4 Register D (read only), as listed in Table 4.
Table 4 Register D (table 4 d register)
D 7 |
D 6 |
D 5 |
D 4 |
D 3 |
D 2 |
D 1 |
D 0 |
VRT |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
VRT=0 means that the internal lithium battery of the DS12887 chip has been exhausted and the time and RAM area information are invalid;
VRT=1, the information is valid.
3 Hardware interface circuit
The structural block diagram of DS12887 in data acquisition terminal application is shown in Figure 1. W77E58 high-performance single-chip microcomputer with dual serial ports is used. One serial port uses MAX487 to realize RS485 interface with multi-function electric energy meter to obtain data of low-voltage power distribution parameters; the other serial port uses MAX232 to communicate with GPRS Modem to realize remote data reception and transmission.
AT28C256 EEPROM is used to store historical data. 8255 parallel expansion interface is used for function expansion and standby, as well as normal working indication, standby power indication, data collection indication, remote communication indication, and event alarm indication.
Figure 1 Hardware structure diagram of the data acquisition terminal
4Interface software
The following is the interface software between the DS12887 clock chip and the 77E58 microcontroller, written in assembly language. The low-voltage power distribution data acquisition and monitoring system uses DS12887 with the following four functions: First, to store historical data by time, such as storing historical data starting from a certain year, month, and day, it can continuously save 7 days of data, and on the 8th day, the data of the first day will be overwritten; second, to achieve fixed-point data acquisition by changing hours; third, to achieve current data acquisition by changing minutes; fourth, to determine whether a new day has arrived by whether a certain day has changed. If a certain day changes, it means that a new day has arrived, and the RAM unit corresponding to the AT28C256 in the new day will be initialized.
4.1 Related constant definitions and RAM unit comments
;;;;;; 13H……Current minute value (BCD code)
SZ_addm equ 0f700H ; Second register address
SZ_addf equ 0f702H ; register address
SZ_adds equ 0f704H; register address
SZ_addr equ 0f707H ;Day register address
SZ_addy equ 0f708H ; Month register address
SZ_addn equ 0f709H ;year register address
SZ_adda equ 0f70aH ; A register address
SZ_addb equ 0f70bH ;B register address
SZ_addc equ 0f70cH ;C register address
SZ_addd equ 0f70dH ;D register address
4.2 Initialize the clock chip or clock settings
In the low-voltage power distribution data acquisition and monitoring system, it has the functions of initializing and setting the clock of DS12887 or reading the clock through GPRS Modem remote communication. The year, month, day, hour, minute and second data received by the single-chip microcomputer are stored in the 21H, 22H, 23H, 24H, 25H and 26H RAM memory units respectively.
Initialize the clock setting subroutine:
MOV DPTR, #SZ_addb; Set register B to "1" to disable the refresh cycle inside the chip
MOV A,#82H;
MOVX @DPTR, A;
MOV DPTR, #SZ_addn; write data to the year register
MOV A, 21H;
MOVX @DPTR, A;
MOV DPTR, #SZ_addy; write data to the month register
MOV A, 22H;
MOVX @DPTR, A;
MOV DPTR, #SZ_addr; write data to the day register
MOV A, 23H;
MOVX @DPTR, A;
MOV DPTR, #SZ_adds; data of register when writing
MOV A, 24H;
MOVX @DPTR, A;
MOV DPTR, #SZ_addf; write data to sub-register
MOV A, 25H;
MOVX @DPTR, A;
MOV DPTR, #SZ_addm; write data to the seconds register
MOV A, 26H;
MOVX @DPTR, A;
MOV DPTR, #SZ_adda; Initialize register A, turn on the crystal oscillator to start timing, and disable interrupts.
MOV A, #20H; disable square wave output.
MOVX @DPTR, A;
MOV DPTR, #SZ_addb; Set register B to "0",
MOV A, #02H; BCD code format, 24-hour system, allowing time refresh.
MOVX @DPTR, A;
RET ;
4.3 Reading Data from DS12887
Read data subroutine: MOV DPTR, #SZ_adda; read the contents of register A
MOVX A, @DPTR; query the VIP bit to determine whether the chip is in the update cycle
JB ACC.7, XIN;
MOV DPTR, #SZ_addf; read the value of the sub-register
MOVX A, @DPTR;
CJNE A, 13H, SAMPLE; Determine whether the time minute register is updated, that is, whether 1 minute has expired?
SJMP XIN ; not yet reached
SAMPLE: . . . . . . ; Arrived, start collecting data from the multi-function meter
5 Conclusion
This paper starts with the structural principle of the real-time clock DS12887, and describes the functional characteristics and usage of the chip. Focusing on the hardware interface circuit and software programming of DS12887 and single-chip computer 77E58, this paper describes how DS12887 realizes the timing and current data acquisition functions in the low-voltage distribution data acquisition and monitoring system. It is applied to the 2002 Jiangxi Provincial Education Department Science and Technology Project Plan "Single-phase Pocket Multifunctional Field Calibrator", the project number is Ganjiao Science and Technology [2002] No. 1901, the fund project funds are 10,000 yuan, and the scientific and technological achievements have been identified in June 2005. The innovation of this paper is to cleverly use the function of the DS12887 clock chip, take the real-time running time as the criterion, realize the collection and storage of instantaneous, fixed-point, one-day, and historical data, and realize remote monitoring through the GPRS network. The system has been installed and operated by the power supply bureau and proved to be reliable. It can realize the remote reading of various data of the power plant transformer electric energy meter, which is worthy of promotion.
References
1 Zheng Zhongming. Interest rate display screen designed using DS12887 [J]. Foreign Electronic Components, 2002, 10: 17-19.
2 Zhang Songbo, Zhang Dongsheng. Application of real-time clock 12887 in embedded systems [J]. Electrical Measurement and Instrumentation, 2004, 8: 54-56.
3 Li Tao, Xu Jianzheng. Distribution transformer monitoring system based on GPRS wireless technology [J]. Electrical Measurement and Instrumentation, 2004, 6: 55-57.
4. Zhu Jiebin, Yu Hongli, Pan Ziqiang. Application of clock chip in voltage monitor calibration device[J]. Microcomputer Information,
Early December 2006:288-290.
Previous article:Sensorless Field Oriented Control Using an 8-bit Microcontroller
Next article:Research on the Design of 8-bit Microcontroller Architecture
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Understand the difference between differential and single-ended signals
- Dating in spring + rapeseed flowers blooming in my hometown
- MSP430 Ultrasonic Sensing Microcontroller
- Basics of Electrical Impedance Measurement - A lot of people - worth watching
- "Playing with the board" + Zhou Hangci's book Chapter 10, Example 2
- Why are there two on-chip SRAMs in DSP processors?
- [N32L43X Review] 8. USB CDC custom transmission content
- 7. "Ten Thousand Miles" Raspberry Pi Car——RPi.GPIO Learning (PWM and External Interrupt Simulation Timer)
- Pingtouge RISC-V RVB2601 development board--Big circle eats small circle game based on analog remote sensing control
- GigaDevice GD32307E-START Review Summary