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

Preparing the Application Code to Run

  1. Launch the IAR5.5 Embedded Workbench IDE, then click on File → Open → Workspace.
  2. Select “emeters.eww” when prompted for Workspace to be opened.
    GUID-711646EF-C78C-48E7-A9CE-8BCE495D4325-low.gifFigure 9-1 Opening Workspace
  3. Select the emeter-app-i2041 project tab at the bottom of the Workspace window.
  4. Check the project options by right clicking on the project name and selecting Options… from the pop-up menu as shown in Figure 9-2.
    GUID-4134801B-4A0A-47BB-995E-D6067E044A39-low.gifFigure 9-2 Project Tab
  5. When the options appears, select C/C++ compiler on the left hand column and then select the Optimizations tab on the right hand side and check that the optimization setting is as shown in Figure 9-3).
    GUID-410124B2-F9E1-4573-84AF-22B8DDF6F6B8-low.gifFigure 9-3 Optimization Options
  6. Select FET Debugger on the left hand column of the select Setup tab. The EVM uses Spy-Bi-Wire for its code downloading and debugging. Check to make sure the options are as shown in Figure 9-4.
    GUID-06EE47F3-403D-4872-B819-743F262BEA0E-low.gifFigure 9-4 Debugger Options
  7. Select the Download tab. Under Flash erase, do not choose Erase main memory and Information memory; this option erases both sets of data and cannot be recovered. Instead, choose Erase main memory as the download option to preserve these factory parameters: system clock calibration, ADC calibration, and internal reference calibration (Figure 9-5). However, metrology calibration stored in the main memory, such as VGAIN, IGAIN, PGAIN, and so on, are always erased after downloading. Select Erase main memory as the option for download to preserve the factory parameters.
    GUID-179EB650-D035-4132-A16F-CBBEF472F116-low.gifFigure 9-5 Download Options
  8. Click OK after all of the changes are made.
  9. Rebuild the project by right clicking on the project and selecting Rebuild All from the pop-up menu (see Figure 9-6). Three warnings are reported during rebuilding (see Figure 9-6), it is safe to ignore the three warnings. To open the project workspace, modify the code, compile, and download the code; IAR Embedded Workbench® 5.5 must be installed with a valid license. If a valid license is not available, the object code can still be downloaded. For downloading procedures, see Section 9.3.
    GUID-58115C1A-C623-4E59-9799-F00F9B8D7418-low.gifFigure 9-6 Compiling the Application
    GUID-9090B7A0-C030-4CB5-804E-25BE3DE84025-low.gifFigure 9-7 Warnings
  10. Make sure the jumper on J8 is short properly. Connect the 14 pin connector P1 to MSP-FET430UIF by a flat cable as shown in Figure 9-8.
    WARNING:

    The debugging interface is NOT ISOLATED; make sure proper isolation is in place between the EVM and the PC using for debugging with AC or DC high voltage connected.

    Connection to debugging interface is optional for the operation of the EVM. The EVM can operate standalone without debugger connected.

    GUID-6B7DC1F3-F6D6-4D81-9914-5EB07510E1B7-low.gifFigure 9-8 Connecting EVM and FET
  11. Click the Download and Debug button to begin download and debugging as shown in Figure 9-9.
    GUID-5162FFE1-85EE-4D5B-BA9A-24943ACBAC99-low.gifFigure 9-9 Code Downloading
  12. After downloading is completed and successful, a screen like that shown in Figure 9-10 will appear. Click Go to start application running.
    GUID-9F9EE0EA-89F0-444A-87B5-E6D90F2FED99-low.gifFigure 9-10 Debugger Screen
    GUID-7F89B40F-B241-4ED5-A2BE-5D92CCEAB424-low.pngFigure 9-11 EVM running