1.2.7.1.2 Manual Calibration
The calibration constants must be calculated according to the metrology library documentation. A spreadsheet is included in the distribution package to make the procedure easier. This spreadsheet calculates the proper values of the CAL_x registers and generates the commands to be sent to the board through the serial console to update the registers. This section explains how to calibrate the board using the spreadsheet. These are the steps to follow:
- Follow the instructions described in the previous chapter, ensuring that the board is properly configured, paying special attention to the configuration related to the hardware connected to the metrology inputs
- Open the
METROLOGY_CONFIGURE_CALIBRATE_CALCULATE.xlsx spreadsheet, and go to the
"Step-by-step guide" sheet, and follow the steps. Note: The steps described can change depending on the version of the Excel file.
- Configure the input sources and the meter tester if used (meter form, voltage, current, and so on). In this example, a PIC32CXMTSH board will be calibrated using a WECO tester, configured to generate 1A and 220V to each phase, at 50 Hz. Phase shift between voltage vectors is 120º, and phase shift between voltage and current vectors is 60º for each phase, but any convenient values of voltage, current and phase angle may be used.
- Write these values in the yellow
cells.
Figure 1-47. Input Sources Configuration 
- If voltage-to-voltage phase
correction is desired, write “1” in the yellow cells. If enabled, the metrology
library will correct the phase shift between the voltage vectors. Then select
channels to calibrate, in this case, for PIC32CXMTSH channels A and B are
selected.
Figure 1-48. Voltage-to-Voltage Phase Correction and Channel Selection 
- Set the calibration constants to the
default values (unity gain and zero phase adjustments). To do that, copy the green
and purple cells to the metrology console. The constants can be sent as groups using
the DCM command:
Figure 1-49. Set Default Values as Groups 
>DCM( 34:20000000; 35:20000000; 36:20000000; 37:20000000; 38:20000000; 39:20000000; 40:20000000 ) Set 34 Is Ok ! Set 35 Is Ok ! Set 36 Is Ok ! Set 37 Is Ok ! Set 38 Is Ok ! Set 39 Is Ok ! Set 40 Is Ok ! >DCM( 41:0; 42:0; 43:0; 44:0; 45:0; 46:0; 47:0 ) Set 41 Is Ok ! Set 42 Is Ok ! Set 43 Is Ok ! Set 44 Is Ok ! Set 45 Is Ok ! Set 46 Is Ok ! Set 47 Is Ok ! >Or it can be sent one by one. This is useful if not all channels are being configured and just certain channels need to be set to the default values:
Figure 1-50. Set Default Values Individually 
- Energize the board, applying the established configuration (in the WECO software, this is done through the JOG command), and wait for the meter tester to stabilize the voltage and current sources.
- On Terminal, enter the following
commands: PAR[U], PAR[I], PAR[A], DCR, DSR and DAR. Then, copy and paste the results
to the blue cells:
Figure 1-51. Read the Measured Parameters from the Board (Commands PAR) 
Figure 1-52. Read DSP_CONTROL Registers (Command DCR) 
Figure 1-53. Read DSP_STATUS Register (Command DSR) 
Figure 1-54. Read DSP_ACC Register (Command DAR) 
- The spreadsheet calculates the
calibration constants (the CAL_x registers) and generates the commands to be sent to
the board through the serial console. The user can choose between:
- Sending the calibration
constants as groups using the DCM command; able to send multiple commands at
the same time. To do that, copy the green and purple cells to the metrology
console.
Figure 1-55. Set Calibration Constants as Groups 
>DCM(34:0FCF598F; 35:2114B35A; 36:0FD3B6B1; 37:21131224) Set 34 Is Ok ! Set 35 Is Ok ! Set 36 Is Ok ! Set 37 Is Ok ! >DCM(41:FFF9AAD4; 42:0; 43:FFE72DEF; 44:28A7B0) Set 41 Is Ok ! Set 42 Is Ok ! Set 43 Is Ok ! Set 44 Is Ok ! > - Sending the calibration
constants one by one by using the DCW command. To do that, copy the green
and purple cells to the metrology console.
Figure 1-56. Set Calibration Constants Individually 
- Sending the calibration
constants as groups using the DCM command; able to send multiple commands at
the same time. To do that, copy the green and purple cells to the metrology
console.
- Read the control registers (command
DCR) to check that the calibration registers were successfully updated (values in
bold):
>DCR 00 STATE_CTRL 01 FEATURE_CTRL 02 HARMONIC_CTRL 03 METER_TYPE 2 700 0 CCC 04 M 05 N_MAX 06 PULSE0_CTRL 07 PULSE1_CTRL 0 1130 810601D0 810201D0 08 PULSE2_CTRL 09 P_K_t 10 Q_K_t 11 I_K_t 110401D0 500000 500000 500000 12 S_K_t 13 CREEP_THR_P 14 CREEP_THR_Q 15 CREEP_THR_I 500000 2E9A 2E9A 212D 16 CREEP_THR_S 17 PWR_OFFS_CTRL 18 PWR_OFFS_P 19 PWR_OFFS_Q 2E9A 0 0 0 20 PWR_OFFS_S 21 SWELL_THR_VA 22 SWELL_THR_VB 23 SWELL_THR_VC 0 5EAB918 5EAB918 5EAB918 24 SAG_THR_VA 25 SAG_THR_VB 26 SAG_THR_VC 27 K_IA 1A2EC26 1A2EC26 1A2EC26 4D291 28 K_VA 29 K_IB 30 K_VB 31 K_IC 19CC00 4D291 19CC00 4D291 32 K_VC 33 K_IN 34 CAL_M_IA 35 CAL_M_VA 19CC00 4D291 FCF598F 2114B35A 36 CAL_M_IB 37 CAL_M_VB 38 CAL_M_IC 39 CAL_M_VC FD3B6B1 21131224 20000000 20000000 40 CAL_M_IN 41 CAL_PH_IA 42 CAL_PH_VA 43 CAL_PH_IB 20000000 FFF9AAD4 0 FFE72DEF 44 CAL_PH_VB 45 CAL_PH_IC 46 CAL_PH_VC 47 CAL_PH_IN 28A7B0 0 0 0 48 CPTR_CTRL 49 CPTR_BUFF_SIZE 50 CPTR_ADDR 51 Reserved1 3F00 0 0 0 52 Reserved2 53 Reserved3 54 ATS_CTRL_20_23 55 ATS_CTRL_24_27 0 0 1010103 7010101 56 ATS_CTRL_28_2B 57 Reserved4 58 PWR_OFFS_P_A 59 PWR_OFFS_P_B 3 0 0 0 60 PWR_OFFS_P_C 61 PWR_OFFS_Q_A 62 PWR_OFFS_Q_B 63 PWR_OFFS_Q_C 0 0 0 0 > - Wait for about 2 seconds to let the DSP data to be stabilized.
- On Terminal, enter PAR commands to read the measurements and check that the obtained values are accurate.
- Repeat steps 8 through 12 to recalibrate the meter again if the accuracy does not meet the specification requirement.
- When accuracy meets the requirement,
save the calibration constants into non-volatile memory by using the terminal
command DCS.
Figure 1-57. Correct Results after Calibration
>DCS Save Data Is Ok ! >
Note: The command DCD allows the default calibration and configuration
settings from the firmware (constant values stored in the application code) to be
loaded. Otherwise, the system will always be booting up with the calibration values
stored in non-volatile memory.
