Abstract: The introduction uses the multistage graduation correspondence pattern composition the residential district automatic electrical energy cost system’s hardware constitution and the software design; The introduction electrical energy data acquisition’s hardware composes and increases the electric quantity measuring accuracy with emphasis the method.
Key word: Electrical energy cost system graduation correspondence correspondence repeater electrical energy data acquisition
Since long, the power supply Control section has been is copying the table to the user electric quantity’s statistics in the foundation to carry on artificially, the work load is big, immediate influence power supply department’s working efficiency. Along with the computer technology and networking’s development, the automatic electrical energy cost system arises at the historic moment. In plot inhabitant quantity are many, even becomes in thousand especially, therefore the data acquisition unit number are many, they must use the multistage graduation correspondence pattern with computer’s between correspondence. This article introduces based on the graduation correspondence pattern residential district automatic electrical energy cost system’s implementation plan.
First, system constitution
System’s structure as shown in Figure 1. The system uses the graduation mailing address, between the computer and 32 89C51 monolithic integrated circuits uses the RS-485 half-duplex connection. MAX232 realizes the RS-232 connection signal level transformation is the TTL level. MAX483 is 5V the power supply RS-485 connection difference signal transceiver, may be the RS-485 differential interface signal form or carries on the TTL level transformation the reverse direction the transformation. Each 89C51 monolithic integrated circuit undertakes the relaying duty which the computer and between 32 data acquisition 89C52 corresponds. Uses the different mouth line to control 89C51 and computer, the data acquisition between correspondence separately. 89C51 and between data acquisition 89C52 also uses the RS-485 half-duplex connection, realizes two kind of signal format transformation by MAX483. the 89C52 monolithic integrated circuit constitution data acquisition, completes 1 housing unit 2 household pulse electric meter’s pulse quantity gathering through T0 and T1, thus carries on the kilowatt hour quantity the conversion. The RS-485 connection support multistage correspondences, allow on the main line to hang meet 32 drivers, therefore through the level-to-level administration, the computer may connect 32×32=1024 the data acquisition, is also 1024×2=2048 user’s electricity consumption gathering. If increases 1 level of 89C51 in among to take the repeater again, may expand the user number 32 times, satisfies the general residential district the practical application request.
Second, hardware junction circuit
between 1.RS-232 and RS-485 electric circuit connection
The RS-232 connection signal format transforms the RS-485 differential interface signal format electric circuit connection as shown in Figure 2; Correspondence repeater’s electric circuit connection as shown in Figure 3.
Shown in Figure 3 in the correspondence repeater’s junction circuit, between 89C51 and the computer, 89C51 and between the data acquisition carries on the half-duplex operation with 1 twisted pair line, time sharing realizes the transmission and the receive. Because uses 1 serial port to carry on the correspondence, to avoid sending a letter the number confusion, controls 1#MAX483 with P1.6 to send data permission position DE; Controls 2#MAX483 with P1.7 to send data permission position DE. The receive data is always different when carries on, according to receives the address which the first computer transmits, then transmits the address for the data acquisition, finally receives the data acquisition transmission data order to carry on. Uses the multistage mailing addresss, the data format is 11, according to the order respectively is successively: what 1 outset position, 8 bit data positions, 9th use in distinguishing the transmission or the receive is the address or the data. Each signal repair company unit has an only address, respectively is 0~31, by meets in the P1 mouth tumbler switch’s establishment only determination.
2. electrical energy data acquisition composition
Junction circuit as shown in Figure 4. Electrical energy data acquisition measurement kilowatt hour signal impulse from electrical energy measurement specific IC chip pulse out-port, after transmitted light electric coupling and Schmitt trigger reshaping, songzhi monolithic integrated circuit 89C52 counting input end T0 and T1, gather the pulse quantity which each housing unit 2 household pulse electric meter outputs. T0 and T1 establish as the way 2, the starting value is 0FFFFH. When the T0 interrupt request, completes the pulse in the overflow trap service routine the counting and the electric quantity increasing. In order to coordinate to use electricity the charge system’s reform (i.e. to use electricity for peak uses electricity time, trough to use electricity time and uses electricity normally time), must carry on the real-time statistics to the electricity consumption (, but is not computation fixed time); Simultaneously to guarantee that electric quantity gathering and the demonstration precision, the computation divides into 1 degree position and 0.1 degrees position in the software design to the electricity consumption, took the measure which increased progressively separately, the reason has been as follows:
After electric meter constant and pulse constant determination, may result in the pulse which through the computation 1 kwh electricity correspondence electric meter outputs to count K is the constant, then 0.1 kwh electricity correspondence electric meter outputs the pulse number is K/10, namely has the K/10 pulse arrival, because K/10 not necessarily happen to is an integer, if leaves the decimal or carries on carrying to the decimal to take entire, has the accumulative error inevitably.
The distinction increasing’s method is as follows: T0 (or T1) examines every time to 1 pulse under jumps along, TL0 (or TL1) the overflow trap 1 time, reduces separately in the interrupt service to the K/10 value register and the K value register 1. The K/10 value register reduces to 0:00, 0.1 degree value register increase progressively 0.1 degree, and sets at the starting value to the K/10 value register; The K value register reduces to 0:00, the value register increases progressively 1 degree, and sets at the starting value to the K value register and the K/10 value register. Like this when electric quantity for entire, the accumulative error will be 0.
In order to let the user understand promptly own uses electricity the situation, the data acquisition uses six LED monitors to demonstrate the total electricity consumption, the demonstration measuring range is 99999.9, the demonstration resolution is 0.1 degree.
TL7705CP is the power source examination electric circuit. Data acquisition use inhabitant 220V power source power supply, when the line outage gathering working voltage falls from 5V to 4.75V below, the system reset, namely becomes the low level by the original high level, has the drop in the external interrupt 0 input ends along namely the external interrupt request signal; In the interrupt service 89C52 in the internal RAM total electric quantity and the K/10 value register, the K value register content enters before a supply voltage vanishing period of very short time memory in serial EEPROM 24C02, prepares comes when the electricity the total electric quantity and the pulse quantity takes out. the 89C52 P1 mouth external connection tumbler switch, uses in determining the electrical energy data acquisition address only. Establishes the external interrupt 0 interrupt priorities is the high priority.
Third, correspondence work flow and subprogram diagram
1. correspondence work flow
(1) the computer first transmits the signal repair company unit the address 0.
(2) 32 correspondence repeaters receive this address, then and own address (by P1 mouth tumbler switch only determination) comparison, only then the address equal correspondence repeater, transmits the data acquisition address is 0.
(3) the address is 0 data acquisitions transmits successively T0 and the T1 gathering total electric quantity for the signal repair company unit, the data transmission which the signal repair company unit will receive again for the computer.
(4) is redundant (3) step, until transmits completely 32 data acquisition’s 64 data for the computer.
(5) computer transmission correspondence repeater’s address 1. Is redundant (2), (3), (4) step, until 32×32×2=2048 a data transmits completely 32 correspondence repeaters for the computer, this correspondence ended.
2. flow chart
(1) electrical energy data acquisition
In the data acquisition, divides into the master routine and 4 interrupt service. 4 interrupt sources respectively are external interrupt 0, T0 which and the T1 overflow traps, the serial interrupt the power source power failure causes. in 4 interrupt sources, the external interrupt 0 establish as the high priority interrupt, other 3 for same level low priority interrupt. When these 3 interrupt sources simultaneously apply for the interrupt, the interrupt Guizhou Province order is: Timer 0 overflow traps, timer 1 overflow trap and serial port interrupt.
The master routine mainly completes T0, T1 and the serial port initialization, reads from 24C02 serial EEPROM before supply voltage vanishing a period of very short time memory entering total electric quantity and the K/10 value register, the K value register’s counting value.
T0 and in the T1 interrupt service completes the pulse the counting and the electric quantity increasing. The detailed content has made the specification in above.
In the external interrupt 0 interrupt service 89C52 in the internal RAM total electric quantity and the K/10 value register, a K value register’s enters before supply voltage vanishing period of very short time memory in serial EEPROM, prepares comes when the electricity the total electric quantity and the pulse quantity takes out. As shown in Figure 5 for the data acquisition serial communication diagram.
(2) corresponds the repeater
The master routine is quite simple, mainly carries on the serial port the initialization, to open the interrupt, the waiting serial port interrupt to have the production. Interrupt service diagram as shown in Figure 6.
Concluding remark
This design proposal is not only suitable for the residential district automatic electrical energy cost system, its design concept is suitable similarly for the guesthouse, the granary, the commercial run examination and so on multi-spot data acquisition system, has the broad application prospect.