Function Block Generator

Generated logic is an engineering aid. Verify all logic, fail-safe behaviour and safety requirements before production use. This tool is not a functional safety certification tool.

Block

Direct-on-line style motor control: start/stop latch, ready/fault, local/remote, feedback monitoring, modes and statistics.

Portable IEC 61131-3 text with (* *) comments. Adapt library names (TON, R_TRIG) and retain handling to your environment.

Inputs

Options

Start timeout, sdefault value of the TIME input

Outputs

FB_Motor.st

1(*
2 FB_Motor - Motor control
3 Generated by ASUTP Hub (template: Motor).
4 Target: Generic IEC 61131-3 Structured Text.
5 Engineering aid: verify logic, fail-safe behaviour and safety requirements before production use.
6 Stop is dominant over Start. Alarms latch and are cleared by Reset when the cause is gone.
7*)
8FUNCTION_BLOCK FB_Motor
9VAR_INPUT
10 Start : BOOL; (* Start command (rising edge) *)
11 Stop : BOOL; (* Stop command, TRUE = stop (dominant) *)
12 Reset : BOOL; (* Acknowledge latched alarms *)
13 Ready : BOOL; (* Drive / MCC ready *)
14 Fault : BOOL; (* External fault, TRUE = fault *)
15 Feedback : BOOL; (* Running feedback *)
16 StartTimeout : TIME := T#10S; (* Max. time from RunCmd to feedback *)
17END_VAR
18VAR_OUTPUT
19 RunCmd : BOOL; (* Command to contactor / drive *)
20 Running : BOOL; (* Motor running *)
21 Alarm : BOOL; (* Any latched alarm active *)
22 ReadyToStart : BOOL; (* All start conditions fulfilled *)
23 ExternalFault : BOOL; (* Latched external fault *)
24 FailToStart : BOOL; (* Latched: no feedback within StartTimeout *)
25END_VAR
26VAR
27 rtStart : R_TRIG; (* Start edge detection *)
28 RunLatch : BOOL; (* Latched manual run request *)
29 RunRequest : BOOL; (* Resulting run request *)
30 ControlAllowed : BOOL; (* Control location permits remote control *)
31 tonStart : TON; (* Start supervision timer *)
32END_VAR
33
34 (* ---- Control location ---- *)
35 ControlAllowed := TRUE; (* no local/remote selection configured *)
36
37 (* ---- Alarms (set-dominant latches, cleared by Reset when the cause is gone) ---- *)
38 (* Timers use RunCmd from the previous scan. *)
39 ExternalFault := Fault OR (ExternalFault AND NOT Reset);
40 tonStart(IN := RunCmd AND NOT Feedback, PT := StartTimeout);
41 FailToStart := tonStart.Q OR (FailToStart AND NOT Reset);
42 Alarm := ExternalFault OR FailToStart;
43
44 (* ---- Start conditions ---- *)
45 ReadyToStart := ControlAllowed AND NOT Alarm AND Ready;
46
47 (* ---- Run request ---- *)
48 rtStart(CLK := Start);
49 RunLatch := (rtStart.Q OR RunLatch) AND NOT Stop AND ReadyToStart;
50 RunRequest := RunLatch;
51
52 (* ---- Outputs ---- *)
53 RunCmd := RunRequest AND ReadyToStart;
54 Running := Feedback;
55
56END_FUNCTION_BLOCK
57

Generated code comments are in English (ASCII) for compatibility with PLC editors.

Related