FUNCTION_BLOCK FB_MotorControl VAR_INPUT Startknop: BOOL; Stopknop: BOOL; Overbelastingsignaal: BOOL; END_VAR VAR_OUTPUT RunningStatus: BOOL; FaultIndicator: BOOL;END_VAR BEGIN // Start-Stop logica IF Startknop EN NIET Stopknop EN NIET overbelast Signal THEN RunningStatus := TRUE; ELSIF StopButton OR OverloadSignal THEN RunningStatus := FALSE; END_IF; // Foutindicatie FaultIndicator := OverloadSignal; END_FUNCTION_BLOCK
S.C.L.
Geval 3: PID-temperatuurregeling
FUNCTION_BLOCK FB_TempControl VAR_INPUT Setpoint: REAL; ProcessValue: REAL; END_VAR VAR_OUTPUT ControlOutput: REAL; END_VAR VAR Kp: REAL := 2.0; Ki: REAL := 0.05; Kd: REAL := 0.5; IntegralTerm: REAL := 0; LastError: REAL := 0; Timer: TON; END_VAR BEGIN // Uitvoeren periodiek (100ms) Timer(IN := NIET Timer.Q, PT := T#100ms); IF Timer.Q THEN VAR Error := Instellingspunt - Proceswaarde; IntegralTerm := IntegralTerm + Error; VAR DerivativeTerm := Error - LastError; LastError := Error; ControlOutput := Kp * Error + Ki * IntegralTerm + Kd * DerivativeTerm; ControlOutput := LIMIT(0.0, ControlOutput, 100.0); Timer ((IN := FALSE); END_IF; END_FUNCTION_BLOCK
S.C.L.
Geval 5: Vergrendeling van de veiligheidspoort
FUNCTION_BLOCK FB_SafetyGate VAR_INPUT Gate1Closed, Gate2Closed: BOOL; EStopButton: BOOL; ResetButton: BOOL; END_VAR VAR_OUTPUT SafetyStatus: BOOL; END_VAR VAR LockoutStatus: BOOL= FALSE:LockoutTimer: TON; END_VAR BEGIN // Veiligheidsvoorwaarde VAR AllGatesClosed := Gate1Closed AND Gate2Closed; // Noodstop hoogste prioriteit IF EStopButton THEN SafetyStatus := FALSE; LockoutStatus := TRUE;LockoutTimer ((IN := TRUE, PT := T#10S); RETURN; END_IF; // Unlock logic IF ResetButton AND LockoutStatus AND LockoutTimer.Q THEN LockoutStatus := FALSE; END_IF;// Normale werking indien NIET LockoutStatus DAN SafetyStatus := AllGatesClosed; END_IF;