Microchip Technology MCP3901, PIC18F65J90 User Manual

MCP3901 and PIC18F65J90
Energy Meter Reference Design
User’s Guide
© 2012 Microchip Technology Inc. DS51968A
Note the following details of the code protection feature on Microchip devices:
Microchip products meet the specification contained in their particular Microchip Data Sheet.
Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the intended manner and under normal conditions.
There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
Microchip is willing to work with the customer who is concerned about the integrity of their code.
Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not mean that we are guaranteeing the product as “unbreakable.”
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our products. Attempts to break Microchip’s code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
Information contained in this publication regarding device applications and t he lik e is provided only for your convenience and may be su perseded by upda t es . It is y our responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life supp ort and/or safety ap plications is entir ely at the buyer’s risk, and the buyer agrees to defend, indemnify and hold harmless M icrochip from any and all dama ges, claims, suits, or expenses re sulting from such use. No licens es are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.

Trademarks

The Microchip name and logo, the Microchip logo, dsPIC, K
EELOQ, KEELOQ logo, MPLAB, PIC, PICmicro, PICSTART,
32
PIC
logo, rfPIC and UNI/O are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.
FilterLab, Hampshire, HI-TECH C, Linear Active Thermistor, MXDEV, MXLAB, SEEVAL and The Embedded Control Solutions Company are registered trademarks of Microchip Technology Incorporated in the U.S.A.
Analog-for-the-Digital Age, Application Maestro, chipKIT, chipKIT logo, CodeGuard, dsPICDEM, dsPICDEM.net, dsPICworks, dsSPEAK, ECAN, ECONOMONITOR, FanSense, HI-TIDE, In-Circuit Serial Programming, ICSP, Mindi, MiWi, MPASM, MPLAB Certified logo, MPLIB, MPLINK, mTouch, Omniscient Code Generation, PICC, PICC-18, PICDEM, PICDEM.net, PICkit, PICtail, REAL ICE, rfLAB, Select Mode, Total Endurance, TSHARC, UniWinDriver, WiperLock and ZENA are trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.
SQTP is a service mark of Microchip Technology Incorporated in the U.S.A.
All other trademarks mentioned herein are property of their respective companies.
© 2012, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved.
Printed on recycled paper.
ISBN: 978-1-61341-960-1
Microchip received ISO/TS-16949:2009 certification for its worldwide headquarters, design and wafer fabrication facilities in Chandler and Tempe, Arizona; Gresham, Oregon and design centers in California and India. The Company’s quality system processes and procedures are for its PIC devices, Serial EEPROMs, microperipherals, nonvolatile memory and analog products. In addition, Microchip’s quality system for the design and manufacture of development systems is ISO 9001:2000 certified.
®
MCUs and dsPIC® DSCs, KEELOQ
®
code hopping
DS51968A-page 2 © 2012 Microchip Technology Inc.
MCP3901 AND PIC18F65J90
ENERGY METER
REFERENCE DESIGN

Table of Contents

Preface ...........................................................................................................................7
Introduction............................................................................................................7
Document Layout .................................................................................................. 8
Conventions Used in this Guide............................................................................ 9
Recommended Reading.............................................................. .. ......................10
The Microchip Web Site...................................................................................... 10
Customer Support.................... .................................... .................. .....................10
Document Revision History................................................................................. 10
Chapter 1. Product Overview
1.1 Introduction ...................................................................................................11
1.2 What the MCP3901 and PIC18F65J90 Energy Meter
Reference Design Kit Includes ............................................................... 12
1.3 Getting Sta rted .... .................................................................................. ....... 12
Chapter 2. Hardware
2.1 Overview ............. ......................................................................................... 13
2.2 Input and Analog Front End .........................................................................16
Chapter 3. Calculation Engine and Register Description
3.1 Calculati on E n g in e Si g nal Flow Summary ................................................... 17
3.2 Register L is t ................................................................................................. 18
3.3 MODE .......................................................................................................... . 19
3.4 STATUS .......... .. ........................................................................................... 20
3.5 CAL_CONT R O L ........................................................................................... 20
3.6 LINE_CYC ................. .. ................................................................................ 21
3.7 LINE_CYC _ C N T ............. ... ..................................................... .. .. ................ 2 1
3.8 RAW2_I_RMS ..............................................................................................21
3.9 RAW_I_RM S .................... .......................................... .................................. 22
3.10 I_RMS ............... ......................................................................................... 22
3.11 RAW2_V _ R M S ......................................................................................... 22
3.12 RAW_V_ R M S .......................... ........................................................ ......... 22
3.13 V_RMS ....... ... .. ........................................................................................... 22
3.14 LINE_F R E Q UE N CY ............................................... .................................... 23
3.15 RAW_PO WER_ACT ......................................... ........................................ 23
3.16 POWER_ A CT ..................................... .......................................... .............. 23
3.17 POWER_APP ............................................................................................23
3.18 RAW_PO WER_REACT .......... ................ ................................................... 24
3.19 POWER_ R EA CT ...... .. .. ............................. .......................................... ....... 24
© 2012 Microchip Technology Inc. DS51968A-page 3
MCP3901 and PIC18F65J90 Energy Meter Reference De sign
3.20 PERIOD .... ....................................................... ........................................... 24
3.21 ENERG Y _ AC T ............. .. ............................ ................................................ 24
3.22 ENERGY_APP ..........................................................................................25
3.23 I_ABS_MAX ...............................................................................................25
3.24 V_ABS _ M A X ............. ... .............................................................................. 2 5
3.25 ENERG Y _ RE A C T ...................................................................................... 25
3.26 PHASE_COMPENSATION ........................................................................ 25
3.27 OFFSE T _ I_ R M S .. .. .................................................................................. . 26
3.28 OFFS ET _ V _RMS . .. ..................................................... .. ... ......................... 2 6
3.29 GAIN_I_RMS ............................................................................................. 26
3.30 GAIN_V _ R MS ............................................................................................ 26
3.31 OFFSE T _ P O WE R _ A CT .................... ...................................................... 26
3.32 GAIN_P O WER_ACT ........ .. ........................................................................ 27
3.33 OFFSE T _ P O WE R _ RE ACT .............. ........................................................ 27
3.34 GAIN_P O WER_REACT ... .................................................................... ...... 27
3.35 GAIN_E N E RGY_ACT ................................................................................ 27
3.36 GAIN_ENERGY_APP ................................................................................ 27
3.37 GAIN_E N E RGY_REACT . .. .. ...................................................................... 27
3.38 CF_PU LSE_WIDTH ............. ...................................................................... 28
3.39 GAIN_D E N R_ENERGY_A C T ......... ................ ........................................... 28
3.40 GAIN_N U MR_ENERGY_ A CT ............................................ ....................... 28
3.41 MODE1 _ D EF ............................................................. .............................. 28
3.42 CAL_ST A T US ........... ... .......................... .. .. ................................................ 28
3.43 MAXIMUM CURRENT ............................................................................. 29
3.44 CALIB R AT ION_VOLTAG E ....... .. ..................................................... .. ... ... 29
3.45 CALIBRATION_CURRENT ......................................................................29
3.46 CALIB R AT ION_FREQUE N CY . ................................................................. 29
3.47 METER _ C ON S T A N T ......................................... ....................................... 2 9
3.48 CALIB R A T I O N _ L INE _ C Y CLE ................................................. ... .. ............ 30
3.49 GAIN_D E N R_ENERGY_R EA C T ............ .. ... ............................................. 30
3.50 GAIN_N U MR_ENERGY_ R E ACT ............. ................................................ 30
3.51 PHASE_COMPENSATION_90 ................................................................. 30
3.52 CREEP_THRSHOLD_MINUTE ................................................................. 30
3.53 CREEP_THRSHOLD_SECOND ................................................................30
Chapter 4. Meter Protocol and Timings
4.1 Protocol ..................................................... .. ... ............................................. 31
Appendix A. Schematic and Layouts
A.1 Introduction .................................................................................................. 33
A.2 Schematics and PCB Layout ........................ ......................... .. .. ..................33
A.3 Board – ADC Schematic ............................................................................. 34
A.4 Board – MCU S c he matic ........... .. ............. .. ... ............................................. 35
A.5 Board – LCD and USB Schematic .............. .. ............................... ................36
A.6 Board – Top Silk and Pads ........................ .. ..................... .......................... 37
A.7 Board – Top Copper .................................................................................... 38
DS51968A-page 4 © 2012 Microchip Technology Inc.
A.8 Board – Bottom Copper ...............................................................................39
A.9 Board – Bottom Silk and Pads ..................... .. .. .. ............................. .. ...........40
A.10 Board – To p 3 D ............................................................. .. .. ............. ... .. ....... 41
A.11 Board – Bo tt om 3D ...... ............. ... .. ............. .. .. ........................... .. .. ............ 42
Appendix B. Bill of Materials (BOM)
Worldwide Sales and Service ....................................................................................46
© 2012 Microchip Technology Inc. DS51968A-page 5
MCP3901 and PIC18F65J90 Energy Meter Reference De sign
DS51968A-page 6 © 2012 Microchip Technology Inc.
MCP3901 AND PIC18F65J90
ENERGY METER
REFERENCE DESIGN

Preface

NOTICE TO CUSTOMERS
All documentation becomes dated, and this manual is no exception. Microchip tools and documentation are constantly evolving to meet customer needs, so some actual dialogs and/or tool descriptions may differ from those in this document. Please refer to our web site (www.microchip.com) to obtain the latest documentation available.
Documents are identified with a “DS” number. This number is located on the bottom of each page, in front of the p age number. The numbering convention for the DS number is “DSXXXXXA”, where “XXXXX” is the document number and “A” is the revision level of the document.
For the most up-to-date information on development tools, see the MPLAB Select the Help menu, and then Topics to open a list of available online help files.
®
IDE online help.
INTRODUCTION
This chapter contains general information that will be useful to know before using the MCP3901 and PIC18F65J90 Energy Meter Reference Design User’s Guide. Items discussed in this chapter include:
• Document Layout
• Conventions Used in this Guide
• Recommended Reading
• The Microchip Web Site
• Customer Support
• Document Revision History
© 2012 Microchip Technology Inc. DS51968A-page 7
MCP3901 and PIC18F65J90 Energy Meter Reference De sign
DOCUMENT LAYOUT
This document describes how to use the MCP3901 and PIC18F65J90 Energy Meter Reference Design as a development tool to emulate and debug firmware on a target board. The manual layout is as follows:
Chapter 1. “Product Overview” – Important information on using the MCP3901
and PIC18F65J90 Energy Meter Reference Design including a Getting Started section that describes wiring the line and load connections.
Chapter 2. “Hardwa re ” – Includes details on the function blocks of the meter
including the analog front end design, phase lock loop circuitry, and power supply design.
Chapter 3. “Calculation Engine and Register Description” – This section
describes the digital signal flow for all power output quantities such as RMS current, RMS voltage, active power, and apparent power. This section also includes the calibration register’s detail.
Chapter 4. “Meter Protocol and Timings”– This chapter describes the protocol
used for accessing the registers, including commands that are used to interface to the meter.
Appendix A. “Schematic and Layouts” – Shows the schematic and layout
diagrams.
Appendix B. “Bill of Materials (BOM)” – Lists the parts used to build the
MCP3901 and PIC18F65J90 Energy Meter Reference Design.
DS51968A-page 8 © 2012 Microchip Technology Inc.
CONVENTIONS USED IN THIS GUIDE
This manual uses the following docum entat io n conven tion s:
DOCUMENTATION CONVENTIONS
Description Represents Examples
Arial font:
Italic chara c ters Referenced books MPLAB
Initial caps A window the Output window
Quotes A field name in a window or
Underlined, italic text with right angle bracket
Bold characters A dialog button Click OK
N‘Rnnnn A number in verilog format,
Text in angle brackets < > A key on the keyboard Press <Enter>, <F1>
Courier New font:
Plain Courier New Sample source code #define START
Italic Courier New A variable argument file.o, where file can be
Square brackets [ ] Optional arguments mcc18 [options] file
Curly brackets and pipe character: { | }
Ellipses... Replaces r epeated text var_name [,
Preface
®
IDE User’s Guide
Emphasized text ...is the only compiler...
A dialog the Settings dialog A menu selection select Enable Programmer
“Save project before build”
dialog A menu path File>Save
A tab Click the Power tab
4‘b0010, 2‘hF1 where N is the tota l number of digits, R is th e radi x and n is a digit.
Filenames autoexec.bat File paths c:\mcc18\h Keywords _asm, _endasm, static Command-line options -Opa+, -Opa- Bit values 0, 1 Constants 0xFF, ‘A’
any valid filename
[options]
Choice of mut ually exclus ive arguments; an OR selection
Represents code supplied by user
errorlevel {0|1}
var_name...]
void main (void)
{ ...
}
© 2012 Microchip Technology Inc. DS51968A-page 9
MCP3901 and PIC18F65J90 Energy Meter Reference De sign
RECOMMENDED READING
This user's guide describes how to use the MCP3901 and PIC18F65J90 Energy Meter Reference Design. Other useful documents are listed below. The following Microchip documents are available and recommended as supplemental reference resources.
MCP3901 Data Sheet – “Two Channel Analog Front End” (DS22192)
This data sheet provides detailed information regarding the MCP3901 device.
AN994 – “IEC Compliant Active-Energy Meter Design Using the MCP3905A/06A” (DS00994)
This application note documents the design decisions associated with using the MCP390X devices for energy meter design and IEC compliance.
THE MICROCHI P WEB SITE
Microchip provides online support via our web site at www.microchip.com. This web site is used as a means to make files and information easily available to customers. Accessible by using your favorite Internet browser, the web site contains the following information:
Product Support – Data sheets and errata, application notes and sample programs, design resources, user’s guides and hardware support documents, latest software releases and archived software
General Technical Support – Frequently Asked Questions (FAQs), technical support requests, online discussion groups, Microchip consultant program member listin g
Business of Microchip – Product selector and ordering guides, latest Microchip press releases, listing of seminars and events, listings of Microchip sales offices, distributors and factory representatives
CUSTOMER SUPPORT
Users of Microchip products can receive assistance through several channels:
• Distributor or Representative
• Local Sales Office
• Field Application Engineer (FAE)
• Technical Support
Customers should contact their distributor, representative or field application engineer (FAE) for support. Local sales offices are also available to help customers. A listing of sales offices and locations is included in the back of this document.
Technical support is available through the web site at:
http://www.microchip.com/support.

DOCUMENT REVISION HISTORY

Revision A (January 2012)
• Initial Release of this Document.
DS51968A-page 10 © 2012 Microchip Technology Inc.

Chapter 1. Product Overview

1.1 INTRODUCTION

The MCP3901 and PIC18F65J90 Energy Meter Reference Design is a fully functional IEC Class 0.5 compliant single-phase meter. This low-cost design does not use any transformers and requires few external components. The PIC18F65J90 directly drives the LCD, and includes both an isolated USB connection for meter calibration and access to the device power calculations. The system calculates active energy, active power, RMS current, RMS voltage, reactive energy, reactive power, apparent power and other typical power quantities.
The Microchip Energy Meter 1-Phase Software is used to calibrate and monitor the system, and can be used to create custom calibration setups. For some accuracy requirements, only a single point calibration may be needed. The energy meter software offers an automated step-by-step calibration process that can be used to quickly calibrate energy meters.
MCP3901 AND PIC18F65J90
ENERGY METER
REFERENCE DESIGN
FIGURE 1-1: MCP3901 and PIC18F65J90 Single-Phase Energy Meter.
© 2012 Microchip Technology Inc. DS51968A-page 11
MCP3901 and PIC18F65J90 Energy Meter Reference De sign

1.2 WHAT THE MCP3901 AND PIC18F65J90 ENERGY METER REFERENCE DESIGN KIT INCLUDES

This MCP3901 and PIC18F65J90 Energy Meter Reference Design kit includes:
• MCP3901 and PIC18F65J90 Energy Meter Reference Design User’s Guide
• Important Information Sheet

1.3 GETTING STARTED

To describe how to use the MCP3901 and PIC18F65J90 Energy Meter Reference Design, the following example is given using a two-wire 1-phase, 220 V AC line voltage and connections using energy meter calibrator equipment, or other programmable load source. The meter design uses a 5A load for calibration current, and a maximum current (I
To test a calibrated meter, the following connections apply for a two-wire connection.
1.3.1 Step 1: Wiring Connections
Figure 1-2 identifies the line and load connections of the MCP3901 and PIC18F65J90 Energy Meter Reference Design.
MAX
) of 60A.
1
Line
Neutral
MAIN
2
3
4
Line
Neutral
LOAD
FIGURE 1-2: Example Connections using a 2-Wire System.
1.3.2 Step 2: Turn On Line/Load Power to the Meter (Power the Meter)
The meter will turn on when the line connection has 220V connected. The LCD display will show the total energy accumulated.
DS51968A-page 12 © 2012 Microchip Technology Inc.

2.1 OVERVIEW

Figures 2-1 and 2-2 show the MCP3901 and PIC18F65J90 and Energy Meter
Reference Design:
MCP3901 AND PIC18F65J90
ENERGY METER
REFERENCE DESIGN

Chapter 2. Hardware

3
1
4
2
10
J2
U1
LCD1
9
D9D8
D1
P1
D3
J4
J3
D2
SW3
8
7
SW1
C40
SW2
DANGER
HIGH VOLTAGE
MCP3901 / PIC18F65J90 SHUNT METER
Legend:
1 = IR for meter communication 7 = Push button Switches 2 = Test points 8 = 9-digit LCD Disp lay with icons for kWh and kVARh 3 = MCP3901 Analog Front End 9 = Pulse Output for Active and Reactive
4 = +9V DC Input (non-isolated) 10 = USB Connection (isolated) 5 = Connections to shunt
current sensing resistor
6 = Connections to Line and Neutral
5
6
(isolated)
FIGURE 2-1: Top View – Hardware Components.
© 2012 Microchip Technology Inc. DS51968A-page 13
MCP3901 and PIC18F65J90 Energy Meter Reference De sign
.
17
C40
R21 R20
X2
R28
R27 R26
C32
C24 C25
R19
U7
R17
U4
C7
R29
U2
C39
R33
C37
U5
R30
R34
16
12
13
DANGER
HIGH VOLTAGE
C6
C5
C41
R14 R12 C2
R15 R11 C1
L1
Q1
C38
D5
D4
U8
C30 C27 C21 C22
C10
R31 C23
D6
L2
L3
R24 R25
C19
C17
R18
C16
D7
C4
MOV1
U6
C8
C9
R32
U3
Legend:
12 = Opto-isolators for Pulse outputs 13 = Power supply 14 = Non-volatile memory for calibration constants and energy usage data 15 = PIC18F65J90 16 = Isolation IC 17 = MCP2200 for USB connection
15
14
FIGURE 2-2: Bottom View – Hardware Components.
DS51968A-page 14 © 2012 Microchip Technology Inc.
Hardware
PIC18F65J90
RA2
RA3 RG1
RG4
RC7/RX RC6/TX
RA5
RC3/SCK
RC4/SDI
RC5/SDO
RA1
SWITCH SWITCH
USB to UART
Converter
MCP2200
Active Power
Mini - USB Connector
(ISOLATED)
SCK
SDO
SDI CS
MCP3901
AFE
SCK
SDO
SDI CS
Reactive Power
FIGURE 2-3: Digital Connections.
25LC256
SPI - EEPROM
© 2012 Microchip Technology Inc. DS51968A-page 15
Loading...
+ 32 hidden pages