UM0402 STMICROELECTRONICS | Alldatasheet

Document overview

  • Manufacturer or author: Provided By ALLDATASHEET.COM(FREE DATASHEET DOWNLOAD SITE)
  • PDF pages: 35

Technical content

Datasheet sections

  • 1 Overview
  • 1.1 Safety rules
  • 1.2 Conventions
  • 1.3 Multi tariff meter description
  • 1.4 Multi tariff meter features
  • 1.5 Recommended reading
  • 1.6 Obtaining technical support
  • 2 Getting started
  • 2.1 Multi-tariff meter checklist
  • 2.2 Equipment requirements
  • 2.3 Installing the hardware
  • 3 Hardware Features
  • 3.1 Electrical parameters
  • 3.2 Mechanical outlines
  • 4 Firmware features
  • 4.1 Multi Tariff management and configuration
  • 4.2 Maximum demand management and configuration
  • 4.2.1 Day type maximum demand
  • 4.2.2 Month type maximum demand
  • 4.2.3 Quarter type maximum demand
  • 4.3 Date and time configuration
  • 4.4 Memory structure
  • 4.4.1 Common storage for all maximum demand types
  • 4.4.2 Storage specific for day type MD
  • 4.4.3 Storage specific for month type MD
  • 4.4.4 Storage specific for quarter type maximum demand
  • 5 Multi-tariff meter operation
  • 5.1 Normal operation
  • 5.1.1 Tamper mode

Single-phase multi-tariff energy meter Introduction This user manual describes the functions and features of the single-phase multi-tariff energy meter. The reference board is an integrated system designed to provide a complete, ready-to-use energy meter application. It is a medium-end solution for power metering, using the ST72F321 microcontroller, the M41T94 Real Time Clock, the M95256 EEPROM and the STPM14 energy meter ASSP device. The multi-tariff energy meter reference board implements several features including multi- tariff management, absolute and average maximum demand calculation, two types of tamper management and power failure management. It can therefore be used as a platform for evaluation and development of meter applications. The aim of this guide is to provide: ■ Procedures for getting the reference board functioning quickly ■ An overview of the implementation of meter main features ■ The information required to be able to customize meter features.

1 Overview

1.1 Safety rules

This board can be connected to mains voltage (220V). In the case of improper use, wrong installation or malfunction, there is a danger of serious personal injury and damage to property. All operations such as transport, installation and commissioning as well as maintenance should be carried out only by skilled technical personnel (regional accident prevention rules must be observed). Danger: Due to the risk of death when using this prototype on mains voltage (220V), only skilled technical personnel who are familiar with the installation, mounting, commissioning and operation of power electronic systems and have the qualifications needed to perform these functions, may use this prototype.

1.2 Conventions

The lowest analog and digital power supply voltage is called VSS. All voltage specifications for digital input/output pins are referred to as VSS. The highest OTP writing power supply voltage is VOTP. The highest power supply voltage of the device is VCC. Positive currents flow into a pin. Sinking means that the current flows to the pin while sourcing means that the current flows from the pin. Timing specifications of signals treated by the device are relative to the CLKOUT. This signal is fed from a 4.194 MHz on-board crystal oscillator. Timing specifications of SPI interface signals are relative to the SCLNLC, which need not to be in phase with CLKOUT. A positive logic convention is used in all equations.

1.3 Multi tariff meter description

The single-phase multi-tariff energy meter reference board is designed using STPM14 metering ASSP and ST72F321BR6 microcontroller. The STPM14 belongs to STPM1x metering devices family. It measures the active energy that is output as a pulse train with a frequency proportional to the measured power. It supports tamper detection, monitoring both phase and neutral line wires, where two current transformers are used as current sensors. The clock to STPM14 is supplied by a crystal of frequency 4.194304 MHz. The microcontroller drives the LCD, processes measurements coming from the ASSP and manages RTC and EEPROM functionalities, for example saving relevant data in EEPROM before moving to halt mode during power down. It also manages maximum demand calculation on a daily, monthly or three-month base.

A 16 MHz crystal is used for obtaining an 8 MHz CPU clock for the micro. power is down and the battery is fully discharged. Figure 1. Multi-tariff meter board power to the application is supplied by 4.8V rechargeable battery. An LCD display is present with 24x4 segments, customized for electricity meter use. This board also supports IRDA protocol IEC62056-21 mode C. button cycle through the display of additional information. See Table 8 on page 19 for full details on the parameters displayed on the LCD.

1.4 Multi tariff meter features

  • Cost-effective and flexible, based on STPM14
  • Fulfils class 1 accuracy for Ib=5A and Imax=80A according to IEC 61036:1996 + A1: 2000, Static meter for active energy (classes 1 and 2)
  • Operating Voltage range 220V ±20%
  • Continuously detects and displays No load condition, Reverse direction and fraud & case Tamper conditions
  • Configurable number of tariffs (1 to 4) and Maximum demand Type (day type, one month type or three month type)
  • Accumulated data for whole meter life (Total kWh consumption, Average MDs, Total number of Tariffs, Tariff time slots, consumption under different tariff rates, power failure date/time)
  • Data for last 12 months (Consumption under Tamper mode for each month, First/last Case/fraud Tamper Date/time, total Tamper time and power failure accumulating time for each month)
  • Data for Absolute Maximum Demand (Absolute MD, Date/Time) according toType of MD requested
  • SW LCD driver for 24X4 segments LCD glass with contrast control
  • RTC with SPI exists for real Date/Time
  • EEPROM with SPI for storing 256 Kbit of data
  • Case tamper detection in power down also
  • External switch to see all the data stored into EEPROM sequentially even when AC power is not available
  • Battery backup to detect tampering and see all the parameters stored in EEPROM during power down also
  • Single point and fast calibration of STPM14 for Class 1 meter

1.5 Recommended reading

This documentation describes how to use the Multi Tariff Meter Reference Board. Additional information can be found in the following documents:

  • STPM14 datasheet;
  • Components datasheets;
  • inDART -STX for ST7 User's Manuals;
  • IEC 62056 IrDA Protocol Mode C;
  • IrDA module for Multitariff Meter user manual.

1.6 Obtaining technical support

Technical assistance is provided free to all customers. For technical assistance, documentation, information and updates about products and services, please refer to your local ST distributor/office.

2 Getting started

2.1 Multi-tariff meter checklist

  • Reference design board (Figure 1)
  • STPM14 programmer
  • An interactive CD-ROM with software and documentation.

2.2 Equipment requirements

supplier or a simple connection to the line voltage.

2.3 Installing the hardware

into the line socket, or to an AC voltage source, providing 220 VAC. Figure 2. Multi-tariff meter board connections

3 Hardware Features

3.1 Electrical parameters

VCC = 3.6V, TAMB = +25 C, unless otherwise noted. Table 1. Electrical parameters

0.65 V Internally generated

3.2 Mechanical outlines

Table 1. Electrical parameters (continued)

4 Firmware features

4.1 Multi Tariff management and configuration

It is possible to define up to four tariffs to apply to the energy count. The number of tariffs must be defined in EEPROM_Union structure in the EEPROM.c file. Tariff-change time should also be given in the EEPROM_Union structure in 24-hour HH:MM:SS format. Tariff times in the EEPROM.c file should be defined in increasing order starting from the first definition. For example, if the number of tariffs defined in EEPROM_Union structure is 3, we should give three tariff times in increasing order starting from first as shown below: {0x05, 0x00, 0x00},// Change of tariff from A3 to A1 at 5:00 AM {0x10, 0x30, 0x00},// Change of tariff from A1 to A2 at 10:30 AM {0x21, 0x00, 0x00},// Change of tariff from A2 to A3 at 9:00 PM {0x00, 0x00, 0x00},// Not defined Tariff rates are defined in EEPROM_Union structure in EEPROM.c file in the same order as tariff times. For example, if the number of tariffs defined in EEPROM_Union structure is 3 (as in the above case), the tariff rate should be defined as below: 3.000, // Tariff rate defined for A1 {0, 0} // kWh_Energy and Pulse count initialized to 0 2.001, // Tariff rate defined for A2 {0, 0} // kWh_Energy and Pulse count initialized to 0 2.852, // Tariff rate defined for A3 {0, 0} // kWh_Energy and Pulse count initialized to 0 0.0, // Not Defined {0, 0} To set and change the tariff, a function Set_TARIFF() is called every second. Energy consumption is calculated as total and for each tariff.

4.2 Maximum demand manage ment and configuration

The maximum demand (MD) is the maximum continuous load (kW) which remains for a certain period. This period is programmable and can be chosen from 1 minute up to 60 minutes. There are three types of absolute maximum demand which are defined: a) Daily based, b) Monthly based, c) Quarterly based. According to this selection, the absolute maximum demand will be calculated and stored for each day, or for each month or for each quarter in a 12 month base. Out of these three options, one can be selected by the user in the lib.h file by preprocessor directive; in the same way it is possible to program the period of constant load. An example definition is given below: /* define type for MD*/ #defineMD_minutes 1 // #defineDAY1 #defineONE_MONTH 1 // #defineTHREE_MONTHS 1 In every case the average of these maximum demands is calculated and stored for a year as:

  • last three months average maximum demand,
  • second last three months average maximum demand,
  • third last three months average maximum demand,
  • fourth last three months average maximum demand,
  • last six months average maximum demand,
  • last nine months average maximum demand
  • last twelve months average maximum demand. In the following paragraphs the three types of MD will be explained in detail.

4.2.1 Day type maximum demand

In this type the storing period is chosen and programmed to be one day. As an example, the maximum load period is chosen and programmed to be 15 minutes. If on the first day (e.g. 25th Dec'06) there is a continuous load of 150 kW for 15 minutes starting from 10:15PM to 10:30PM, and another one of 200 kW for 10 minutes starting from 11:11PM to 11:21PM, the meter stores the value of 150 kW as the "maximum demand" of that day with date 25th Dec'06 and time 22:30:00 in 24Hour HH:MM:SS format. The meter acts the same way for each day. Average maximum demands are calculated using the MD values of each day. Then at the end of the month, the meter calculates and stores:

  • maximum demand for each day of the month,
  • average maximum demands of all types.

In EEPROM, the storing of the day type MD for each day is defined as below: If the particular year is a leap year, then 59th index data will be filled by 29th Feb maximum demand, otherwise index will be incremented by 2 which leaves the 59th index maximum demand data as it was.

4.2.2 Month type maximum demand

In this type the storing period is chosen and programmed to be one month. As an example, the maximum load period is chosen and programmed to be 15 minutes. The maximum demand of a day is calculated as in the previous case. If the first day the absolute maximum demand is 150 kW, and the second day it is 75 kW, the meter keeps the value of the 150 kW of the previous day as the maximum demand value. If the third day the maximum demand is 200 kW, the meter stores 200 kW with new date and time instead of the 150 kW as maximum demand of the month. At the end of the month the meter stores only one value of maximum demand, and calculates average maximum demands using the MD values of each month. Then at the end of the month, the meter calculates and stores:

  • maximum demand of the month,
  • average maximum demands of all types. In EEPROM, the storing of month type MD for each month is defined as below:

4.2.3 Quarter type maximum demand

In this type the storing period is chosen and programmed to be three months. Let suppose that the maximum load period is chosen and programmed to be 15 minutes. The maximum demand of each month is calculated as in the previous case. Moreover, at the end of each month the maximum demand of the quarter is calculated as the maximum demand of the three months of the quarter, and average maximum demands are calculated using the MD values of each month. Summarizing, at the end of month meter calculates and stores:

  • maximum demand of the month,
  • maximum demand of the quarter,
  • average maximum demands of all types. Name 1st Jan 2nd Jan 27th Feb 28th Feb 29th Feb 1st March 31st Dec Name JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC Index 0123456789 1 0 1 1

In EEPROM, in the case of three months type MD the storing of month-wise maximum demand and three month-wise maximum demand is defined as below:

4.3 Date and time configuration

RTC date and time can be set by the firmware itself. There is a RTC_init() function which initializes the RTC with the specified date and time. The date and time to be initialized in RTC should be specified in RTC_table[10] array. The definition of array is as below: RTC_table[0] = write command and 7 bit address(0x00) = 0x80 RTC_table[1] = Seconds up to 0.01 in BCD format = value given by user RTC_table[2] = ST and Seconds in BCD format = value given by user RTC_table[3] = Minutes in BCD format = value given by user RTC_table[4] = CEB, CB and Hours in BCD format = value given by user RTC_table[5] = Day of week = value given by user RTC_table[6] = Date of month in BCD format = value given by user RTC_table[7] = Month in BCD format = value given by user RTC_table[8] = Y ear = value given by user RTC_table[9] = calibration value = value given by user For more information, please refer to M41T94 datasheet of RTC used in the board. Date and time can also be set by using the IRDA protocol. Please refer to the IEC 62056 PROTOCOL MODE C user manual.

4.4 Memory structure

The meter sensitive data are stored in EEPROM. M95256 256 Kbit EEPROM is used. Below are details on memory organization.

4.4.1 Common storage for all maximum demand types

There is some common data stored at the start of EEPROM. This data is saved in 89 Bytes of EEPROM_Union structure of EEPROM_DATA_Union data type, and represents the energy count, the average maximum demand, application flags, tariff definitions, energy counts and power down information. Two pages of 64 Bytes are used for storing these 89 Bytes, as shown below: Name JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC Index 0123456789 1 0 1 1 Name JAN, FEB, MAR APR, MAY , JUN JUL, AUG, SEP OCT, NOV, DEC Index 0123

Table 2. EEPROM common information

EEPROM_month_Union structure of EEPROM_DATA_Month_Union data type.

  • Energy consumption during tamper;
  • First and last box tamper time and date;
  • First and last line tamper time and date;
  • Total month tamper time;
  • Total month power down time. EEPROM_month_Union structure is stored as below: 4Dh power_down_date: Day, Month, Y ear volatile unsigned char 50h power_down_time: Sec, Min, Hour volatile unsigned char 53h pwr_dn_index_year volatile unsigned char 54h pwr_dn_index_mon volatile unsigned char 55h Index_Box_Tamper volatile unsigned int 57h Index_Fraud_Tamper volatile unsigned int

Table 3. EEPROM common information (for each month)

4.4.2 Storage specific for day type MD

4.4.3 Storage specific for month type MD

2 pages of 64 Bytes are used for storing 12 structures of EEPROM_AMD_Union data type. Table 4. EEPROM day type MD information Table 5. EEPROM month type MD information

4.4.4 Storage specific for quarter type maximum demand

Bytes) of data present in EEPROM related to three months type Maximum Demand. Table 6. EEPROM quarter type MD information Table 7. EEPROM quarter type MD information

Multi-tariff meter operation UM0402

5 Multi-tariff meter operation

5.1 Normal operation

Connect the meter to the voltage source and to the load, as shown in Figure 2 on page 7, and power on the board by plugging it into the AC line socket, or by powering on the AC source to which line and neutral wires are connected. During normal operation, the meter is supplied with the line voltage, the microcontroller is in Run Mode and all devices are powered on. The red LED just below the LCD blinks with a frequency proportional to active power measured by STPM14 (pulse constant is set to 1000imp/kWh) and the LCD displays active energy measured, current tariff and other symbols, as listed below in details.

5.1.1 Tamper mode

The meter is able to detect and manage two types of tamper:

  • box tamper (when the box is opened). This event can be simulated with jumper J1.
  • fraud tamper The STPM14 metering device is also able to detect tamper on the line or voltage wire. If a difference between currents in line and neutral wire is detected the device enters tamper mode. In normal mode, the current averages with a 50% multiplex ratio between the two channels. In tamper mode only the higher current is used for energy computation and the other current is monitored only to check if tamper is still present. For more details about line tamper please refer to STPM14 datasheet. Both box and line tamper events are detected by the microcontroller, which also records their timestamp and other sensitive data. During a tamper event the LCD displays the E bottom (tamper) symbol. The energy computation is still performed and increases the total energy; moreover the meter computes and stores the total amount of energy consummated during tamper events for each month.

5.1.2 IR Mode

The meter implements a simple IrDA communication, compliant with IEC 62056 protocol mode C, using two led (…) as transmitter and receiver. In this way it is possible to read all information stored in EEPROM, as energy consumption, tamper information and MD data or to change application parameters without opening the meter case or stopping its operation. A firmware library has been developed to communicate, through a hand held unit (HHU) connected to PC serial port, with a GUI interface.

  • read from a specified EEPROM memory location,
  • read from microcontroller RAM,
  • write in a specified EEPROM memory location,
  • reset all EEPROM memory locations
  • set RTC time and date. The GUI allows the baud rate to be set (from 300 to 19200 bps), the parity (odd / even), communication port, data format and other communication parameters. Two windows are available in the GUI, showing data sent and received from the microcontroller, in hexadecimal and ASCII format. For further details about the implemented IrDA protocol, refer to the IEC 62056 Protocol Mode C document. For the operation of the GUI and the command set please refer to the IrDA module for multi-tariff meter user manual.

5.1.3 LCD display

Table 8. LCD Common Information

0 Energy

data, the others are past months going backwards for 1 year.

9 Rate @1st tariff

10 Consumption for

11 Rate @2nd tariff

12 Consumption for

13 Rate @3rd tariff

14 Consumption for

15 Rate @4th tariff

16 Consumption for

or month or day, the others are previous data going backwards for 1 year.

  • Quarterly AMD case: j from 0 to 15 (displays 12 months + 4 quarters information).
  • Monthly AMD case: j from 0 to 11.
  • Daily AMD case: j from 0 to 365. Index i=0 refers to current quarter, month or day, it increases by one each button press up to the maximum for each case for past information.

Table 9. LCD Month Information

5.2 Operation during power failure

microcontroller is in Run Mode and all devices are powered on. to HALT mode and LCD, EEPROM and STPM14 are switched off.

5.2.1 Tamper mode

available, but box tamper is still recognized by the meter. Section 5.1.1: Tamper mode on page 18.

5.2.2 IR Mode

5.2.3 LCD Display

wakes up and the LCD displays the information listed above. to halt mode and the LCD is switched off again.

5.3 LCD icons description

The LCD can display different icons, which meaning is shown below. Table 10. LCD AMD Information

Table 11. LCD Icons

6 Additional features

6.1 STPM14 programming

memory) through a serial interface. board through J2 10 pins connector, as shown in Figure 3. Figure 3. Board connected to parallel hardware interface For more details on calibration and configuration bits please refer to STPM14 datasheet. For more details on GUI interface please refer to user manual UM0128.

6.2 In-circuit programming

  • In-circuit debugging
  • Real time code execution without probes
  • Customization of the application
  • Easy application debug. J1 10 pins connector is available for ICP functionality.

Figure 4. Microcontroller section schematic

Figure 5. Measurement section schematic Figure 6. Power supply section schematic Figure 7. Memory and RTC section schematic

230 Vac

Figure 8. IR and reset schematic Figure 9. Connectors and LCD schematic

16 MHZ

Table 12. BOM list

95 C13,C14,C20,

13 LL4148 Small signal diode SMD 1206

Table 12. BOM list (continued)

Figure 10. Top layer

Figure 11. Bottom layer

Figure 12. Components layer

7 Revision history

Table 13. Document revision history 17-Apr-2007 1 Initial release.