Simulation Tools for Wireless Automation - Aaltogeta.aalto.fi/en/courses/lect11_geta_2009.pdf ·...
Transcript of Simulation Tools for Wireless Automation - Aaltogeta.aalto.fi/en/courses/lect11_geta_2009.pdf ·...
TKK | Control Engineering
Simulation Tools for Wireless AutomationSimulation Tools for Wireless Automation
Mikael Björkbom
TKK | Control Engineering AS-74.3199 Wireless Automation
ContentsContents
• Introduction
• Simulators for wireless/networked/embedded control systems
• PiccSIM-simulator
• Case studies
TKK | Control Engineering AS-74.3199 Wireless Automation
Wireless Automation Solutions
• Communications and control are interconnected!Simply: no data -> no control
• Development of control algorithms that tolerate jitter and losses
Robustness vs. performance
• Development of communication protocols and technologies that reduce jitter
• Need to evaluate different protocols/control methodsImpact on overall system?
Practical issues
TKK | Control Engineering AS-74.3199 Wireless Automation
Need for CoNeed for Co--Simulation ToolsSimulation Tools
• Complex systems, need simulation to study: PiccSIME.g. Effect of MAC/routing protocol on control performance
Networked and distributed application
• Simulation tools required to support co-design and co-simulation of both wireless and automation
TKK | Control Engineering AS-74.3199 Wireless Automation
Simulators for wireless/networked/embedded control system design
TKK | Control Engineering AS-74.3199 Wireless Automation
Categorization
• Asynchronous simulationPtolemy II
• Communication basedNs-2
• Dynamic agents• Control based
Simulink• Truetime
• Co-simulation platformsIntegration of communication and control simulation tools
• Ns-2 + Modelica• Ns-2 + Simulink (PiccSIM)
TKK | Control Engineering AS-74.3199 Wireless Automation
Ptolemy II
• Dynamic systems and asynchronous eventsDiscrete, asynchronous events
• Not real network modelsNo interference
Distance based radio range
Transmission delay
J. Eker, J.W. Janneck, E.A. Lee, J. Liu, X. Liu, J. Ludvig, S. Neuendorffer, S. Sachs and Y. Xion. Taming heterogeneity—the Ptolemy approach. In Proc. of the IEEE. Vol. 91, no. 1. 2003. pp. 127.144
TKK | Control Engineering AS-74.3199 Wireless Automation
The Network Simulator, Ns-2• Simulation of wired & wireless networks
Open source platformNew technologies quickly available
• Supported layersMAC, CSMA
• Link layer, RoutingTransport
• TCP, Streaming• Constant bitrate UDP
• PartlyApplication
• Ping, Telnet, FTP, HTTP• Processing at Sender & Receiver• Traffic generation
Physical• Radio propagation models
TKK | Control Engineering AS-74.3199 Wireless Automation
Ns-2
• Trace simulation eventsAnalyze results
• Network Animator, NAMVisual representation of simulation
TKK | Control Engineering AS-74.3199 Wireless Automation
Ns-2
• Ns-2 is for communication simulation
• Addition of Agents with dynamic propertiesOrdinary differential equations
Ns-2 ”samples” the Agent and sends the information
M.S. Branicky, V. Liberatore, S.M. Phillips. Networked control system co-simulation for co-design. In Proc. of the American Control Conference, 2003. vol. 4. 4-6 June, 2003. pp. 3341-3346.
TKK | Control Engineering AS-74.3199 Wireless Automation
TrueTime
• Impemented as S-functions (C-code) in Simulink
• Control engineering approach
• Used mainly for scheduling of CPUs
• Wired and wireless network modelsLAN, WLAN, Bluetooth, ZigBee
Simple network models
Network simulation accuracy questionable
D. Henriksson, A. Cervin and K.-E. Årzén. TrueTime: Simulation of Control Loops Under Shared Computer Resources. In Proc. 15th IFAC World Congress on Automatic Control. Barcelona, Spain. July 2002.
TKK | Control Engineering AS-74.3199 Wireless Automation
TrueTime
uy
r
TrueTime 1.5 Distributed Wireless Control SystemCopyright (c) 2007
Martin Ohlin , Dan Henriksson and Anton CervinDepartment of Automatic Control , Lund University , Sweden
Please direct questions and bug reports to : truetime @control .lth .se
u
reference
r, y
Wireless Network
snd1
snd2
rcv 1
rcv 2
P1
P2
Node 2(Controller )
A/D
Rcv
P
Snd
Node 1(Sensor /Actuator )
Rcv
A/D
P
D/A
Snd
P2
snd1snd2
P1
rcv2
rcv1[snd1]
[P1]
[snd2]
[rcv2]
[rcv1]
[P2]
Display
DC Servo
1000
s +s2
Clock
TKK | Control Engineering AS-74.3199 Wireless Automation
Integrated
• Ns-2 + Modelica
• PiccSIM: Ns-2 + Simulink
• Benefits from both fieldsAppropriate tools for comm. & contr. model building
Not complete integration
• Ultimately: fully featured single tool!
TKK | Control Engineering AS-74.3199 Wireless Automation
Ns-2 + Modelica
• Ns-2 controls simulationBoth on the same machine
• Ns-2 instructs Modelica to run to the next sample time
Exchange of informationNetwork simulation
• DrawbacksNo event based communication
Ns-2 + Modelica: Al-Hammouri, D. Agrawal, V. Liberatore, H. Al-Omari, Z. Al-Qudah, and M. S. Branicky. Demo Abstract: A Co-Simulation Platform for Actuator Networks. Sensys 2007.
Queued packets
TKK | Control Engineering AS-74.3199 Wireless Automation
PiccSIM simulator
TKK | Control Engineering AS-74.3199 Wireless Automation
PiccSIM
• Platform for integrated communication and control design simulation, implementation and modelling
• Main developers (@TKK): Mikael Björkbom & Shekar Nethi
• Integrates two widely used simulatorsNs-2: Communications system simulation
MATLAB/Simulink: Control design and simulation
Integration saves the burden of developing a complete simulator from scratch! (maintenance, updates...)
• Aim: to provide the tools and solutions for wireless automation
Communications and control co-design and co-simulation
All the required design tools in one environment
TKK | Control Engineering AS-74.3199 Wireless Automation
PiccSIM
• Simulink + ns-2• Simulink sends packets through ns-2
Separate computersUDP packetsSimulation time-synchronization between computers
• Application event based communicationSend on thresholdAlarms
TKK | Control Engineering AS-74.3199 Wireless Automation
PiccSIM: Integration of Simulink and nsPiccSIM: Integration of Simulink and ns--22
TKK | Control Engineering AS-74.3199 Wireless Automation
PiccSIM architecture
Server, DB
Remote User InterfaceMoCoNet GUI
Process
Simulink orxPC Target
I/O Board
Controller
Sensors
Internet
Ns-2 Network Simulator
Simulation
Configuration and management
PiccSIM ArchitectureLocal User InterfacePiccSIM Toolchain
TKK | Control Engineering AS-74.3199 Wireless Automation
ToolchainToolchain
• Main GUISimulink model
Ns-2 TCL script
PiccSIM block library
• Access to design toolsControl design
Network design
Code generation tools
• Start/Stop simulationCoordinates simulation
• Simulink and ns-2
TKK | Control Engineering AS-74.3199 Wireless Automation
PiccSIM Network Design ToolPiccSIM Network Design Tool
• Place wireless nodes
• Define network settingsPhysical, MAC, Routing...
Traffic, Agents...
Simulation settings
• Automatically generate TCL script for ns-2
TKK | Control Engineering AS-74.3199 Wireless Automation
Control design and simulation, MATLAB / Simulink
• Provides the tools required for versatile control designPID control
Fuzzy control
Neural networks
Model predictive control etc...
• High-level programming environment for simulations
• Almost any modelled plant and designed controller can be simulated in Simulink including
Signal processing components
Filtering
Estimation algorithms etc...
• Supports automatic code generation to implement the controllers on real-time operating systems
TKK | Control Engineering AS-74.3199 Wireless Automation
Simulink
• Control engineering friendly
Build application with Simulink
• PiccSIMReady made blocks for integration with Ns-2
Time-synchronization between Simulink and ns-2
Any system made with Simulink can be simulated with ns-2 network!
TKK | Control Engineering AS-74.3199 Wireless Automation
Scope of ToolchainScope of Toolchain
• Simulation ofWireless Networked Control System (WiNCS)
Sensor Network applications
• Application + network
Sensor node
Send to N 1 T 1Node
ID = 0
Reference
Out
Process
Process
Controller node
Timestamps
Data N 0 T 1
Node
ID = 1 Controller
ControllerPID
uy_ref
y
TKK | Control Engineering AS-74.3199 Wireless Automation
Automatic Code GenerationAutomatic Code Generation
• Simulation -> Implementation and testing on real hardware
• Generic node block in PiccSIM libraryMake implementation in block
• Simulink blocks, Matlab code...
• Radio blocks for communication between nodes
• Matlab Real-Time WorkshopTarget Language Compiler (TLC)
Generate code from Simulink block
• Wrapper main file for Sensinode node hardwareOther wrappers can easily be implemented
Process_interface
AD 0
Radio timestamp 1
Radio recv 1
DA 6
DA 7
Radio send 1
TKK | Control Engineering AS-74.3199 Wireless Automation
Automatic Code GenerationAutomatic Code Generation
Radio send 1
3
DA 7
2
DA 6
1
Tapped Delay
4Delays
Signal Specification
D:3 Saturation
Rate Transition
Gain 3
2.5
Gain 2
2.5/0.8 Gain 1
90/2.5
DetectChange
U ~= U/z
Data Type Conversion
double
Constant
L
Bias2
u-2.5/2
Bias1
u+0.4
Add
Radio recv 1
3
Radio timestamp 1
2
AD 0
1
TKK | Control Engineering AS-74.3199 Wireless Automation
PiccSIM – Key features
• Support for powerful control design and implementation tools provided by MATLAB/Simulink
• Capability to simulate any wired/wireless networks readily available in ns-2
• Automatic code generation from Simulink models for real-time execution on real wireless node hardware
• Real-time control of a true or simulated process over a user-specified network
• Easy-to-use network configuration tool and• The platform is accessible over the Internet, i.e. it supports
remote experimenting.
TKK | Control Engineering AS-74.3199 Wireless Automation
BUILDING AUTOMATION BUILDING AUTOMATION CASE STUDYCASE STUDY
TKK | Control Engineering AS-74.3199 Wireless Automation
Building Automation CaseBuilding Automation Case
Room
Access point
Wireless sensor
North
Elevator WC
Server
Kitchen
Control Café
Meeting room 1
Meeting room 2
WC1: 4.5x3.2
5: 3.9x4.5
3: 3.9x4.5
4: 3.9x4.5
6: 3.9x4.5
7: 4.5x4.58: 4.5x4 9: 4.5x6
10: 4.5x6
11: 3.9x4.5
12: 3.9x4.5
39: 8x6 38: 8x6 37: 6.8x7 36: 6.8x3.8 35: 6.8x5.2 34: 6.8x5 33: 6.8x5 32: 6.8x5 31: 6.8x4
16: 4.5x5.5
15: 2.5x4.5
14: 2.5x4.5
13: 2.5x4.5
17: 4.5x6 18: 4.5x3 19: 4.5x3
20: 2.5x4.5
21: 3.9x4.5
22: 3.9x4.5
23: 3.9x4.5
24: 4.5x4.5
25: 2.5x4.5
26: 2.7x4.5
27: 3.9x4.5
28: 2.7x4.5
29: 2.7x4.5
30: 3.9x4.52: 4.5x3.2
1: 3.9x4.5 = ID: (N-S)x(W-E)
4.5x3.2
4.5x2
11x1.6
22x1.6
2x60
11x1.6
Plaster wallConcrete wallBrick wall (50% glass windows)
TKK | Control Engineering AS-74.3199 Wireless Automation
Building Automation CaseBuilding Automation Case
• Temperature and ventilation control of office
• Wireless sensors transmit measurements to central controllerTemperature, CO2, desired temperature
Occupancy messages for lightning
• Controller calculates heating and airflow to each room
• Currently wired, what happens when wireless?
TKK | Control Engineering AS-74.3199 Wireless Automation
Key Features of CaseKey Features of Case
• Large number of nodes, much traffic
• Time-driven (temperature) + Event driven (people enter the room)
• Static (no node mobility)
• Indoor => reduced communication rangeMultihop
• Slow process dynamics compared to networkPacket drop problems
Transmission time << Process time-constant
TKK | Control Engineering AS-74.3199 Wireless Automation
Wireless Control LoopWireless Control Loop
Room
Sensor node
Send to N 1 T 1Node
ID = 0
Reference
Out
Process
Process
Controller node
Timestamps
Data N 0 T 1
Node
ID = 1 Controller
ControllerPID
uy_ref
y
Wireless communication
RoomTemperature sensor
Access point
TKK | Control Engineering AS-74.3199 Wireless Automation
Case studies: Wireless building automation system
• Physical models:Heat balance in rooms (PID control)
CO2 concentration in rooms (relay control)
Event driven signals, lighting (on/off)
• Communication model:Zigbee radio module (15m range)
Ricean indoor propagation channel model
Room
Acces point
Wireless sensorNorth
Elevator WC
Server
Kitchen
Control Café
Meeting room 1
Meeting room 2
WC1: 4.5x3.2
5: 3.9x4.5
3: 3.9x4.5
4: 3.9x4.5
6: 3.9x4.5
7: 4.5x4.5 8: 4.5x4 9: 4.5x6 10: 4.5x6
11: 3.9x4.5
12: 3.9x4.5
39: 8x6 38: 8x6 37: 6.8x7 36: 6.8x3.8 35: 6.8x5.2 34: 6.8x5 33: 6.8x5 32: 6.8x5 31: 6.8x4
16: 4.5x5.5
15: 2.5x4.5
14: 2.5x4.5
13: 2.5x4.5
17: 4.5x6 18: 4.5x3 19: 4.5x3
20: 2.5x4.5
21: 3.9x4.5
22: 3.9x4.5
23: 3.9x4.5
24: 4.5x4.5
25: 2.5x4.5
26: 2.7x4.5
27: 3.9x4.5
28: 2.7x4.5
29: 2.7x4.5
30: 3.9x4.5
2: 4.5x3.2
1: 3.9x4.5 = ID: (N-S)x(W-E)
4.5x3.24.5x2
11x1.6
22x1.6
2x60
11x1.6
Plaster wallConcrete wallBrick wall (50% glass windows)
Room
Acces point
Wireless sensorNorth
Elevator WC
Server
Kitchen
Control Café
Meeting room 1
Meeting room 2
WC1: 4.5x3.2
5: 3.9x4.5
3: 3.9x4.5
4: 3.9x4.5
6: 3.9x4.5
7: 4.5x4.5 8: 4.5x4 9: 4.5x6 10: 4.5x6
11: 3.9x4.5
12: 3.9x4.5
39: 8x6 38: 8x6 37: 6.8x7 36: 6.8x3.8 35: 6.8x5.2 34: 6.8x5 33: 6.8x5 32: 6.8x5 31: 6.8x4
16: 4.5x5.5
15: 2.5x4.5
14: 2.5x4.5
13: 2.5x4.5
17: 4.5x6 18: 4.5x3 19: 4.5x3
20: 2.5x4.5
21: 3.9x4.5
22: 3.9x4.5
23: 3.9x4.5
24: 4.5x4.5
25: 2.5x4.5
26: 2.7x4.5
27: 3.9x4.5
28: 2.7x4.5
29: 2.7x4.5
30: 3.9x4.5
2: 4.5x3.2
1: 3.9x4.5 = ID: (N-S)x(W-E)
4.5x3.24.5x2
11x1.6
22x1.6
2x60
11x1.6
Plaster wallConcrete wallBrick wall (50% glass windows)
TKK | Control Engineering AS-74.3199 Wireless Automation
On the physical model
TzdTz /dt
Tz [C]1roo _a*c_a
-K -
UA_W
-K -
UA _S
-K -
UA _R
-K -
UA _N
-K -
UA _E
-K -
Tw - Tz
Tsa - Tz
Ts - Tz
To - Tz
Tn - Tz
Te - Tz
Product
Integrator
1s
Inflow air temp
-C-
Inflow
-C-
From 1
t_out
Add
1/delta
-K -
Tw [C]4
Te [C]3
Ts [C]2
Tn [C]1
TKK | Control Engineering AS-74.3199 Wireless Automation
SimulationSimulation
TKK | Control Engineering AS-74.3199 Wireless Automation
One RoomOne Room
20 40 60 80 100 120 14020
22
24Temperature loop 18
20 40 60 80 100 120 140-1000
0
1000
Temperature Heating
Problems?
TKK | Control Engineering AS-74.3199 Wireless Automation
Dropped PacketsDropped Packets
1 2
34 5
6
7 8 9 10
1112 13
141516 17 18 19
2021
22
2324
252627282930
313233343536373839
0 11.3 22.5 33.8 45 56.3 67.5 78.8 90
TKK | Control Engineering AS-74.3199 Wireless Automation
Stability?Stability?
• Network drops packetsNo information => no control?
• Jitter margin, δmaxHow much packet drops can the control loop tolerate
Stability theorem
• Robusness to Transmission delay jitter
Packet drops
Dotted: δmax= 1 packetSolid: δmax = 2 consecutive packets
20 40 60 80 100 120 14020
21
22
23
24Temperature loop 18
20 40 60 80 100 120 140-1000
0
1000
Heating
20 40 60 80 100 120 140-1000
-500
0
500
1000
Temperature Heating
TKK | Control Engineering AS-74.3199 Wireless Automation
Room Far AwayRoom Far Away
20 40 60 80 100 120 14018
20
22
24Temperature loop 24
20 40 60 80 100 120 140-1000
0
1000
2000
Temperature Heating
• Almost unstable with δmax = 2
• Need better network Quality of Service• Solution?
TKK | Control Engineering AS-74.3199 Wireless Automation
Add Another Access PointAdd Another Access Point
• Wired Ethernet between access points
Room
Access point
Wireless sensor
North
Elevator WC
Server
Kitchen
Control Café
Meeting room 1
Meeting room 2
WC1: 4.5x3.2
5: 3.9x4.5
3: 3.9x4.5
4: 3.9x4.5
6: 3.9x4.5
7: 4.5x4.58: 4.5x4 9: 4.5x6
10: 4.5x6
11: 3.9x4.5
12: 3.9x4.5
39: 8x6 38: 8x6 37: 6.8x7 36: 6.8x3.8 35: 6.8x5.2 34: 6.8x5 33: 6.8x5 32: 6.8x5 31: 6.8x4
16: 4.5x5.5
15: 2.5x4.5
14: 2.5x4.5
13: 2.5x4.5
17: 4.5x6 18: 4.5x3 19: 4.5x3
20: 2.5x4.5
21: 3.9x4.5
22: 3.9x4.5
23: 3.9x4.5
24: 4.5x4.5
25: 2.5x4.5
26: 2.7x4.5
27: 3.9x4.5
28: 2.7x4.5
29: 2.7x4.5
30: 3.9x4.52: 4.5x3.2
1: 3.9x4.5 = ID: (N-S)x(W-E)
4.5x3.2
4.5x2
11x1.6
22x1.6
2x60
11x1.6
Plaster wallConcrete wallBrick wall (50% glass windows)
Ethernet
TKK | Control Engineering AS-74.3199 Wireless Automation
Far Away RoomFar Away Room
20 40 60 80 100 120 14018
20
22
24Temperature loop 24
20 40 60 80 100 120 140-1000
0
1000
2000
Temperature Heating
One access point Two access points
20 40 60 80 100 120 140
20
21
22
Temperature loop 24
20 40 60 80 100 120 140-1000
0
1000
Temperature Heating
TKK | Control Engineering AS-74.3199 Wireless Automation
Packet drop with two access pointsPacket drop with two access points
1 2
34 5
6
7 8 9 10
1112 13
141516 17 18 19
2021
22
2324
252627282930
313233343536373839
0 11.3 22.5 33.8 45 56.3 67.5 78.8 90
TKK | Control Engineering AS-74.3199 Wireless Automation
Control Cost, PerformanceControl Cost, Performance
No network One access point Two access points
1 234 5
67 8 9 10
1112 13
141516 17 18 19
2021222324
252627282930
313233343536373839
0 0.0187 0.0375 0.0562 0.075 0.0938 0.112 0.131 0.15
1 234 5
67 8 9 10
1112 13
141516 17 18 19
2021222324
252627282930
313233343536373839
0 0.0187 0.0375 0.0562 0.075 0.0938 0.112 0.131 0.15
1 234 5
67 8 9 10
1112 13
141516 17 18 19
2021222324
252627282930
313233343536373839
0 0.0187 0.0375 0.0562 0.075 0.0938 0.112 0.131 0.15
TKK | Control Engineering AS-74.3199 Wireless Automation
Conclusions of the BA-case study
• Wireless communication affects controlNeed enough network QoS
• One access point is not enoughNetwork re-design: Add access point
Also other network considerations, later...
• Control stabilityController tuning revised
• Only by simulating both communication and controlAnalyze how system actually works
Reveals problems not otherwise obvious
TKK | Control Engineering AS-74.3199 Wireless Automation
Target tracking
• A moving robot, whose distance to static nodes is measured
• At least three distance measurements are needed to obtain a position estimate
• Remote control along a predefined route
• AODV (single path) and LMNR (multipath) routing protocols and their effect on the control performance compared
TKK | Control Engineering AS-74.3199 Wireless Automation
Recorded simulation of target tracking
TKK | Control Engineering AS-74.3199 Wireless Automation
Results
• Multipath routing establishes the route faster
Shorter delay
Positive impact on control
• Long delays make the position control hard
Error increases
Oscillations and overshoot
• LMNR results in roughly 10 % better position estimation accuracy over AODV 200 300 400 500 600 700 800 900 1000 1100
200
300
400
500
600
700
800
900
1000
Reference trajectorySinglepath routingMultipath routingNo contact
TKK | Control Engineering AS-74.3199 Wireless Automation
Simulation scenario
• Squad of mobile wireless robots moving in different formations
• Controlled by leader• Assume location based on
e.g.GPSodometer orinertia measurements
• Routing <-> Control performance
Can not be determined beforehand!
TKK | Control Engineering AS-74.3199 Wireless Automation
Networked robotics - demo
• Circle: desired position
• Ball: robot position
• Red: no connection
• Green: leader
Video
TKK | Control Engineering AS-74.3199 Wireless Automation
PiccSIM – Researcher’s Interface
• PiccSIM webpage: http://www.control.hut.fi/dev/MoCoNet/PiccSIM.html
• Upload of Simulink model and ns-2 tcl scripts
• Run simulation remotely
TKK | Control Engineering AS-74.3199 Wireless Automation
Conclusions
• The problems of wireless automation from the control design point-of-view are related to
Asynchronism
Varying time-delays
Packet loss
• The choice of communication methods, network topology and protocols (e.g. routing) greatly affect the QoS experienced by the control system
• Hard to know beforehand how a protocol will affect the control results
• Co-design and co-simulation are required!
TKK | Control Engineering AS-74.3199 Wireless Automation
ConclusionsConclusions
• Simulator suitable for co-simulation of wireless automationTrueTime
Modelica/ns-2
• PiccSIM provides a relatively easy-to-use tool for researchSimulink + ns-2
Graphical user interfaces: network configuration, radio environment modeling tools
Tools for control design and tuning