Title: A Framework for Dynamically Configurable Embedded Controllers
1A Framework for Dynamically Configurable Embedded
Controllers
2Outline
- Introduction
- Pålsjö
- The PAL Language
- The Framework
- Patterns
- Case Studies
- Summary
3Introduction
- What is an embedded controller ?
- How are they implemented ?
- Which are the problems ?
- What kind of tools do we need ?
4Controller
Plant
5Embedded Controllers
- The controller is embedded in the system.
- Parallel tasks.
- The control loop.
- User interaction.
- Logging and displaying data
- Real-time
- The computer must react to inputs from the plant
at a certain speed. - Deadlines, soft and hard.
- Large and complex.
6Implementation Today
- Assembler, Forth
- C/C, Modula-2 real-time kernel
- ADA
- Dedicated systems
- PLC systems (SattLine).
- Matlab/X-Math with code generators
7Which are the problems?
- C/C, Modula-2 or ADA
- Dynamic and portable.
- Long development time error prone.
- Code Generators
- Easy to use,but limited.
- Can be used together with simulation tools.
- Static configuration.
- General problems
- Hard to maintain and reuse.
8What kind of tool did we need?
A rapid prototyping system that ...
- is easy to use and reuse,
- is portable, open and free,
- is on-line configurable,
- has supports algorithm libraries,
- and gives total control of execution.
9 and what did we get ? - Pålsjö!
- A framework for experiments in automatic control
and embedded systems. - A set of C-classes.
- Pålsjö Configuration Language - PCL.
- A language for control algorithm description.
- Pålsjö Algorithm Language - PAL Blomdell-97.
10Outline
- Introduction
- Pålsjö
- The Pal Language
- The Framework
- Patterns
- Three New Patterns
- Case Studies
- Summary
11Pålsjö ÈpùlÇSÎ
combines the advantages of the other approaches!
- Algorithms coded off-line.
- Block based language.
- Systems configured on-line.
- Creating, initializing, and connecting blocks.
- Data types tailored for automatic control.
- Matrices.
- Polynomials.
12- Support for control algorithms.
- Periodic and sequential algorithms.
- A run-time system.
- User interface.
- Network interface.
- Support for several platforms.
- Open and free.
- Automatic documentation.
- Support for algorithm libraries.
13Basic Ideas
- Observations
- Many controller implementations have a similar
internal structure. - The actual control algorithm is usually just a
fraction of the total code. - Solution
- Gather the common features in a library.
- Let the user only add the actual control
algorithm.
14The Pålsjö System
Function Libraries
User functions
PAL blocks
. . . . . . . .
Matrix functions
Polynomial function
15 On-line
Create blocks
Connect blocks
Real-time behavior
16Outline
- Introduction
- Pålsjö
- The PAL Language
- The Framework
- Patterns
- Three New Patterns
- Case Studies
- Summary
17PALPålsjö Algorithm Language
- Block based imperative language
- Signal and parameter interface
- Algorithm description
- Periodic and/or sequential.
Interface Description Algorithm Description
18Interface Description
- Variables declared with a data type and an
interface modifier. - The interface modifier defines how the variable
may interact with the environment - Input, Output, State, Parameter
- name ltinterface modifiergt ltdata typegt
19Data types
- Integers, floats.
- Strings
- Arrays
- Dimensions
- Integer variable used to specify dimensions for
aggregate data types.
i input integer s parameter string a1
integer array1..3 of real a2 array0..2
of input real d 1 dimension a3
array1..d of integer
20Data types
d1 2 dimension, d2 2 dimension M
matrix1..d1,1..d2 of real deg1 3
dimension P1 output polynomial1..deg1 of
real P2 input polynomial1..deg12 of real
21Periodic Algorithms
- Two special procedures
- Calculate() - Calculates output signals.
- Update() - Updates states.
- Example A PI-Controller
22Module Module1 block PI y, yref, v input
real u output real K, Ti, Tr
parameter real P, I 0.0, e real h
sampling interval bi hK/Ti, br
h/Tr calculate begin e yref - y
P K e u P I end
calculate update begin I I bi
e br (v - u) end update end PI end
Module1.
Interface section
Algorithm section
23Why two sweeps?
- Necessary in order to update states correctly
when signals are limited. - Keep the time delay from input to output at a
minimum.
24Sequential Algorithms
- Grafcet (IEC-1131)
- Textual representation for steps, actions and
transitions
Initial step Init pulse activate Action1 end
Init step Step2 activate Action2 end Step2
action Action1 u . step Action1
transition from Init to Step2 when true
25Outline
- Introduction
- Pålsjö
- The PAL Language
- The Framework
- Patterns
- Case Studies
- Summary
26The Framework
- Contains classes for block administration, user
interaction, network communication etc. - A skeleton application.
- Main loop lies within the framework.
27The Internal Structure
- Allows edits on a running system.
- Edits made on shadow configuration.
- Edits monitored and scanned for errors.
- States copied before swap.
28Reflection
- Autonomous blocks
- Contain name, type, owner variable set info
- Functions for cloning and copying itself
- Autonomous variables
- Contain name, type, owner connections
- Functions for cloning and copying itself
- Plug-in objects
- String interface
- Data type will parse themselves
- C wrapper
29Running the System
- PCL - Pålsjö Configuration Language
- Create, connect and execute blocks
- Reconfigure on the fly
- Text interface
- Network interface
- Setup
- Host - Target
- Single PC
30The Interface
31Outline
- Introduction
- Pålsjö
- The PAL Language
- The Framework
- Patterns
- Case Studies
- Summary
32The Pattern Concept
- Package informal information.
- Document traditional solutions.
- Originates from architecture.
- Patterns
- A set of cooperating classes for a well defined
problem. - Problem definition, solution idea, participants,
interaction,inheritance, sample code, known uses.
33Three New Patterns
- The Calculate-Update pattern.
- Execution of block diagrams.
- The Parameter-Swap pattern.
- Assigning parameters to critical processes.
- The Register Idiom.
- Adding code to a framework without recompilation.
34Parameter-Swap Pattern
- A real-time pattern that deals with the problem
of updating controller parameters in a fast and
consistent way. - Scenario
- Several low-priority write processes
- One critical read process - the control loop.
- Design a structure which allows parameter
assignment without blocking of the control loop.
35- c is an indirect parameter.
- Calculation of indirect parameters may be
expensive. - Solution
- Use two parameter set.
- Let the writer process do all calculations.
- Use pointer-swap to change parameter set.
Block par in input real out output
real s state real a, b parameter real
c a b calculate out end
calculate update begin s end
update end par
36The Run-time Behavior
37The Classes
- The super classes encapsulated the relation
between the block, the parameters and the
environment.
38Outline
- Introduction
- The PAL Language
- The Framework
- Patterns
- Case Studies
- Summary
39Case Studies
- Inverted pendulum - standalone and on the robot.
- Code reuse and scaling.
- A hybrid tank controller
- Combining periodic and sequential algorithms.
- An adaptive servo controller
- Polynomials, external function and global
dimensions - A fault-tolerant scheme
- On-line configuration.
40The Inverted Pendulum
- Swing up and stabilize.
- Equation of motion
- Measure the angle ?.
- Estimate the angular velocity.
41The Controller
- Three sub-controllers
- Swing-up
- Catch
- Stabilize
- Good estimates for the angular velocity
necessary!
42A Nonlinear Observer
- The observer
- Analysis ? stability conditions.
- Design guidelines.
43Experiments
44Pendulum on the Robot
45Outline
- Introduction
- Pålsjö
- The PAL Language
- The Framework
- Patterns
- Case Studies
- Summary
46Summary
- Pålsjö
- A tool for real-time control experiments
- A new dedicated language - PAL
- NT, Solaris, m68k-VME, and PowerPC-VME.
- Future Plans
- New mechanisms for hybrid systems.
- Java GUI.
- Improved support for on-line algorithm update.
- Simulation support.
47Simulation
- SIMART-A French simulation package for CACSD
- PAL blocks may execute in SIMART
- Experiments made with SIMULINK
48Related Work
49Contributions
- Design and implementation of the Pålsjö software
environment. - Three generic software patterns have been
identified and documented. - A novel nonlinear observer for the inverted
pendulum. - A new hybrid controller for a double tank system.
50Papers and Reports
- Johan Eker and Karl Johan Åström (1996) -
- A Nonlinear Observer for the Inverted
Pendulum. - Johan Eker and Anders Blomdell (1996) -
- A Structured Interactive Approach to
Embedded Control . - Jörgen Malmborg and Johan Eker (1997) -
- Hybrid Control of a Double Tank System.
- Johan Eker and Anders Blomdell (1997) -
- Patterns in Embedded Control Systems.
51Inheritance Structure
52System Blocks
- The Periodic block
- Executes its child block periodically.
- Built-in scheduler.
- The Sporadic block
- Executes its child blocks sporadically.
- Useful for tasks such as interrupt handling.
- An Algorithm block must belong to a Periodic or a
Sporadic block to be executed.
53Example of a Configuration
- Down-sampled measurement signal.
- Two sampling rates.
- ? Use two Periodic blocks.
54(No Transcript)
55Simulations
56A Hybrid Tank Controller
- Control the level of the lower tank.
- One controller for set-point changes.
- One controller for steady-state.
57PID
Time Optimal
58- Gain scheduled PID controller
- Time Optimal Controller
- Feedback using switching
curves - Switching PID ? Time Optimal using Lyapunov
functions.
Level tank 2 (m)
Level tank 1(m)
59Simulation
60Experiments
61Functions Procedures
procedure F(var1 input real var2 output
integer) begin . end
function F(var1 input real var2 output
integer) integer begin . result 1.0
end
62A Typical Control System
- Several parallel tasks
- The control loop
- Read values from the plant,
- Calculate new control signals
- Write control signal to actuator.
- User interaction.
- Logging and displaying data