Activation Inheritance in Modelica Ramine Nikoukhah Scicos Project - - PowerPoint PPT Presentation

activation inheritance in modelica
SMART_READER_LITE
LIVE PREVIEW

Activation Inheritance in Modelica Ramine Nikoukhah Scicos Project - - PowerPoint PPT Presentation

Activation Inheritance in Modelica Ramine Nikoukhah Scicos Project July 8, 2008 Should all events be considered synchronous Consider multi-rate systems Different system components run at different frequencies Parts of the system can run on


slide-1
SLIDE 1

Activation Inheritance in Modelica

Ramine Nikoukhah

Scicos Project

July 8, 2008

slide-2
SLIDE 2

EOOLT July 2008

  • R. Nikoukhah

2

Should all events be considered synchronous

Consider multi-rate systems Different system components run at different frequencies Parts of the system can run on conditional bases Full or partial synchronization may or may not be needed How to have flexibility to: Leave different components asynchronous Impose easily synchronism when needed

slide-3
SLIDE 3

EOOLT July 2008

  • R. Nikoukhah

3

Example

Untitled

input file read from

Plant

+

  • Control

Detection Failure

Synchronism is not needed in this situation Imposing it creates unneeded constraints

slide-4
SLIDE 4

EOOLT July 2008

  • R. Nikoukhah

4

Why not impose synchronization?

Due to numerical errors in solvers, zero-crossing times are never exact Counting on simultaneous zero-crossing detections only increases non-determinism In most cases, such synchronisms are unwanted; user does (should) not count on them They lead to an exponentially growing number of event scenarios: virtually impossible to generate efficient static code

slide-5
SLIDE 5

EOOLT July 2008

  • R. Nikoukhah

5

Event clocks in Scicos

Event clocks are not basic blocks

Untitled

Two Event clocks do not generate synchronous events

Super Block

1 0.1 Delay

slide-6
SLIDE 6

EOOLT July 2008

  • R. Nikoukhah

6

Synchronization problems to avoid

Incorrect way of implementing decimation

Activation sources

generate asynchronous events => order of block execution is not predictable.

Source

S/H

Clock Slow Clock Fast

Func.

slide-7
SLIDE 7

EOOLT July 2008

  • R. Nikoukhah

7

Synchronization problems to avoid

Use frequency division: Combination Counter Modulo and If-then-else => frequency division. Division factor set by fixing the value of n, and the phase by the initial state of the counter. The freq_div (Super) block, available in the Events palette, is constructed this way.

slide-8
SLIDE 8

EOOLT July 2008

  • R. Nikoukhah

8

Synchronization problems to avoid

Correct way of implementing decimation

Synchronized events at different frequencies can be implemented by sub-sampling the fast clock

Source

S/H

Clock Fast

Func.

then else If in>0 Modulo n Counter

slide-9
SLIDE 9

EOOLT July 2008

  • R. Nikoukhah

9

Example of a multirate system

Systems diagnosis with controller reconfiguration Synchronization is required

slide-10
SLIDE 10

EOOLT July 2008

  • R. Nikoukhah

10

Sample clocks

Virtual blocks, replaced by one Event clock and sub-sampling Uses slowest clock generating all events using sub-sampling: modulo counter and conditional blocks Clock algebra similar to Simulink Resulting events are synchronized Transparent to the user

1 S-CLK

3 S-CLK

slide-11
SLIDE 11

EOOLT July 2008

  • R. Nikoukhah

11

Modelica vs Scicos

unitDelay

1 z

k=1 gain

1/z

1

In this case Event Clock or Sample Clock can be used in Scicos No synchronization problem

slide-12
SLIDE 12

EOOLT July 2008

  • R. Nikoukhah

12

Modelica vs Scicos

The two diagrams are not equivalent Scicos diagram is not synchronous The correct formulation is:

unitDelay

1 z

unitDelay1

1 z

1/z 1/z

1/z 1/z

1 S-CLK 1 S-CLK

slide-13
SLIDE 13

EOOLT July 2008

  • R. Nikoukhah

13

Other solution: explicit event signals

Other solution to synchronize blocks is to drive them explicitly with synchronized event signals Events need not be periodic

unitDelay

1 z

unitDelay1

1 z

be

1/z 1/z

:

slide-14
SLIDE 14

EOOLT July 2008

  • R. Nikoukhah

14

Other solution: activation inheritance

Blocks, in the absence of activation, inherit their activations through regular inputs Events need not be periodic

unitDelay

1 z

unitDelay1

1 z

:

1/z 1/z

A/D

slide-15
SLIDE 15

EOOLT July 2008

  • R. Nikoukhah

15

Activation inheritance

Simple and non-ambiguous rules Provides a data-flow like behavior Inheritance mechanism does not considerably modify the compiler: missing activation signals added at a pre-compilation phase Can also be used in applications where the activations are not periodic

slide-16
SLIDE 16

EOOLT July 2008

  • R. Nikoukhah

16

Modelica: method 1

Consider a masked Scicos block to include period information in the block Compatible with current Modelica Discrete library if special interpretation used for the keyword sample

3 S-CLK

1/z

1 1

unitDelay

1 z

slide-17
SLIDE 17

EOOLT July 2008

  • R. Nikoukhah

17

Modelica: method 2

Introduce a new type “Event” in Modelica and include an Event input port for this block Defining events as new types in Modelica has other advantages

1 z

1/z

model Memory input Event e1;

  • utput Real y;

input Real u; discrete Real z; equation when e1 then z=u; y=pre(z); end when; end Memory;

slide-18
SLIDE 18

EOOLT July 2008

  • R. Nikoukhah

18

Modelica: method 3

Use activation inheritance mechanism Allow “discrete” equations in “equation section where the activation in inherited

1/z

unitDelay

1 z

model Memory

  • utput Real y;

input Real u; discrete Real z; equation z=u; y=pre(z); end Memory;

slide-19
SLIDE 19

EOOLT July 2008

  • R. Nikoukhah

19

Conclusion

Before considering to rewrite the discrete block library in Modelica, synchronization issue need to be clarified All three mechanisms can be used but result in different libraries Very relevant to current discussions about the controller specification and real-time code generation