SLAA638A august   2014  – may 2023 MSP430I2040 , MSP430I2041

 

  1.   1
  2.   Single Phase and DC Embedded Metering (Power Monitor) Using MSP430I2040
  3.   Trademarks
  4. Introduction
    1. 1.1 Safety and Precautions
    2. 1.2 Features
  5. Design Details
    1. 2.1 Block Diagram
    2. 2.2 Hardware Design
      1. 2.2.1 Interface Circuit
      2. 2.2.2 11
      3. 2.2.3 Shunt Resistor
      4. 2.2.4 Voltage Divider Circuit
      5. 2.2.5 Layout Consideration
      6. 2.2.6 Shunt Sensor Pad Design
    3. 2.3 Software Design
      1. 2.3.1 The Toolkit Package
      2. 2.3.2 Metrology Computation Engine
      3. 2.3.3 Background Process
      4. 2.3.4 Phase Correction
      5. 2.3.5 Frequency Measurement and Cycle Tracking
      6. 2.3.6 Cycle Tracking and Forground Process Triggering
      7. 2.3.7 Foreground Process
  6. Calibration Techniques
    1. 3.1 Introduction
    2. 3.2 Calibration Techniques
      1. 3.2.1 Calibration Setup
        1. 3.2.1.1 Apparatus
        2. 3.2.1.2 Setup
    3. 3.3 Calibration Procedures
      1. 3.3.1 Calibration of AC and DC Parameters
      2. 3.3.2 Calibration of Compensation Resistance and Capacitance
      3. 3.3.3 Calibration of Current AC Offset
      4. 3.3.4 Calibration of Voltage AC Offset
      5. 3.3.5 Calibration of Phase Correction
      6. 3.3.6 Calibration of DC Parameters
  7. Hardware Setup
    1. 4.1 Top View of the EVM
    2. 4.2 Bottom View of the EVM
    3. 4.3 Hardware Setup Procedures
      1. 4.3.1 Setting Up the Power Supply to EVM
      2. 4.3.2 Setting Up the Serial Communication Interface
      3. 4.3.3 Setting Up Line Input and Load Output
      4. 4.3.4 Setting Up the Debugging Interface
  8. Calibrator Software
    1. 5.1 Software Package Content
    2. 5.2 Setting Up the PC Software Tool
      1. 5.2.1 Minimum System Requirement
      2. 5.2.2 Installing the Software
      3. 5.2.3 Configuring the Software
    3. 5.3 Instruments
  9. Operating the PC Software Tool
    1. 6.1 Introduction
    2. 6.2 Start Using the EVM
    3. 6.3 Known Issues
  10. Serial Communication Commands
    1. 7.1 Introduction
    2. 7.2 Communication Protocol
      1. 7.2.1 Polling Mode
        1. 7.2.1.1 Command and Respond Frame
    3. 7.3 Commands
      1. 7.3.1  HOST_CMD_GET_METER_NAME
        1. 7.3.1.1 Command Format
      2. 7.3.2  HOST_CMD_GET_METER_VER
        1. 7.3.2.1 Command Format
      3. 7.3.3  HOST_CMD_GET_METER_CONFIGURATION
        1. 7.3.3.1 Command Format
        2. 7.3.3.2 Parameter Definition
      4. 7.3.4  HOST_CMD_GET_RTC
        1. 7.3.4.1 Command Format
      5. 7.3.5  HOST_CMD_ALIGN_WITH_CALIBRATION_FACTORS
        1. 7.3.5.1 Command Format
      6. 7.3.6  HOST_CMD_SET_PASSWORD
        1. 7.3.6.1 Command Format
      7. 7.3.7  HOST_CMD_GET_READINGS_PHASE_N
        1. 7.3.7.1 Command Format
      8. 7.3.8  HOST_CMD_GET_EXTRA_READINGS_PHASE_N
        1. 7.3.8.1 Command Format
      9. 7.3.9  HOST_CMD_SUMCHECK_MEMORY
        1. 7.3.9.1 Command Format
      10. 7.3.10 HOST_CMD_CLEAR_CALIBRATION_DATA
        1. 7.3.10.1 Command Format
      11. 7.3.11 HOST_CMD_SET_CALIBRATION_PHASE_N
        1. 7.3.11.1 Command Format
      12. 7.3.12 HOST_CMD_GET_CALIBRATION_PHASE_N
        1. 7.3.12.1 Command Format
      13. 7.3.13 HOST_CMD_SET_CALIBRATION_EXTRAS
        1. 7.3.13.1 Command Format
      14. 7.3.14 HOST_CMD_GET_CALIBRATION_EXTRAS
        1. 7.3.14.1 Command Format
  11. Firmware and Embedded Metering Library API
    1. 8.1 Introduction
    2. 8.2 Embedded Metering LIbrary API
      1. 8.2.1 Embedded Metering Library Function Calls
        1. 8.2.1.1 Functions for Metrology Engine Control
          1. 8.2.1.1.1 Functions for Metrology Engine Control
          2.        int metrology_init (void)
          3.        int metrology_init_from_nv_data (void)
          4.        void align_metrology_with_calibration_data (void)
          5.        void metrology_switch_to_normal_mode (void)
          6.        void metrology_init_analog_front_end_normal_mode (void)
          7.        void metrology_disable_analog_front_end (void)
        2. 8.2.1.2 Procedure for Metrology Engine Initialization
        3. 8.2.1.3 Functions for Calculate and Reading the Readings
          1. 8.2.1.3.1 Functions for Calculate and Reading the Readings
          2.        power_t calculate_phase_readings (void
          3.        power_t active_power (int ph)
          4.        power_t reactive_power (int ph)
          5.        power_t apparent_power (int ph)
          6.        power_t fundamental_active_power(int ph)
          7.        power_t fundamental_reactive_power(int ph)
          8.        power_factor_t power_factor (int ph)
          9.        rms_voltage_t rms_voltage (int ph)
          10.        rms_voltage_t fundamental_rms_voltage(int ph)
          11.        thd_t voltage_thd(int ph)
          12.        rms_current_t rms_current (int ph)
          13.        rms_current_t fundamental_rms_current(int ph)
          14.        thd_t current_thd(int ph)
          15.        int16_t mains_frequency (int ph)
          16.        uint16_t phase_status (int ph)
      2. 8.2.2 Embedded Metering LIbrary Callbacks
      3. 8.2.3 Application Level Calibration Functions
        1. 8.2.3.1 Functions for Reading and Writing Calibration Parameters
          1. 8.2.3.1.1 Functions for Reading and Writing Calibration Parameters
          2.        int get_calibration_status (void)
          3.        void set_calibration_status (int value)
          4.        int clear_calibration_data (void)
          5.        int16_t get_temperature_intercept (void)
          6.        int16_t get_temperature_slope (void)
          7.        void set_temperature_parameters (int16_t temperature_at_calibration, int16_t temperature_sensor_intercept, int16_t temperature_sensor_slope)
          8.        calibration_scaling_factor_t get_P_scaling (int phx)
          9.        void set_P_scaling (int phx, calibration_scaling_factor_t value)
          10.        calibration_scaling_factor_t get_V_rms_scaling (int phx)
          11.        void set_V_rms_scaling (int phx, calibration_scaling_factor_t value)
          12.        int16_t get_v_dc_estimate (int phx)
          13.        int16_t get_initial_v_dc_estimate (int phx)
          14.        void set_v_dc_estimate (int phx, int16_t value)
          15.        int32_t get_v_ac_offset (int phx)
          16.        void set_v_ac_offset (int phx, int32_t value)
          17.        calibration_scaling_factor_t get_I_rms_scaling(int phx);
          18.        void set_I_rms_scaling(int phx, calibration_scaling_factor_t value);
          19.        int32_t get_i_dc_estimate(int phx);
          20.        int32_t get_initial_i_dc_estimate(int phx)
          21.        void set_i_dc_estimate(int phx, int32_t value);
          22.        int32_t get_i_ac_estimate(int phx);
          23.        void set_i_ac_offset (int phx, int32_t value)
          24.        uint16_t get_compensate_capacitor_value (int phx)
          25.        void set_compensate_capacitor_value (int phx, uint16_t value)
          26.        uint16_t get_compensate_resistance (int phx)
          27.        void set_compensate_resistance (int phx, uint16_t value)
          28.        int16_t get_phase_corr (int phx)
          29.        void set_phase_corr (int phx, int16_t value)
      4. 8.2.4 Setting Default Calibration Parameters
  12. Example Application Code
    1. 9.1 Introduction
    2. 9.2 Preparing the Application Code to Run
    3. 9.3 Downloading Without an IAR License
  13. 10Hardware Design Files
    1. 10.1 PACKAGE
    2. 10.2 Schematic
  14. 11EVM Specification and Performance
    1. 11.1 EVM Specifiction
  15. 12Running on MSP430i2040 and MSP430i2041
    1. 12.1 164
  16. 13Revision History

Start Using the EVM

When the EVM has been powered, some of the seven LEDs will be flashing or turned on to indicate its operation status. Some of the LEDs are not used; make changes to the provided source code to make use of all the LEDs, as necessary. The list of LEDs’ indication is listed in Table 6-1.

Table 6-1 LEDs’ Indication Status
LEDStateIndication
LED1ONBackground Operations Running
LED1OFFBackground Operations Completed
LED2ONVoltage Negative Half Cycle
LED2OFFVoltage Positive Half Cycle
LED3ONNot used
LED3OFFNot used
LED4ONForeground Operations Running
LED4OFFForeground Operations Completed
LED5ONEVM is in AC mode measurement
LED5OFFEVM is not in AC mode measurement
LED6ONEVM is in DC mode measurement
LED6OFFEVM is not in DC mode measurement
LED7ONActive Energy Pulse Pulsing
LED7OFFActive Energy Pulse Idle

The EVM is now ready to run, launch the software “calibrator-20121120.exe” in the folder “calibration-runtime” to start communicating with the EVM. A window as shown in Figure 6-1 appears. As defined in the XML file “calibration-config.xml”, meter position 1 is assigned the serial port to communicate with the EVM, the [Comms] indicator turns green if communication to the EVM from the PC is established and it flashes between read and green when the communication is taking place.

GUID-F6AD4313-1D95-479E-BF32-A7EE6DCD4500-low.gifFigure 6-1 Calibrator Software Startup Window

Click on the [Comms] indicator in the Meter Status window as shown in Figure 6-2.

GUID-9E7C7A43-6EDD-45CA-B8B5-2DB80BCBA34D-low.gifFigure 6-2 Meter Status Window

This window shows the current reading of the meter. The background of a reading box is gray if the EVM does not support that particular reading. It turns red if the reading from EVM to that box has a large variance. It turns yellow if the reading from EVM has a fairly low variance. It turns green if the reading has a low variance. Note that the software on the PC reads the EVM every second and it also does some averaging to the data read, thus, the update rate is slower than the update rate of the EVM.

At the bottom of this window, there are four buttons:

  1. Click on the Meter Consumption button, which brings up the Meter Consumption window, but the EVM does not support this feature. The Meter Consumption window provides no useful information.
  2. Click on the Meter Calibration Factors button, which brings up the Meter Calibration Factors window (see Figure 6-3). The current calibration factor values are shown in this window.
    GUID-56384911-287E-4779-A014-92F0905E7015-low.gifFigure 6-3 Meter Calibration Factor Window
  3. Click on the Meter Features buttons, which brings up the Meter Features window (see Figure 6-4). In this window, the support feature of the EVM is reported in the Meters Feature window. Figure 6-4 only shows the look and feel of the meter feature window, but this is not the exact feature of the EVM.
    GUID-DD81BDF3-678A-4F19-A0EA-45D47E1F10D8-low.gifFigure 6-4 Meter Features Window
  4. Click on the Manual Call button, which brings up the Meter Error window (see Figure 6-5). In this window, the adjustment to the calibration factor values could be done by entering the percentage error of the reading from the EVM compare to the reading from the reference meter. For more details on the technique and procedure of performing calibration, see Section 3.
    GUID-84B9F1D4-A3CC-464A-8391-8F26E9BB9E18-low.gifFigure 6-5 Meter Error Window

To modify the calibration factor requires the correction to be entered in the percentage error. The percentage error is calculated as shown in Equation 23:

Equation 23. GUID-33B00CBE-16CB-4F78-845B-C4F79B18E61C-low.gif

Put the percentage error in the corresponding box in the Meter Error Window (see Figure 6-5). Click Update meter and the updated calibration values will be calculated and written to the EVM. The corresponding values will be reflected in the Meter Calibration Factor Window.