AG VLSI Design and Architecture

SFB 501 - Project D1: Application System "Buildings"

PSiGene

Pattern Catalog

[PSiGene]

15.4 Pattern PIDControl

Intent

PID control algorithm.

Also Known As

 

Motivation

 

Applicability

 

Structure

 

Participants

Same as TwoPointControl plus:

Methods:
Relations:

Collaborations

 

Consequences

 

Implementation

compute
    | diff prop control |
    "calculates weather it is too warm, too cold or just good"
    "calls corresponding method according to the temperature"

    diff := 10.0 * (self {oldTemperature} - self {getRadiatorTemperature}).
    prop := 20.0 * (self {desiredTemperature} - self {getTemperature}).
    control := (diff + prop) * self {interval} / 60.0.
    (control > 60.0) ifTrue: [ control := 60 ].
    (control < -60.0) ifTrue: [ control := -60 ].

    control > 0 ifTrue: [ self {tooCold}: control ].
    control < 0 ifTrue: [ self {tooWarm}: (control abs). ]
        ifFalse: [ self {good}. ].'
tooWarm: time
    |anEvent aThread |
    self {thread} instance isNil ifTrue:
    [
        (anEvent := SimEvent new)
        sender: self {activeObject} instance;
        receiver: self {activeObject} instance;
        timestamp: (Scheduler simSched simMillisecondClockValue + time);
        deadline: (anEvent timestamp + 3000);
        eventType: #openValve;
        eventData: `'''.    

        self {tooWarm}. 

        aThread := Thread
        createThread:
            [   :currentEvent |
                self {good}.
                self {activeObject} instance killThread: (self {thread} instance).
                self dco_{thread}: (self {thread} instance).
            ]
            atPriority: {priority}.
        self {activeObject} instance addThread: aThread reactOn: #(#openValve).
        self con_{thread}: aThread.
        self {event} instance send.
    ].
    ^self'

Related Patterns

GenericControl , TwoPointControl

PEdit description

 


previous page next page up   Table of Contents PSiGene