Design Electricity Meters with Kinetis M Series Mcus FTF-SEG-F0469
Total Page:16
File Type:pdf, Size:1020Kb
Design Electricity Meters with Kinetis M Series MCUs FTF-SEG-F0469 Felix Wang | Senior Global Product Manager Martin Mienkina | Senior Member of Technical Staff M A Y . 2 0 1 4 TM External Use Session Objectives • Understand electricity meter block diagram and major functionalities • Familiarize with Kinetis M series MCUs • Become familiar with Freescale electricity meter reference designs, HW/SW development tools and algorithms offering • Mastering MCU programming… Tutorial • Ideal Hilbert Transformer Kinetis M series products are designed for next-generation smart meter applications. The cost-effective Kinetis M series MCUs combine a sophisticated analog front end (AFE), hardware tamper detection and low-power operation to enable the design of secure, high-accuracy 1-, 2- and 3-phase electricity metering solutions. Freescale also provides proven 1-, 2-, and 3-phase hardware reference designs with complex metrology firmware satisfying 0.1% measurement accuracy and all ESD requirements. Traditional smart metering designs typically employ two chips to separate user billing software from the main application code, as required by WELMEC, OIML and other global standards. However, Kinetis M series MCUs handle this task with a single chip due to their on-chip memory protection unit, peripheral bridge, protected GPIO and DMA controller. To guard against external tampering, M series MCUs include active and passive tamper pins with automatic time stamping throughout, including on the independent real-time clock (iRTC). In addition, a random number generator enables faster, easier implementation of encryption algorithms than software implementations… Product launch, European Utility Week, Amsterdam – Oct. 15, 2013 TM External Use 1 Agenda • Introduction to Electricity Metering • Kinetis M Series MCUs • Electricity Metering Algorithms • Electricity Meter Reference Designs • Kinetis M Development Tools • Mastering MCU Programming… • References TM External Use 2 Electricity Meter Block Diagram MEASURE PROCESS DISPLAY • Measure − Electricity meters must measure phase voltages and phase currents consumed by connected load − Measurement linearity of 0.1% over 2000:1 dynamic range. − Shunt resistors, current transformers or Rogowski coils can be connected. • Process − Accurate calculation of the active and reactive energies − Time keeping with accuracy better than 0.5s/day needed for billing purposes − Tamper processing ensures security − Load profiles and parameters storage • Display − LCD display allows visual inspection − HMI (control button) allows system configuration − IR / RF communication allows download of data for utility companies and automatic meter reading TM External Use 3 Agenda • Introduction to electricity metering • Kinetis M series MCUs • Electricity metering algorithms • Electricity meter reference designs • Kinetis M development tools • Mastering MCU programming… • References TM External Use 4 Core Timer/PWM/Clock GPIO • CM0+ core Up to 50MHz • Quad Timer (total 4 universal timers) • Up to 68 with push pull, pull up/down select • Separate FLL post-scalers for Flash and Core • 2x PIT • Up to 8 GPIO with filter clocks. • 1x Watchdog Timer (windowed, independently • Support for interruption on any edge • Single cycle access for all GPIOs (Rapid GPIO) • Dedicated PLL for ΣΔ modulator clock clocked) • 4ch DMA • 1x EWM (External Watchdog Monitor) Power Modes & Clock • Memory Protection Unit • 1x LPTimer • Many low power modes supported • Single 32kHz Crystal operation LCD Display • 2.7V to 3.6V Operating voltage with AFE • 1.71V to 3.6V Operating voltage without AFE • MHz Crystal optional • Up to 288 segment LCD, up to 8 backplanes • 1.71V-3.6V IRTC VBAT supply Security & Encryption Wakeup Unit • 32kHz or 4 MHz internal clock source • • Programmable 16/32-bit CRC • Group selected GPIOs (16), LPTIM, RTC 32.768kHz crystal oscillator • IRTC w/ tamper detection (+tamper pins) , HSCMP, SCI , Brownout and Package • 3 Tamper pins (operating on battery) POR sources to wake up from Power Gated • 100 LQFP, 64 LQFP and 44 LGA options • Random Number Generator (NIST: SP800-90) STOP mode • -40°C ~ +85°C Temp • AES Encryption (via software library) • Memories +/-250mV analogue I/O • Up to 128 KB Program Flash pads with 6kV PESD • 16 KB SRAM Analog • 4x24 bit ΣΔ after averaging (2xPGA) highly accurate supporting EN 50470-1, EN 50470-3, IEC 62053-21, IEC 62053-22 and IEC 62053-23, optimized for shunt sensor (≥50uOhm). • 0.1% error in active and reactive energy over a dynamic range of 2000 to 1 • Internal 1.2V reference voltage (33 ppm/oC) • 12-ch 16-bit SAR for auxiliary measurement • 2x analog comparator Serial Communications • 2x SPI • 4x UART • All combined with Quad Timer & HSCMP for IR • 2 support ISO7816 Kinetis M series MCUs Pager M series One Kinetis • All support flow control • 2× I2C • All UARTs and SPIs are 3V compatible while 1 UART and 1 SPI are both 3V and 5V compatible (open drain configuration) Peripheral XBAR x3 • Remapping peripheral IOs • UART selection for IR TM IPs with functionality External Use 5 specific to metering Analogue Subsystem (Overview) 1.2V Voltage Reference • Generates accurate High-Speed Comparator reference voltage shared • Two comparators, each with between PGA, SD ADC, • 6-bit DAC to provide selectable SAR ADC and HSCMP Kinetis M voltage reference • Accepts a +/-250mV input signal VREF 1.2V VREF range 16-bit SAR ADC • Conversion speed up to ADC11 2x HSCMP 818 ksps …….. Inter-peripheral Crossbar Switch 16-bit SAR • 12 single ended channels ADC2 MUX • Allows programmable digital ADC • 4 result registers ADC1 interconnections between ADC0 • variety of triggering options }{XBAR specific modules • 33 input x 33 output multiplexer SD0 PGA+SD Phase shifter & Decimator • Interrupt or DMA request 24-bit SD ADC and PGA SD1 PGA+SD Phase shifter & • Conversion speed up to Decimator 101 ksps on four channels SD Phase shifter & Phase Shifter and Decimator SD2 Decimator • Four SD ADC channels • Phase shift compensation with (two PGA) SD3 SD Phase shifter & o Decimator resolution of 0.003 @ 50 Hz • SW and HW triggering line frequency • Capability to connect external Kinetis M analogue and digital blocks allow galvanic ally isolated SD realization most of electricity meter use-cases. modulators TM External Use 6 Analogue Subsystem (Electricity Meter Use-Cases) • 1-Phase • 1-Phase Kinetis M with neutral Kinetis M current VREF 1.2V VREF measurement VREF 1.2V VREF ADC11 2x HSCMP ADC11 2x HSCMP …….. …….. 16-bit SAR 16-bit SAR ADC2 MUX ADC2 MUX ADC 110/220V ADC ADC1 L_OUT ADC1 110/220V L_OUT ADC0 ADC0 }{XBAR }{XBAR SR SR I Sense SD0 PGA+SD Phase shifter & L_INP Phase shifter & Decimator I Sense SD0 PGA+SD L_INP Decimator SD1 PGA+SD Phase shifter & SD1 PGA+SD Phase shifter & Decimator Decimator Voltage Phase shifter & Phase shifter & Voltage V Sense SD2 SD divider V Sense SD Decimator SD2 Decimator divider N_INP SD3 SD Phase shifter & SD3 SD Phase shifter & N_INP Decimator NSense Decimator N_OUT • All measurements performed by SD ADC CT/RC • Shunt resistor measurements amplified by Programmable Gain Amplifier (PGA) • Phase shift between phase voltage and phase current measurements compensated by Phase Shifter block. TM External Use 7 Analogue Subsystem (Electricity Meter Use-Cases – Cont’d) • 3-Phase with neutral • Form-12S current measurement Kinetis M 110/220V Kinetis M L1 L2 L3 N VREF 1.2V VREF 1.2V VREF VREF ADC11 2x HSCMP ADC11 2x HSCMP …….. V3 Sense …….. N 16-bit SAR Voltage 16-bit SAR L1 L2 ADC2 MUX dividers ADC2 MUX 110V ADC V2 Sense ADC ADC1 ADC1 CT/RC ADC0 V1 Sense ADC0 }{XBAR }{XBAR CT/RC Phase shifter & Phase shifter & I1 Sense SD0 PGA+SD IN Sense SD0 PGA+SD Decimator Decimator CT/RC Phase shifter & Phase shifter & I2 Sense SD1 PGA+SD I3 Sense SD1 PGA+SD Decimator Decimator Phase shifter & Phase shifter & V1 Sense SD2 SD I2 Sense SD Decimator SD2 Decimator Voltage Phase shifter & dividers SD3 SD I1 Sense SD Phase shifter & V2 Sense Decimator SD3 Decimator • All measurements performed by SD ADC • Phase and neutral current measurement performed by SD • Rogowski coil measurement optionally amplified by ADC Programmable Gain Amplifier (PGA) • Phase voltage measurement performed by 16-bit SAR ADC • Phase shift between phase voltage and phase current • Phase shift between phase voltage and phase current measurements compensated by Phase Shifter block. measurements compensated either numerically a FIR filter or by hardware using Quad Timer channels. TM External Use 8 Analogue Subsystem (SD ADC and PGA) • Blocks • Features − Four channels with 24-bit SD ADC (two PGAs) − Supports single and continuous conversions − Phase Shifter & Decimator − Support both software and hardware triggering − CPU/DMA Interface − Output sampling rates: 3 kHz, 6 kHz, 12 kHz, AFE_CLK 24 kHz, 48 kHz, and 96 kHz + SD Phase Decimation − Gain programmable from 1x to 32x PGA 32-bit Result Register Modulator Compensator Filter - − Dynamic phase shift compensation Single channel − Synchronized start operation PGA_EN SD_EN EXT_MOD PH_EN EXT_MOD _EN − Option to generate interrupt or DMA request _DATA Register bits on conversion complete • Electrical parameters • SD ADC measurement range − Full operating voltage range: 2.7V to 3.6V − ±250 mV (1 VP-P differential, 0.5 VP-P single ended) input range for both single ended and differential inputs − Common mode voltage range of 0 to 0.8V − SD modulator Signal-to-Noise Ratio: • Normal mode: 92dB @ (Fs=6.144MHz, OSR=2048) • Low power mode: 82dB @ (Fs=0.768MHz, OSR=256) Operation PGA Signal range SNR Current Mode (mV peak-peak) (dB @ OSR=2048) (mA) Normal ON 31 (gainx32) 64 (74) 4.0 Low Power ON 31 (gainx32) 52 (62) 3.1 VLPR VLPW STOP VLPS VLLSx Normal OFF 1000 92 1.4 TM FF FF OFF Low Power OFF 1000External Use 9 82 0.5 (PLL disabled) Analogue Subsystem (16-bit SAR ADC) ADHWTSA ADCSC1A Conversion ADHWTSn Trigger • Blocks Control ADTRG ADCSC1n ADHWT − Single 16-bit SAR ADC Compare true 1 Control Registers (ADCSC2, ADCCFG1, ADCCFG2) − Four result registers allows measurement up to four samples ADACKEN without interrupt service AIENn ADCHn ADLPC Asynch.