industrial automation - slowtec...2019/01/15  · monthly iot meetup @ redhat | 2019-01-15 | slide...

30
Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 1 Industrial Automation with Rust, Embedded Linux, and Open Hardware

Upload: others

Post on 19-Aug-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Industrial Automation - slowtec...2019/01/15  · Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 21 Rust Cons Ecosystem is young and evolving – expect breaking changes when upgrading

Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 1

Industrial Automation

with Rust,

Embedded Linux,

and Open Hardware

Page 2: Industrial Automation - slowtec...2019/01/15  · Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 21 Rust Cons Ecosystem is young and evolving – expect breaking changes when upgrading

Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 2

Who we are...

Dipl.-Ing. Markus Kohlhase

Dipl.-Inform. Uwe Klotz

B.Sc. Enja Stein

Page 3: Industrial Automation - slowtec...2019/01/15  · Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 21 Rust Cons Ecosystem is young and evolving – expect breaking changes when upgrading

Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 3

What we do...

● Software Engineering● Automation & Closed-loop Control● Industrial 4.0● (Web) App Development● Product Prototyping● Consulting

● Software Engineering● Automation & Closed-loop Control● Industrial 4.0● (Web) App Development● Product Prototyping● Consulting

Page 4: Industrial Automation - slowtec...2019/01/15  · Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 21 Rust Cons Ecosystem is young and evolving – expect breaking changes when upgrading

Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 4

Some of our projects...

● Water treatment plants– Closed-loop control– HMI (Web app)

● Solar power plants● Irrigation systems

– Product design– Software development– I/O Systems engineering (Partner: Relumity)

● Laboratory software● Of-grid house automation● Geo. information system

● Water treatment plants– Closed-loop control– HMI (Web app)

● Solar power plants● Irrigation systems

– Product design– Software development– I/O Systems engineering (Partner: Relumity)

● Laboratory software● Of-grid house automation● Geo. information system

Page 5: Industrial Automation - slowtec...2019/01/15  · Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 21 Rust Cons Ecosystem is young and evolving – expect breaking changes when upgrading

Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 5

An industrial use case...● ~ 40 Sensors● ~ 15 Actuators

● ~ 40 Sensors● ~ 15 Actuators

Page 6: Industrial Automation - slowtec...2019/01/15  · Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 21 Rust Cons Ecosystem is young and evolving – expect breaking changes when upgrading

Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 6

Architecture

IPC / SBC I/O System

Android TabletTouchscreen

slowtec Software

Modbus TCP/RTU

Sensors Actuators

WLAN

Page 7: Industrial Automation - slowtec...2019/01/15  · Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 21 Rust Cons Ecosystem is young and evolving – expect breaking changes when upgrading

Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 7

Open Hardware(...our experiences so far)

● I/O System– IndustrialShields no RTD, insufcient quality ←– Kunbus no AO/AI in 2016←

● Industrial PC– Raspberry Pi unreliable←– Odroid unreliable, depending on environmental conditions←– IndustrialShields no Linux←– Olimex ? no experiences so far←

● I/O System– IndustrialShields no RTD, insufcient quality ←– Kunbus no AO/AI in 2016←

● Industrial PC– Raspberry Pi unreliable←– Odroid unreliable, depending on environmental conditions←– IndustrialShields no Linux←– Olimex ? no experiences so far←

Page 8: Industrial Automation - slowtec...2019/01/15  · Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 21 Rust Cons Ecosystem is young and evolving – expect breaking changes when upgrading

Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 8

I/O System & Industrial PC(Proprietary)

Page 9: Industrial Automation - slowtec...2019/01/15  · Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 21 Rust Cons Ecosystem is young and evolving – expect breaking changes when upgrading

Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 9

Our own open embedded industrial I/O board powered by Linux & Rust

● MIPS @ 1 GHz ● 128 MB RAM● 32 MB NOR Flash● versatile connectivity

● MIPS @ 1 GHz ● 128 MB RAM● 32 MB NOR Flash● versatile connectivity

Partner: Relumity, Stuttgart

Page 10: Industrial Automation - slowtec...2019/01/15  · Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 21 Rust Cons Ecosystem is young and evolving – expect breaking changes when upgrading

Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 10

Some insights...

Page 11: Industrial Automation - slowtec...2019/01/15  · Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 21 Rust Cons Ecosystem is young and evolving – expect breaking changes when upgrading

Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 11

HMI (Touchscreen with Web App)

Page 12: Industrial Automation - slowtec...2019/01/15  · Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 21 Rust Cons Ecosystem is young and evolving – expect breaking changes when upgrading

Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 12

What is NixOS?

Page 13: Industrial Automation - slowtec...2019/01/15  · Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 21 Rust Cons Ecosystem is young and evolving – expect breaking changes when upgrading

Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 13

NixOS is a Linux distribution with a unique approach to package and configuration management.It is completely declarative, makes upgrading systems reliable.

Page 14: Industrial Automation - slowtec...2019/01/15  · Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 21 Rust Cons Ecosystem is young and evolving – expect breaking changes when upgrading

Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 14

What is Rust?

Page 15: Industrial Automation - slowtec...2019/01/15  · Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 21 Rust Cons Ecosystem is young and evolving – expect breaking changes when upgrading

Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 15

Rust is an open source systems programming language with a focus on safety.

Page 16: Industrial Automation - slowtec...2019/01/15  · Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 21 Rust Cons Ecosystem is young and evolving – expect breaking changes when upgrading

Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 16

Why Rust?

Page 17: Industrial Automation - slowtec...2019/01/15  · Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 21 Rust Cons Ecosystem is young and evolving – expect breaking changes when upgrading

Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 17

“fast, reliable, productive – pick three”“fast, reliable, productive – pick three”

Page 18: Industrial Automation - slowtec...2019/01/15  · Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 21 Rust Cons Ecosystem is young and evolving – expect breaking changes when upgrading

Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 18

ReliabilityWhy does this still happen in 2018?

panic: runtime error: invalid memory address or nil pointer dereference[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x40142f]

...or even worse: Undefned behavior �

Page 19: Industrial Automation - slowtec...2019/01/15  · Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 21 Rust Cons Ecosystem is young and evolving – expect breaking changes when upgrading

Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 19

Rust Pros

● Safety & Reliability● Security● Predictability (hard-realtime)● Efciency & Performance● Productivity● Maintenance / Long Term Support● Community-drive and Open Source● Cross-platform / Embedded / Bare Metal● Tooling● Deployment

● Safety & Reliability● Security● Predictability (hard-realtime)● Efciency & Performance● Productivity● Maintenance / Long Term Support● Community-drive and Open Source● Cross-platform / Embedded / Bare Metal● Tooling● Deployment

Page 20: Industrial Automation - slowtec...2019/01/15  · Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 21 Rust Cons Ecosystem is young and evolving – expect breaking changes when upgrading

Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 20

Language Goodies● Powerful type system

– Pattern matching a.k.a. “switch on steroids”– Product types (structs, tuples) with methods– Sum types (enums) with data and methods– Light-weight OO through Traits

● Zero-cost abstractions– Resolved at compile-time

● Explicit error handling, no runtime exceptions

● Borrow-checker– Many memory and concurrency errors become impossible

● Allows (some) functional programming patterns● Interoperability with C/C++

– FFI + bindgen

● Tooling – Batteries included–

● Powerful type system– Pattern matching a.k.a. “switch on steroids”– Product types (structs, tuples) with methods– Sum types (enums) with data and methods– Light-weight OO through Traits

● Zero-cost abstractions– Resolved at compile-time

● Explicit error handling, no runtime exceptions

● Borrow-checker– Many memory and concurrency errors become impossible

● Allows (some) functional programming patterns● Interoperability with C/C++

– FFI + bindgen

● Tooling – Batteries included–

Page 21: Industrial Automation - slowtec...2019/01/15  · Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 21 Rust Cons Ecosystem is young and evolving – expect breaking changes when upgrading

Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 21

Rust Cons● Ecosystem is young and evolving

– expect breaking changes when upgrading

● Pure Rust solutions are missing– use C wappers (FFI/bindgen)

● Async primitives are missing – still unhandy, i.e. requires some boilerplate

– async/await announced for 2019

● No generators, coroutines, or higher-kinded types, yet– strict type system and borrow-checker take their toll– limits of the language design need to be pushed

● No ABI

● Ecosystem is young and evolving– expect breaking changes when upgrading

● Pure Rust solutions are missing– use C wappers (FFI/bindgen)

● Async primitives are missing – still unhandy, i.e. requires some boilerplate

– async/await announced for 2019

● No generators, coroutines, or higher-kinded types, yet– strict type system and borrow-checker take their toll– limits of the language design need to be pushed

● No ABI

Page 22: Industrial Automation - slowtec...2019/01/15  · Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 21 Rust Cons Ecosystem is young and evolving – expect breaking changes when upgrading

Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 22

Blazingly fast, compact, efcient● Single, statically linked binary● 6-10 MB in total (uncompressed)● Various communication channels

– HTTP– WebSocket– MQTT– ...

● Embedded Web Application (SPA)● Embedded SQLite DB

● Single, statically linked binary● 6-10 MB in total (uncompressed)● Various communication channels

– HTTP– WebSocket– MQTT– ...

● Embedded Web Application (SPA)● Embedded SQLite DB

Page 23: Industrial Automation - slowtec...2019/01/15  · Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 21 Rust Cons Ecosystem is young and evolving – expect breaking changes when upgrading

Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 23

How to build a controller without programming?

Page 24: Industrial Automation - slowtec...2019/01/15  · Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 21 Rust Cons Ecosystem is young and evolving – expect breaking changes when upgrading

Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 24

slowtec Open IIoT Stack

Page 25: Industrial Automation - slowtec...2019/01/15  · Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 21 Rust Cons Ecosystem is young and evolving – expect breaking changes when upgrading

Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 25

1. Confgure your I/O system

[io_systems.main.ur20] ip = "192.168.0.222" cycle_time_ms = 600

[io_systems.main.ur20.map]

# Temperature tcr001 = [7, 0] tcr002 = [7, 2]

# Pumps p1 = [11, 1] p2 = [11, 2]

Page 26: Industrial Automation - slowtec...2019/01/15  · Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 21 Rust Cons Ecosystem is young and evolving – expect breaking changes when upgrading

Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 26

2. Confgure your sensors / actuators

[inputs.fcr001] title = "Temperation" unit = "l/h" crop = { low = 0.0 } [inputs.fcr001.scale] from = { low = 4.0, high = 20.0 } to = { low = 0.0, high = 100.0 }

[outputs.p1] title = "Temperation pump P1" [outputs.p1.scale] from = { low = 0.0, high = 100.0 } to = { low = 0.0, high = 5.0 }

Page 27: Industrial Automation - slowtec...2019/01/15  · Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 21 Rust Cons Ecosystem is young and evolving – expect breaking changes when upgrading

Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 27

3. Defne your controllers [controllers.condensor_temp] input = "tcr003" output = "h1"

[controllers.condensor_temp.pid] p = 2.0 i = 0.003 d = 0.1 i_max = 80.0 max = 90.0 min = 30.0

[controllers.condensor_temp.setpoint] constraint = { min = 20.0, max = 45.0 } Default = 25.0

Page 28: Industrial Automation - slowtec...2019/01/15  · Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 21 Rust Cons Ecosystem is young and evolving – expect breaking changes when upgrading

Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 28

4. Run & have fun!

$ slowtec-iot config.toml

Page 29: Industrial Automation - slowtec...2019/01/15  · Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 21 Rust Cons Ecosystem is young and evolving – expect breaking changes when upgrading

Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 29

Other features

● Rules / Actions● State Machines● Recording● etc.

● Rules / Actions● State Machines● Recording● etc.

Page 30: Industrial Automation - slowtec...2019/01/15  · Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 21 Rust Cons Ecosystem is young and evolving – expect breaking changes when upgrading

Monthly IoT Meetup @ RedHat | 2019-01-15 | Slide 30

Thank you!

https://www.slowtec.de

https://github.com/slowtec

https://www.slowtec.de

https://github.com/slowtec