30
© 2015 itemis France. All rights reserved. Embedded Software Engineering Reloaded - mbeddr Experience report about the development of a smart meter ESE Kongress 2015 Dr. Stephan Eberle, Bernd Kolb, Dr. Markus Völter

Embedded Software Engineering Reloaded - mbeddr ·  · 2016-12-09Experience report about the development of a smart meter ... Co-project lead of mbeddr ... mbeddr Unit Test for Bin/BCD

  • Upload
    vanbao

  • View
    215

  • Download
    2

Embed Size (px)

Citation preview

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

© 2015 itemis France. All rights reserved.

Embedded Software Engineering Reloaded - mbeddr

Experience report about the development of a smart meter

ESE Kongress 2015 Dr. Stephan Eberle, Bernd Kolb, Dr. Markus Völter

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

© 2015 itemis France. All rights reserved.

○ Dr. Stephan Eberle

R&D Director at itemis France in Paris

Electrical engineering and computer science background

Embedded software design, model-driven tools for automotive

Mainly mbeddr user

○ Bernd Kolb

Architecture & Technology Manager at itemis Stuttgart

Tool development, model-driven development, language engineering

Co-project lead of mbeddr

○ Dr. Markus Völter

Consultant and coach at itemis Stuttgart

Architecture, model-driven development, language engineering, product lines

Initiator and co-project lead of mbeddr

About

2

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

© 2015 itemis France. All rights reserved.

► The use case: a 3-phase smart meter

○ mbeddr: a highly enriched and extensible version of C

○ Advanced smart meter software design

○ Efficiency evaluation

○ Conclusions

Outline

3

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

© 2015 itemis France. All rights reserved.

○ Metrology

Sensing of instantaneous voltage and current

(sample rate 4096 samples/s)

Real-time computation of RMS voltage/current,

active/reactive power and energy, apparent power,

power factor, and mains frequency

3 phases

○ Smart metering

Multi-tariff and time-of-use service support

Load profiles, historical data recording

Anti-tampering, anti-fraud

○ Display

○ Communication

DLMS/COESM for automatic meter reading (AMR) by utility provider

Calibration for end-of-line accuracy adjustment during production

Smart Meter Functions

4

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

© 2015 itemis France. All rights reserved.

○ µC platform

Texas Instruments MSP430

Up to 25MHz, 128 KB ROM (internal

flash), 8 KB RAM (internal)

○ Dual-core design

Metrology node for metrology functions

Application node for smart metering,

display and communication functions

○ Display

Custom seven segment display with 3

lines and different physical units and icons

○ Communication interfaces

RS485 (external)

IrDA (external)

UART (between both processor nodes)

Smart Meter Hardware

5

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

© 2015 itemis France. All rights reserved.

Existing Smart Meter Sample Software

6

Huge amount of fine-grained responsibilities

and interactions

No visible higher level structure

No unit/integration tests

A nightmare to maintain and evolve

Close to impossible to reuse

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

© 2015 itemis France. All rights reserved.

○ Mastering complexity through well structured, modular architecture

○ Hardware-independent testing

○ Incremental integration and commissioning

○ Reuse through platform-based development

Smart Meter Software Design Objectives

Key drivers for using mbeddr

7

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

© 2015 itemis France. All rights reserved.

o The use case: a 3-phase smart meter

► mbeddr: a highly enriched and extensible version of C

○ Advanced smart meter software design

○ Efficiency evaluation

○ Conclusions

Outline

8

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

© 2015 itemis France. All rights reserved.

Dead End: Trying to Find the “Right” Language

9

Efficiency

Comprehensibility

Maintainability

Testability

Reuse

Plain CHigh-level languages

(C++, Java, Python, …)

Machine-oriented,

low-level

notions

Problem-oriented,

high-level

abstractions

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

© 2015 itemis France. All rights reserved.

Way Out: Extending and Combining Multiple Languages

10

Open Source (Eclipse Public License 1.0)

http://mbeddr.com

C Programming Language (C99)

Out-of-the-boxlanguageextensions

User-defined language extensions

Ph

ysic

al

Un

its

Sta

teM

ach

ines

Co

mp

on

en

ts

Co

ncu

rren

cy

Vari

ab

ilit

y

Testi

ng

Veri

ficati

on

Req

uir

em

en

ts &

T

racin

g

Do

cu

men

tati

on

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

© 2015 itemis France. All rights reserved.

The extensible C

11

Physical Units

Components Variability

State Machines

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

© 2015 itemis France. All rights reserved.

The multi-notational C

12

Textual

Tables Mathematical

Graphical

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

© 2015 itemis France. All rights reserved.

Great IDE Support

13

Built on

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

© 2015 itemis France. All rights reserved.

o The use case: a 3-phase smart meter

o mbeddr: a highly enriched and extensible version of C

► Advanced smart meter software design

○ Efficiency evaluation

○ Conclusions

Outline

14

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

© 2015 itemis France. All rights reserved.

Smart Meter Software Architecture

15

Co

mm

HA

LA

pp

lic

ati

on M

etro

log

yU

til

hw

-sp

ec

ific

DLT645DLMS/

COSEMMQTT-

SN

Energy data

Non-Volatile data

Mains frequency measurement

Instantaneous voltage & current sampling

RMS voltage & current calculation

Power & power factor calculation

Energy pulse generation

Energy and consumption calculation

Watch-dog

Clock system

Bin/BCDconverter

LCD formatter

Low-pass filter

Ticker

USCILCD line

Temperature provider

RTCFlash

memoryTimer ADC10SD24E²PROM

PLCmodem

Energy data display

Multi-tariff & billing periods

support

Magnetic interferenceprotection

DLT645 calibration commands

Load profile support

Time of useReset function, historical data

recording

COSEM objects/OBIS

codes

Anti-tampering/anti-fraud

Last/average/maximum demand

Output relay control

do

ma

in-s

pe

cif

ic

ge

ne

ric

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

© 2015 itemis France. All rights reserved.

Excerpt: Metrology Raw Signal Acquisition

16

HA

LM

etro

log

yMetrologyRawSignalCollectorImpl

SD24ConverterGroupImpl

ISD24 (c/s) ISD42ConverterGroupHandler (c/s)

IMetrologyRawSignalData (s/r)

«requires» «provides»

«provides»

«provides» «requires»

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

© 2015 itemis France. All rights reserved.

mbeddr Interfaces and Components of Sigma-Delta ADC

17

HA

L

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

© 2015 itemis France. All rights reserved.

mbeddr Interfaces and Components of Raw Signal Collector

18

Me

trolo

gy

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

© 2015 itemis France. All rights reserved.

mbeddr Composite Component of Energy Data Display

19

Me

trolo

gy

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

© 2015 itemis France. All rights reserved.

mbeddr Physical Units for Active Power Computation

20

Me

trolo

gy

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

© 2015 itemis France. All rights reserved.

mbeddr State Machine for DLT645 Protocol Receiver

21

Util

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

© 2015 itemis France. All rights reserved.

HA

L

○ Integration of individual or multiple

components into test applications

○ Substitution of hardware-

dependent or unfinished

components with mock or stub

components

○ Implementation of test logic using

mbeddr unit test language

○ Optionally emulation of hardware

registers through mbeddr register

language

○ Execution on development PC or

build server

Hardware-Independent Testing

22

Test cases

Ap

plic

atio

n

Mock or stub component

Component(s) under test

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

© 2015 itemis France. All rights reserved.

mbeddr Unit Test for Bin/BCD Converter

23

Util

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

© 2015 itemis France. All rights reserved.

HA

L

Integration Testing of Metrology Components

24

Without mbeddr With mbeddr

Metrology tests scenarios

Metro

log

y

Metrology raw signal simulator

Metrology component(s) under test

Hardware in the Loop Software in the Loop

Fast automatic execution Tedious manual execution

Smart

Meter

Test

Equipment

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

© 2015 itemis France. All rights reserved.

Metrology Component Test Results

25

Validation of correctness AND accuracy

Parameter Range Maximum deviation

RMS Voltage 0 V … 250 V< 100 V: 10 ‰

≥ 100 V: 0,4 ‰

RMS Current 0 A … 104 A< 10 A: 1 ‰

≥ 10 A: 0,2 ‰

Active Power 230 V, 0 … 104 A 0,14 ‰

Reactive Power230 V, 0 … 104 A,

-90° … +90°2,74 ‰

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

© 2015 itemis France. All rights reserved.

Fractional Delay Filter Analysis & Optimization

26

MATLAB/Simulink-like analysis and optimization

of final embedded code

Before optimization

After optimization

Ideal curve

Interpolation of 90° phase-shifted voltage samples

samplen-0,5 samplen+0,5samplen

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

© 2015 itemis France. All rights reserved.

Incremental Integration and Commissioning

27

Very few remaining problems

Minimal debugging on target hardware

Fast localization of root causes

Progressive integration of more and more components up to full application

○ HAL only

○ Raw signal acquisition

○ Display

○ Metrology only

○ Calibration communication only (DLT645)

○ Metrology data transfer only (MQTT-SN)

○ All communication without metrology

○ Full application

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

© 2015 itemis France. All rights reserved.

o The use case: a 3-phase smart meter

o mbeddr: a highly enriched and extensible version of C

o Advanced smart meter software design

► Efficiency evaluation

○ Conclusions

Outline

28

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

© 2015 itemis France. All rights reserved.

Efficiency

29

Metrology node Application node

CODE Memory (Flash) 15,5 KB 10,6 KB

CONST Memory (Flash) 0,9 KB 0,2 KB

DATA Memory (SRAM) 4,2 KB 2,9 KB

mbeddr-generated C code small and fast enough

Code sizes

Runtime performance

Processor load of metrology node @ 4096 sample/s and 25 MHz: 80%

● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

© 2015 itemis France. All rights reserved.

Conclusions

30

○ mbeddr

= C + out-of-the-box extensions + user-defined extensions

= efficiency benefits + higher-level abstractions

= multi-language + multi-notation + seamless integration

○ Component-oriented design of embedded software

Explicit modular architectures

Hardware-independent testing

Incremental integration and commissioning

Reuse and platform-based development