415KB

The following document contains information on Cypress products.
Colophon
The products described in this document are designed, developed and manufactured as contemplated for general use,
including without limitation, ordinary industrial use, general office use, personal use, and household use, but are not
designed, developed and manufactured as contemplated (1) for any use that includes fatal risks or dangers that, unless
extremely high safety is secured, could have a serious effect to the public, and could lead directly to death, personal injury,
severe physical damage or other loss (i.e., nuclear reaction control in nuclear facility, aircraft flight control, air traffic control,
mass transport control, medical life support system, missile launch control in weapon system), or (2) for any use where
chance of failure is intolerable (i.e., submersible repeater and artificial satellite). Please note that Spansion will not be liable
to you and/or any third party for any claims or damages arising in connection with above-mentioned uses of the products.
Any semiconductor devices have an inherent chance of failure. You must protect against injury, damage or loss from such
failures by incorporating safety design measures into your facility and equipment such as redundancy, fire protection, and
prevention of over-current levels and other abnormal operating conditions. If any products described in this document
represent goods or technologies subject to certain restrictions on export under the Foreign Exchange and Foreign Trade Law
of Japan, the US Export Administration Regulations or the applicable laws of any other country, the prior authorization by the
respective government entity will be required for export of those products.
Trademarks and Notice
The contents of this document are subject to change without notice. This document may contain information on a Spansion
product under development by Spansion. Spansion reserves the right to change or discontinue work on any product without
notice. The information in this document is provided as is without warranty or guarantee of any kind as to its accuracy,
completeness, operability, fitness for particular purpose, merchantability, non-infringement of third-party rights, or any other
warranty, express, implied, or statutory. Spansion assumes no liability for any damages of any kind arising out of the use of
the information in this document.
®
®
®
TM
Copyright © 2013 Spansion Inc. All rights reserved. Spansion , the Spansion logo, MirrorBit , MirrorBit Eclipse ,
TM
ORNAND and combinations thereof, are trademarks and registered trademarks of Spansion LLC in the United States and
other countries. Other names used are for informational purposes only and may be trademarks of their respective owners.
Fujitsu Semiconductor Design (Chengdu) Co., Ltd.
Application Note
MCU-AN-500115-E-10
F²MC-8FX FAMILY
8-BIT MICROCONTROLLER
MB95410H/470H SERIES
ONE PHASE POWER METER
(RN8209) SOLUTION
RN8209 OPERATION
APPLICATION NOTE
RN8209 Operation V1.0.0
Revision History
Revision History
Version
Date
Updated by
Modifications
1.0.0
5/31/2011
Funny Chen
First Draft : Write the user manual of RN8209, and describe the
energy measure function on Power Meter solution.
This manual contains 14 pages.
Specifications are subject to change without notice. For further information please contact each office.
All Rights Reserved.
The contents of this document are subject to change without notice.
Customers are advised to consult with sales representatives before ordering.
The information, such as descriptions of function and application circuit examples, in this document are presented solely
for the purpose of reference to show examples of operations and uses of FUJITSU SEMICONDUCTOR device; FUJITSU
SEMICONDUCTOR does not warrant proper operation of the device with respect to use based on such information. When
you develop equipment incorporating the device based on such information, you must assume any responsibility arising
out of such use of the information.
FUJITSU SEMICONDUCTOR assumes no liability for any damages whatsoever arising out of the use of the information.
Any information in this document, including descriptions of function and schematic diagrams, shall not be construed as
license of the use or exercise of any intellectual property right, such as patent right or copyright, or any other right of
FUJITSU SEMICONDUCTOR or any third party or does FUJITSU SEMICONDUCTOR warrant non-infringement of
any third-party's intellectual property right or other right by using such information. FUJITSU SEMICONDUCTOR
assumes no liability for any infringement of the intellectual property rights or other rights of third parties which would
result from the use of information contained herein.
The products described in this document are designed, developed and manufactured as contemplated for general use,
including without limitation, ordinary industrial use, general office use, personal use, and household use, but are not
designed, developed and manufactured as contemplated (1) for use accompanying fatal risks or dangers that, unless
extremely high safety is secured, could have a serious effect to the public, and could lead directly to death, personal injury,
severe physical damage or other loss (i.e., nuclear reaction control in nuclear facility, aircraft flight control, air traffic
control, mass transport control, medical life support system, missile launch control in weapon system), or (2) for use
requiring extremely high reliability (i.e., submersible repeater and artificial satellite).
Please note that FUJITSU SEMICONDUCTOR will not be liable against you and/or any third party for any claims or
damages arising in connection with above-mentioned uses of the products.
Any semiconductor devices have an inherent chance of failure. You must protect against injury, damage or loss from such
failures by incorporating safety design measures into your facility and equipment such as redundancy, fire protection, and
prevention of over-current levels and other abnormal operating conditions.
Exportation/release of any products described in this document may require necessary procedures in accordance with the
regulations of the Foreign Exchange and Foreign Trade Control Law of Japan and/or US export control laws.
The company names and brand names herein are the trademarks or registered trademarks of their respective owners.
© 2011 Fujitsu Semiconductor Design (Chengdu) Co., Ltd.
MCU-AN-500115-E-10 – Page 2
RN8209 Operation V1.0.0
Contents
Contents
REVISION HISTORY ............................................................................................................ 2
CONTENTS .......................................................................................................................... 3
1 INTRODUCTION .............................................................................................................. 4
2 BACKGROUND ............................................................................................................... 5
2.1
Overview ................................................................................................................. 5
2.2
Features of RN8209 ................................................................................................ 5
2.3
Function diagram..................................................................................................... 5
3 HW DIAGRAM ................................................................................................................. 6
3.1
The HW diagram of energy measure ....................................................................... 6
4 HW REFERENCE SCH .................................................................................................... 7
5 FW DIAGRAM .................................................................................................................. 9
5.1
SPI Frame Format ................................................................................................... 9
5.2
SPI Communication Process ................................................................................... 9
5.3
Firmware System Diagram .................................................................................... 10
6 FW FUNCTION LIST...................................................................................................... 11
6.1
API ........................................................................................................................ 11
6.2
HAL ....................................................................................................................... 12
7 ADDITIONAL INFORMATION ....................................................................................... 13
8 APPENDIX ..................................................................................................................... 14
8.1
List of Figures and Tables ..................................................................................... 14
MCU-AN-500115-E-10 – Page 3
RN8209 Operation V1.0.0
Chapter 1 Introduction
1 Introduction
This application note describes how to use One Phase Power Meter (RN8209) solution’s
energy measure chip-RN8209.
Chapter 2 explains the background of RN8209.
Chapter 3 explains the HW diagram of energy measure function.
Chapter 4 explains the HW reference SCH.
Chapter 5 explains the FW diagram.
Chapter 6 explains the FW function list.
MCU-AN-500115-E-10 – Page 4
RN8209 Operation V1.0.0
Chapter 2 Background
2 Background
Background of RN8209
2.1
Overview
RN8209 can measure active power, inactive power, active energy, inactive energy, and can
also provide 2 channels of individual active power and current RMS, voltage RMS, and so on.
RN8209 can realize the solution to prevent the theft of power.
RN8209 support the gain calibration, phase calibration and offset calibration.
2.2
2.3
Features of RN8209

Measure

Software calibration

SPI/RSIO communication

Power watch function

VCC-+5v, power consume-32mw

Internal reference voltage-2.5v±3%, the type value of temperature parameter25ppm/℃
Function diagram
Figure 2-1: The Function Diagram of RN8209
MCU-AN-500115-E-10 – Page 5
RN8209 Operation V1.0.0
Chapter 3 HW Diagram
3 HW Diagram
Hardware diagram of energy measure system
3.1
The HW diagram of energy measure
Voltage sample
Load Current sample
RN8209
Neutral Current sample
Figure 3-1: Hardware diagram
MCU-AN-500115-E-10 – Page 6
MB95F418
RN8209 Operation V1.0.0
Chapter 4 HW Reference SCH
4 HW Reference SCH
Hardware reference SCH of energy measure system
+5V
C41
C55
R74
C54
C56
10R
104
106
10R
104
106
WGND
MSE_AVDD
R73
MSE_V1P
MSE_V1N
MSE_V2P
MSE_V2N
MSE_V3P
MSE_V3N
MSE_REFV
C59
104
106
U23
1
2
3
4
5
6
7
8
9
10
11
12
MSE_nRST
C61
WGND
AVDD
QF
RST_N
PF
NC1
IRQ_N/ZX
V1P
NC2
V1N
OSCO
V2P
OSCI
V2N
DVDD
V3P
DGND
V3N
SCSN
REFV
SCLK
AGND
SDI
IS
SDO
24
23
22
21
20
19
18
17
16
15
14
13
PF
Y 3 C57 22p
3.579545MHz
WGND
SCSN
SCLK
SDI WGND
SDO
RN8209
R99 10K
+5V
WGND
Figure 4-1: RN8209 Periphery Diagram
R1001K
MSE_V1P
C60
J9
1
2
33n
C62
LA
WGND
33n
R101
1K
MSE_V1N
Figure 4-2: Load Current Sample Circuit
R101
J9
NA
1
2
MSE_V2P
1K
R103
C60
20R
33n
R100 WGND
C62
20R
33n
R102 1K
MSE_V2N
Figure 4-3: Neutral Current Sample Circuit
MCU-AN-500115-E-10 – Page 7
C58
22p
RN8209 Operation V1.0.0
Chapter 4 HW Reference SCH
R105 150K
R107 100K
MSE_V3P
MSE_V3N
R104 150K
R103 150K
R102 150K R108 C60
1K
R106 150K
R100 C62
33n
1K
33n
R101 150K
V_N
WGND
WGND
Figure 4-4: Voltage Sample Circuit
+5V
1n
2
R107
3
R106 1K
C64
MSE_SCSN
1
U27
4
SCSN
PS2501-1
330R
+5V
GND
U24
4
SCLK
MSE_SCLK
1
WGND
R103 1K
2
1n
3
R104
C63
PS2501-1
WGND
330R
SDI
MSE_SDO
R101
WGND
2
1n
3
C60
GND
U26
1
R100 1K
4
+5V
PS2501-1
330R
SDO
U25
GND
MSE_SDI
4
1
VDD
330R
3
R102
2
R105
C62
PS2501-1
WGND
Figure 4-5: SPI Communication Circuit
MCU-AN-500115-E-10 – Page 8
1K
1n
GND
RN8209 Operation V1.0.0
Chapter 5 FW diagram
5 FW diagram
Firmware system diagram of energy measure system
5.1
SPI Frame Format
Table 5-1: SPI Frame Format
Command
Command Register
Data
Read Command
{0,REG_ADR[6:0]}
RDATA
Write Command
{1,REG_ADR[6:0]}
WDATA
Write Enable Command
0xEA
0xE5
Write Protect Command
0xEA
0xDC
A Channel Select Command
0xEA
0x5A
B Channel Select Command
0xEA
0Xa5
5.2
Remark
SPI Communication Process
Figure 5-1: SPI Write Process
Figure 5-2: SPI Read Process
MCU-AN-500115-E-10 – Page 9
RN8209 Operation V1.0.0
Chapter 5 FW diagram
5.3
Firmware System Diagram
Start
Init Reg(SYSCON)
Init Reg(EMUCON)
Init Reg(HFConst)
Capture Active Pulse
Calc the energy based
on the EC
Light on the warning light
Deduct the charge
Balance <= 0
?
Balance <
warning
value?
Y
Y
N
N
End
Figure 5-3: Firmware System Diagram
MCU-AN-500115-E-10 – Page 10
Turn off the relay
RN8209 Operation V1.0.0
Chapter 6 FW Function List
6 FW Function List
6.1
API
Table 6-1: FW API List 1
Function Prototype
Description
void RN8209_Reg_Init(void)
Initialize RN8209 register
void EnergyCount_Init(void)
Initialize for energy counting
void EnergyCount_Reset(void)
Reset all meter energy data
void CurEnergyCount_Reset(void)
Reset current meter energy data
void MeterKwhInc(void)
Accumulate meter KWH with each pulse
received
void PowerEnergy(void)
Accumulate energy pulses & output calibration
pulses
void GetMeterCurFwdEnergySum(INT8U *sumBuff)
Retrieve current sum of meter forward energy
data
void GetMeterCurRevEnergySum(INT8U *sumBuff)
Retrieve current sum of meter reverse energy
data
void GetMeterCurAllEnergySum(INT8U *sumBuff)
Retrieve current sum of meter total energy
data
void ReadMeterRuntimeData(void)
Read meter energy data saved in EEPROM
void SaveMeterRuntimeData(void)
Save meter energy data to EEPROM
void ReadMeterConst(void)
Read meter constant from EEPROM
void ReadMeterClibData(void)
Read meter clibration data from EEPROM
void SaveMeterClibData(void)
Write meter calibration data to EEPROM
void LoadTimeSegInfo(void)
Load or reset time-seg parameter in EEPROM
void UpdateTimeSegTable(INT8U tableId, INT8U segCount,
INT8U *segData)
INT8U FindTimeZoneSegTableSeriesId(INT8U idType)
Update time-seg table
INT8U FindTimeZoneSegTableId(INT8U idType)
Find a time-zone-ID and time-seg-table-ID
base on current calendar
INT8U FindTimeSegTariffId(INT8U hh, INT8U mm)
Find a time-seg tariff ID base on given time
value hh(hour) & mm(minute)
void ValidateTimeZoneId(void)
Validate time-zone ID base on current
calendar
void ValidateTimeSegTableId(void)
Validate time-seg table ID base on current
calendar
Find a time-zone series ID base on current
calendar
MCU-AN-500115-E-10 – Page 11
RN8209 Operation V1.0.0
Chapter 6 FW Function List
Table 6-2: FW API List 2
Function Prototype
Description
void SaveLastMonthAllEnergyCounter(void)
Save last month's all energy counter value to
EEPROM
void SaveLastMonthFwdEnergyCounter(void)
Save last month's forward energy counter
value to EEPROM
void SaveLastMonthRevEnergyCounter(void)
Save last month's reverse energy counter
value to EEPROM
void SaveCurrentEnergyCounter(void)
Save current energy counter value base on
tariff ID
void LoadEnergyCounter(void)
Load meter energy counter base on energy
direction state
void EnergyDirValidate(void)
Validate energy direction/state
void GetTimeSegFwdEnergySum(INT8U *sum, INT8U
monthId, INT8U segId)
Get forward energy sum for a specific time
segment
void GetTimeSegRevEnergySum(INT8U *sum, INT8U
monthId, INT8U segId)
Get reverse energy sum for a specific time
segment
void GetTimeSegAllEnergySum(INT8U *sum, INT8U
monthId, INT8U segId)
Get energy forward+reversed sum for a
specific time segment
void UpdateTimeSegTariffId(void)
Update tariff ID based on current time segment
INT32U GetVoltageRmsValue(void)
Get scaled voltage reading
INT32U GetLoadCurRmsValue(void)
Get scaled load current reading
INT32U GetNeutralCurRmsValue(void)
Get scaled neutral current reading
INT32U GetActivePowerValue(void)
Get scaled active power reading
INT32U GetPowerFactorValue(void)
Get scaled power factor reading
6.2
HAL
Table 6-3: FW HAL List
Function Prototype
Description
void SPIPortInit(void)
Initialize SPI port
void BcdEnergySumIntInc(INT8U *bcd)
Increment a 4 byte BCD energy number by 1
from integer part(bcd[2])
void BcdEnergySumDecimalAcc(INT8U *bcd, INT8U
accVal)
void RN8209_ReadRegister(INT8U regAddr, INT8U *buff,
INT8U total)
INT8U SPI_ReadByte(void)
Accumulate a 4 byte BCD energy number
void RN8209_WriteRegister(INT8U regAddr, INT8U *buff,
INT8U total)
void SPI_SendByte(INT8U outDat)
Write RN8209 register value
Read RN8209 register value
Byte in through SPI port
Byte out through SPI port
MCU-AN-500115-E-10 – Page 12
RN8209 Operation V1.0.0
Chapter 7 Additional Information
7 Additional Information
For more Information on FUJITSU semiconductor products, visit the following websites:
English version address:
http://www.fujitsu.com/cn/fsp/services/mcu/mb95/application_notes.html
Chinese version address:
http://www.fujitsu.com/cn/fss/services/mcu/mb95/application_notes.html
MCU-AN-500115-E-10 – Page 13
RN8209 Operation V1.0.0
Chapter 8 Appendix
8 Appendix
8.1
List of Figures and Tables
Table 5-1: SPI Frame Format................................................................................................. 9
Table 6-1: FW API List 1 ...................................................................................................... 11
Table 6-2: FW API List 2 ...................................................................................................... 12
Table 6-3: FW HAL List ........................................................................................................ 12
Figure 2-1: The Function Diagram of RN8209 ........................................................................ 5
Figure 3-1: Hardware diagram ............................................................................................... 6
Figure 4-1: RN8209 Periphery Diagram ................................................................................. 7
Figure 4-2: Load Current Sample Circuit ................................................................................ 7
Figure 4-3: Neutral Current Sample Circuit ............................................................................ 7
Figure 4-4: Voltage Sample Circuit......................................................................................... 8
Figure 4-5: SPI Communication Circuit .................................................................................. 8
Figure 5-1: SPI Write Process ................................................................................................ 9
Figure 5-2: SPI Read Process................................................................................................ 9
Figure 5-3: Firmware System Diagram ................................................................................. 10
MCU-AN-500115-E-10 – Page 14