Fujitsu Semiconductor Design (Chengdu) Co., Ltd. Application Note MCU-AN-5000-E-0 F²MC-8FX FAMILY 8-BIT MICROCONTROLLER MB9540H/470H SERIES ONE PHASE POWER METER (CS5464) SOLUTION CS5464 OPERATION APPLICATION NOTE
Revision History Revision History Version Date Updated by Modifications.0.0 6//0 Funny Chen First Draft : Write the user manual of CS5464, and describe the energy measure function on Power Meter solution. This manual contains 4 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 () 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 () 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. 0 Fujitsu Semiconductor Design (Chengdu) Co., Ltd. MCU-AN-5000-E-0 Page
Contents Contents REVISION HISTORY... CONTENTS... 3 INTRODUCTION... 4 BACKGROUND... 5. Overview... 5. Features of CS5464... 5.3 Function diagram... 6 3 HW DIAGRAM... 7 3. The HW diagram of energy measure... 7 4 HW REFERENCE SCH... 8 5 FW DIAGRAM... 9 5. SPI Communication Process... 9 5. Firmware System Diagram... 0 6 FW FUNCTION LIST... 6. API... 6. HAL... 7 ADDITIONAL INFORMATION... 3 8 APPENDIX... 4 8. List of Figures and Tables... 4 MCU-AN-5000-E-0 Page 3
Chapter Introduction Introduction This application note describes how to use One Phase Power Meter (CS5464) solution s energy measure chip-cs5464. Chapter explains the background of CS5464. 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-5000-E-0 Page 4
Chapter Background Background Background of CS5464. Overview The CS5464 is an integrated power measurement device which combines three analog-to-digital converters, power calculation engine, energy-to-frequency converter, and a serial interface on a single chip. It is designed to accurately measure instantaneous current and voltage and calculate VRMS, IRMS, instantaneous power, active power, apparent power, and reactive power for high-performance power measurement applications. The CS5464 is optimized to interface to shunt resistors or current transformers for current measurement, and to resistive dividers or potential transformers for voltage measurement. The CS5464 features a tamper detection scheme that uses the larger of the active power measurements to register energy. Additional features include system-level calibration, temperature sensor, voltage sag & current fault detection, and phase compensation.. Features of CS5464 Energy Data Linearity: ±0.% of Reading over 000: Dynamic Range On-chip Functions: - Instantaneous Voltage, Current, and Power - IRMS and VRMS, Active, Reactive, and Apparent Power - Current Fault and Voltage Sag Detect - System Calibrations / Phase Compensation - Temperature Sensor - Energy-to-pulse Conversion - Positive-only Accumulation Mode Meets Accuracy Spec for IEC, ANSI, & JIS Low Power Consumption Tamper Detection in -Wire Distribution Systems GND-referenced Signals with Single Supply On-chip.5 V Reference (5 ppm/ C typ) Power Supply Monitor Simple Three-wire Digital Serial Interface Auto-boot Mode from Serial EPROM Power Supply Configurations: VA+ = +5 V; AGND = 0 V; VD+ = +3.3 V to +5 V MCU-AN-5000-E-0 Page 5
Chapter Background.3 Function diagram Figure -: The Function Diagram of CS5464 MCU-AN-5000-E-0 Page 6
Chapter 3 HW Diagram 3 HW Diagram Hardware diagram of energy measure system 3. The HW diagram of energy measure Voltage sample Load Current sample CS5464 MB95F48 Neutral Current sample Figure 3-: Hardware diagram MCU-AN-5000-E-0 Page 7
3 4 3 4 7 4 AGND DGND 3 4 3 4 3 VA+ VD+ 4 8 3 3 4 CS5464 Operation V.0.0 Chapter 4 HW Reference SCH 4 HW Reference SCH Hardware reference SCH of energy measure system +5V +5V R85 5.K R69 0K V_N J7 LA J8 NA R83 50K R90 50K R93 50K R8 R88 5.R C47 03 R89 C48 03 R7 R75 R86 50K R87 50K R94 50K R76 R77 50R 50R 00K 50R 50R R78 00KR79 50R C39 03 C40 03 C43 03 C45 03 C49 4700p C4 4700p C44 4700p MSE_V3P MSE_V3N MSE_VP MSE_VN MSE_VP MSE_VN C35 04 C36 04 U8 9 0 0 9 6 5 VIN+ IIN+ IIN- IIN- IIN+ VIN- VREFIN VREFOUT CS5464 R70 0R C37 04 PFMON CPUCLK XOUT XIN 8 8 MODE 3 RESET 7 CS 5 SCLK SDO 6 7 SDI 4 INT 5 E 6 E E3 3 TEST 4 TEST Y 4.096MHz R97 +5V R80 C46 R9 C5 R95 C5 K n K n K n R7 330R 330R +5V U9 PS50- +5V U0 PS50- VDD U PS50- U5 VDD PS50- MSE_RST R8 330R GND MSE_SCLK R9 330R GND MSE_SDI R98 R67 K C53 PS50- +5V U MSE_SDO R96 330R n GND C34 04 K MSE_PF GND 50R +5V R84 GND 330R U6 J4 PS50- PF CHECK Figure 4-: RCS5464 Reference SCH MCU-AN-5000-E-0 Page 8
Chapter 5 FW diagram 5 FW diagram Firmware system diagram of energy measure system 5. SPI Communication Process Figure 5-: SPI Write Process Figure 5-: SPI Read Process MCU-AN-5000-E-0 Page 9
Chapter 5 FW diagram 5. Firmware System Diagram Start Init Reg(CONFIG) Init Reg(CYCLECOUNT) Init Reg(PULSERATE) Capture Active Pulse Calc the energy based on the EC Light on the warning light Deduct the charge Balance <= 0? Y Balance < warning value? N Y N Turn off the relay End Figure 5-3: Firmware System Diagram MCU-AN-5000-E-0 Page 0
Chapter 6 FW Function List 6 FW Function List 6. API void CS5464_Reg_Init(void) void EnergyCount_Init(void) void AfeRefreshEnable(void) void AfeRefreshTask(void) Function Prototype void EnergyCount_Reset(void) void CurEnergyCount_Reset(void) void MeterKwhInc(void) void PowerEnergy(void) void GetMeterCurFwdEnergySum(INT8U *sumbuff) void GetMeterCurRevEnergySum(INT8U *sumbuff) void GetMeterCurAllEnergySum(INT8U *sumbuff) void ReadMeterRuntimeData(void) void SaveMeterRuntimeData(void) void ReadMeterConst(void) void ReadMeterClibData(void) void SaveMeterClibData(void) void LoadTimeSegInfo(void) Table 6-: FW API List void UpdateTimeSegTable(INT8U tableid, INT8U segcount, INT8U *segdata) INT8U FindTimeZoneSegTableSeriesId(INT8U idtype) INT8U FindTimeZoneSegTableId(INT8U idtype) INT8U FindTimeSegTariffId(INT8U hh, INT8U mm) void ValidateTimeZoneId(void) void ValidateTimeSegTableId(void) void SaveLastMonthAllEnergyCounter(void) void SaveLastMonthFwdEnergyCounter(void) void SaveLastMonthRevEnergyCounter(void) void SaveCurrentEnergyCounter(void) Description Initialize CS5464 register Initialize for energy counting AFE refresh enable Refresh AFE setup with a reset and reconfiguration Reset all meter energy data Reset current meter energy data Accumulate meter KWH with each pulse received Accumulate energy pulses & output calibration pulses Retrieve current sum of meter forward energy data Retrieve current sum of meter reverse energy data Retrieve current sum of meter total energy data Read meter energy data saved in EEPROM Save meter energy data to EEPROM Read meter constant from EEPROM Read meter clibration data from EEPROM Write meter calibration data to EEPROM Load or reset time-seg parameter in EEPROM Update time-seg table Find a time-zone series ID base on current calendar Find a time-zone-id and time-seg-table-id base on current calendar Find a time-seg tariff ID base on given time value hh(hour) & mm(minute) Validate time-zone ID base on current calendar Validate time-seg table ID base on current calendar Save last month's all energy counter value to EEPROM Save last month's forward energy counter value to EEPROM Save last month's reverse energy counter value to EEPROM Save current energy counter value base on MCU-AN-5000-E-0 Page
Chapter 6 FW Function List tariff ID void LoadEnergyCounter(void) void EnergyDirValidate(void) void GetTimeSegFwdEnergySum(INT8U *sum, INT8U monthid, INT8U segid) void GetTimeSegRevEnergySum(INT8U *sum, INT8U monthid, INT8U segid) void GetTimeSegAllEnergySum(INT8U *sum, INT8U monthid, INT8U segid) void UpdateTimeSegTariffId(void) INT3U GetVoltageRmsValue(void) INT3U GetLoadCurRmsValue(void) INT3U GetNeutralCurRmsValue(void) INT3U GetActivePowerValue(void) INT3U GetPowerFactorValue(void) void ResetEnergyParameter(void) void Read_I_V_Energy(void) void CS5464_StartConversion(INT8U mode) Load meter energy counter base on energy direction state Validate energy direction/state Get forward energy sum for a specific time segment Get reverse energy sum for a specific time segment Get energy forward+reversed sum for a specific time segment Update tariff ID based on current time segment Get scaled voltage reading Get scaled load current reading Get scaled neutral current reading Get scaled active power reading Get scaled power factor reading Reset energy parameters Read AFE I/V energy data CS5464 starts to conversion 6. HAL void SPIPortInit(void) Function Prototype Table 6-: FW HAL List Initialize SPI port Description void BcdEnergySumIntInc(INT8U *bcd) Increment a 4 byte BCD energy number by from integer part(bcd[]) void BcdEnergySumDecimalAcc(INT8U *bcd, INT8U accval) void CS5464_ReadRegister(INT8U page, INT8U regaddr, INT8U *buff) INT8U SPI_ReadByte(void) void CS5464_WriteRegister(INT8U page, INT8U regaddr, INT8U *buff) void SPI_SendByte(INT8U outdat) void CS5464_WaitForReady(void) INT8U CS5464_IsReady(void) void CS5464_SetRegPage(INT8U page) Accumulate a 4 byte BCD energy number Read CS5464 register value Byte in through SPI port Write CS5464 register value Byte out through SPI port CS5464 ready-status wait CS5464 ready-status check CS5464 set register page for read/write MCU-AN-5000-E-0 Page
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-5000-E-0 Page 3
Chapter 8 Appendix 8 Appendix 8. List of Figures and Tables Table 6-: FW API List... Table 6-: FW HAL List... Figure -: The Function Diagram of CS5464... 6 Figure 3-: Hardware diagram... 7 Figure 4-: RCS5464 Reference SCH... 8 Figure 5-: SPI Write Process... 9 Figure 5-: SPI Read Process... 9 Figure 5-3: Firmware System Diagram... 0 MCU-AN-5000-E-0 Page 4