Microchip Technology ARD00330 Datenbogen

Seite von 62
PIC18F87J72 SINGLE-PHASE
ENERGY METER CALIBRATION
USER’S GUIDE
© 2011 Microchip Technology Inc.
DS51964A-page 59
Chapter 4.  Communication Protocol
4.1
PROTOCOL
The Universal Asynchronous Receiver and Transmitter (UART) of the PIC
Microcontroller is used to communicate with the meter. In addition to the reading and
writing of the registers, there are also dedicated commands for clearing, loading and
storing calibration registers to Flash. The first byte UART data is an ASCII character
that represents the command, and each command has a specific protocol. Each
command ends with the ASCII character “X”.
4.1.1
Command Description
The first byte of the data (byte 0) is an ASCII character E, L, S, W and R. 
• E – Request for Echo Response to which meter responds with “Q” as
acknowledgment
• L – Load Calibration Registers from Flash (LOAD)
• S – Store Calibration Registers (STORE)
• W – Write Bytes (WRITE)
• R – Read Bytes (READ)
• C – Load Default Calibration Values
The last data byte is always an ‘X’ character. All commands will result in the same com-
mand being returned. The exception is the ‘R’ (READ) command which will return the
additional data in lieu of the number of bytes.
4.1.1.1
“E” ECHO: - TO DETECT THE METER CONNECTION
Example: ‘EX’.
Returns: ‘QX’
4.1.1.2
“L” LOAD: LOAD CALIBRATION REGISTERS FROM FLASH 
Example: ‘LX’.
Returns: ‘LX’. 
This command is used to verify that the calibration values were actually written into
flash (or EEPROM). When the software executes a ‘SX’ command, it should verify that
the values were stored by issuing a ‘LX’ command and then reading the calibration
values with an ‘R’ command.
4.1.1.3
“S” STORE: STORE CALIBRATION REGISTERS INTO FLASH
The Store command writes all the calibration values to the internal EEPROM, and this
function takes some time. During that time, the meter is not functional. The Store
command should only be used after calibrating the meter, not while it is in actual use.
Example: ‘SX’. 
Returns: ‘SX’.