Tipps zur Laufzeitoptimierung

Bei größeren Applikationen mit vielen Achsen kann es notwendig werden, die Instanzen der Funktionsbausteine zeitoptimiert aufzurufen, d.h. die FB-Instanzen sollen nur dann ausgeführt werden, wenn sie auch benötigt werde.

Der folgende kurze Codeabschnitt in StructuredText soll die Technik verdeutlichen, mit der die Laufzeit einer Applikation verringert werden kann. Als Beispiel wird hier der Funktionsbaustein „MC_MoveVelocity“ verwendet.

Mit der Variablen „MC_MoveVelocity_Active“ wird der Funktionsbaustein gesteuert. Sie kann dabei die folgenden Werte annehmen:

Wert

Bedeutung

0

Funktionsbaustein wird nicht ausgeführt.

1

Funktionsbaustein wird ausgeführt, der Eingang „Execute“/“Enable“ ist TRUE.

2

Funktionbaustein wird ausgeführt, bis die entsprechend abgefragte Quittierung (z.B. „Done“, „CommandAborted“ etc.) gesetzt ist. „Execute“/“Enable“ ist FALSE.

Zu Beginn wird „MC_MoveVelocity_Active“ in Abhängigkeit vom Eingang „Execute“/“Enable“ auf 1 gesetzt. Damit wird der Funktionsbaustein „MC_MoveVelocity“ ausgeführt. Solange der Eingang nicht zurück gesetzt wird, bleibt dieser Zustand erhalten.

IF ( Execute_MoveVelocity = TRUE ) AND (MC_MoveVelocity_Activ = 0 ) THEN 
  MC_MoveVelocity_Active :=1;
END_IF

Erst, wenn der Eingang „Execute“/“Enable“ auf FALSE gesetzt wird, ändert sich der Wert von „MC_MoveVelocity_Active“ auf 2. Der Funktionsbaustein wird jetzt noch solange gerechnet, bis eine Quittierung am Ausgang anliegt (hier: „Done“ oder „CommandAborted“). Im Fehlerfall, der hier nicht berücksichtigt ist, ist entsprechend ähnlich zu vorzugehen.

IF MC_MoveVelocity_Active > 0 THEN
  MC_MoveVelocity(
    Axis         := AxisReference,          
    Execute      := Execute_MoveVelocity,          
    Velocity     := Velocity_MoveVelocity,          
    Acceleration := Acceleration_MoveVelocity,          
    Deceleration := Deceleration_MoveVelocity,          
    Jerk         := Jerk_MoveVelocity,          
    Direction    := Direction_MoveVelocity ); 
  AxisReference               := MC_MoveVelocity_0.Axis; 
  InVelocity_MoveVelocity     := MC_MoveVelocity_0.InVelocity; 
  CommandAborted_MoveVelocity := MC_MoveVelocity_0.CommandAborted;
  Error_MoveVelocity          := MC_MoveVelocity_0.Error; 
  ErrorID_MoveVelocity        := MC_MoveVelocity_0.ErrorID;
  IF MC_Mov  eVelocity_Active = 2 AND ( InVelocity_MoveVelocity = TRUE OR  CommandAborted_MoveVelocity = TRUE) THEN 
    MC_MoveVelocity_Active :=0;
  ELSIF Execute_MoveVelocity = FALSE THEN   
    MC_MoveVelocity_Active := 2;
  END_IF
END_IF