Jump to main content

# 1.1.3 Metrology Driver Configurations

Metrology Specific User Configurations

The Metrology driver library is configured through MCC. Following is the MCC configuration window for metrology driver and a brief description of available options.

Figure 1-5.Metrology Driver Main Configuration Options

- Register Base Address:
  - Specifies the Start Address for the Metrology related Registers
- System Frequency:
  - Mains frequency in which the system is going to operate
  - Possible values are 50 or 60 Hz
- AFE Selection:
  - Selects the type and number of AFEs connected to PIC32CXMTx device
  - For PIC32CXMTSH device, where AFE is stacked along with the processor, this configuration option is read-only, and set to the stacked AFE value, ATSENSE203
    Figure 1-6.AFE Selection Read-Only on PIC32CXMTSH Device
  - On the other hand, PIC32CXMTC device uses an external AFE, and therefore, different options can be selected from the drop-down menu
    Figure 1-7.AFE Selection on PIC32CXMTC Device
  - ATSENSE301 is the default selection, as this is the AFE mounted in the PIC32CXMTC-DB. This selection provides 3 voltage channels and 4 current channels.
  - But other AFE combinations are supported, depending on user needs:
    - 3xMCP3910, providing 3 voltage channels and 3 current channels
    - 4xMCP3910, providing 4 voltage channels and 4 current channels
    - 1xMCP3912, providing 2 voltage channels and 2 current channels
    - 1xMCP3913, providing 3 voltage channels and 3 current channels
    - 1xMCP3914, providing 4 voltage channels and 4 current channels
- Physical Channels
  - An independent configuration is available for every Physical Channel. The number of channels is defined by AFE selection as seen above:
    Figure 1-8.Physical Channels
  - Each physical channel can be configured to match a specific logical channel (note that the default configuration matches the HW mounted on PIC32CXMTC-DB board). Available logical channels are: I_A, V_A, I_B, V_B, I_C, V_C and I_N. This is, the Voltages and Currents for phases A, B and C, and the Neutral Current:
    Figure 1-9.Logical Channels List
  - There are 2 additional configuration values, useful in case a different AFE configuration (using MCP AFEs) is selected. These options are:
    - V_D: a Voltage channel left to the user to configure, with a particular configuration capability, which is to work with VDC instead of VAC. This configuration is made through Metrology Registers, more details can be found on the Metrology User Guide.
    - The “not Used” value, which can be selected in case a Physical Channel is not connected to any Logical Channel, or simply there is no intention to measure it
    Figure 1-10.Additional Logical Channel Selection
  - Depending on the Logical channel, whether it is a voltage or a current channel, Sensor Type can be selected
  - Current Channels can use Current Transformer (CT), Resistive Shunt, or Rogowski Coil Current Sensor as Sensor Types:
    Figure 1-11.Current Sensor Types
  - Voltage Channels can only use Resistive Divider Voltage Sensor Type:
    Figure 1-12.Voltage Sensor Types
  - Each Sensor Type offers additional configuration parameters to define the physical parameters of sensor:
    Figure 1-13.Resistive Divider Configuration Options
    Figure 1-14.Current Transformer Configuration Options
    Figure 1-15.Resistive Shunt Configuration Options
    Figure 1-16.Rogowski Coil Configuration Options
  - Each Physical Channel has its own configurable Channel Gain which has to be set according to the reduction of measurement quantity reaching the AFE due to electronic components surrounding the Sensor. Configurable Gain values depend on Logical Channel Type and AFE Selection due to different physical capabilities.
    Figure 1-17.Channel Gain
  - Voltage channels provide an Advanced Configuration section, to enable over- and under-voltage events to be captured by the metrology driver:
    Figure 1-18.Voltage Channel Advanced Configuration
    - Swell Threshold: Voltage values over this limit will generate a Swell Event
    - Sag Threshold: Voltage values under this limit will generate a Sag Event
    - Interrupt Threshold: Voltage values under this limit will generate an Interrupt Event
- CREEP Thresholds
  - Metrology Driver has the ability to detect Start-Up and/or No Load situations on Current and Power magnitudes, by defining a series of thresholds
  - Total and Per Phase thresholds can be defined for Active Power, Reactive Power and Current. A unique Total threshold is available for Apparent Power
    Figure 1-19.Creep Thresholds Configuration
  - When measured quantities during a full mains cycle are below the limits provided in these thresholds, energy will not be accumulated, to prevent considering residual values of power and current
- Pulses Configuration
  - PIC32CXMTx-DB boards provide LEDs for Metrology pulses generation, traditionally used to signal Power and Current magnitudes, so an external Pulse Reader is able to compute Energy consumption from pulse rate
  - 3 different Pulses can be configured in Metrology Driver. Each Pulse can be:
    - Enabled/Disabled
    - Polarity chosen (low/high)
    - Magnitude and measurement Type selected (Current, Active, Reactive and Apparent Power, both total and Fundamental only) (Net, Absolute, Delivered, Generated)
    - Pulse width configured
    - Meter Constant (pulses per magnitude unit) defined
    Figure 1-20.Pulse Output Enable/Disable
    Figure 1-21.Pulse Magnitude Measure Method
    Figure 1-22.Pulse Polarity
    Figure 1-23.Pulse Magnitude Type
    Figure 1-24.Pulse Width and Meter Constant
- Additional Notifications
  - Metrology Driver provides the ability to enable additional notifications, apart from Integration Period which is always active. These notifications are invoked from Driver by calling the functions provided in DRV_METROLOGY_xxxCallbackRegister functions available in Driver API (see Library Interface section for more details). Depending on the notification, it is triggered from an interrupt context, or from main execution context, take this into account when adding code in the callback functions invoked.
    - Integration Period and Full Cycle notifications are invoked from main execution context, so user code can be safely added to handle integration measurements and per-cycle measurements, without blocking other raising interrupts
    - Half Cycle, Raw Zero Cross and Pulse notifications are invoked from interrupt context to achieve timing accuracy. Be very careful when adding user code inside these notification callbacks, as it will block main execution flow and other lower priority interrupts.
  Figure 1-25.Metrology Driver Additional IPC Notifications
  - By default in provided projects, Full and Half Line Cycle interrupts are enabled, and used in the example applications for different purposes
  - Full Line Cycle:
    - Enable Line Cycle interrupt
    - This interrupt is generated every full line cycle. Upon interrupt generation, the frequency and accumulated energy associated with pulse have been updated. Unlike the Raw Zero Cross interrupt, the Full Cycle interrupt uses the 4 kHz narrow-band filtered voltage channels and exhibit a deterministic but frequency-dependent phase delay.
  - Half Line Cycle:
    - Enable Half Line Cycle interrupt
    - This interrupt is generated every half line cycle. Upon interrupt generation, swell and sag flags have been updated. Unlike the Raw Zero Cross interrupt, the Half Cycle interrupt uses the 4 kHz narrow-band filtered voltage channels and exhibit a deterministic but frequency-dependent phase delay.
  - Raw Zero Crossing:
    - Enable Raw Zero Crossing interrupt
    - This interrupt is generated on zero-crossings using the unfiltered raw 16 kHz data stream of the selected direction and selected voltage channel
  - Pulse 0:
    - Enable Pulse 0 interrupt
    - This interrupt is generated immediately after Pulse 0 has computationally committed to be generated, but not necessarily occurred, and is not subject to the pulse's PC0_OVERRIDE control bit
  - Pulse 1:
    - Enable Pulse 1 interrupt
    - This interrupt is generated immediately after Pulse 1 has computationally committed to be generated, but not necessarily occurred, and is not subject to the pulse's PC1_OVERRIDE control bit
  - Pulse 2:
    - Enable Pulse 2 interrupt
    - This interrupt is generated immediately after Pulse 2 has computationally committed to be generated, but not necessarily occurred, and is not subject to the pulse's PC2_OVERRIDE control bit
- Enable Channels for Harmonic Analysis
  Figure 1-26.Enable Harmonic Analysis on Channels
  - This configuration option is used to disable harmonic analysis on different channels. By default, harmonic analysis is enabled for all channels, but user may disable this analysis on any channel if not required.
- Enable Harmonics Order in Analysis
  Figure 1-27.Enable Harmonics Order in Analysis
  - On this configuration option, user may enable the harmonics calculation for any order (up to 31st harmonic) from start-up. This is, if enabled here, the analysis is automatically triggered on Driver initialization.
  - By default, no harmonic is enabled on start-up, but the analysis is requested on demand using the Driver API. Example applications include Console Commands to trigger Harmonics Analysis and show the results on Console. See Demo Meter Application Command Console for details.
- RTOS Settings
  Figure 1-28.Metrology Driver Configuration for RTOS
  - Stack Size (in bytes):
    - Specifies the number of bytes to be allocated on the stack for the metrology driver task
  - Task Priority:
    - Specifies priority for the metrology driver task thread. The value can vary based on RTOS used.
- NVIC Settings
  - IPC1 Interrupt is enabled automatically when using the metrology driver
  - The interrupt priority value must be set according to the main application. Additional IPC notifications should be addressed as soon as possible.
    Figure 1-29.NVIC Configuration for IPC1
- Clock Settings
  - SRAM1 and IPC1 clocks are enabled automatically when using the metrology driver
    Figure 1-30.Peripheral Clock Configuration for Metrology Driver

Rev: E