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 control3 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_Motor9VAR_INPUT10 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_VAR18VAR_OUTPUT19 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_VAR26VAR27 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_VAR3334 (* ---- Control location ---- *)35 ControlAllowed := TRUE; (* no local/remote selection configured *)3637 (* ---- 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;4344 (* ---- Start conditions ---- *)45 ReadyToStart := ControlAllowed AND NOT Alarm AND Ready;4647 (* ---- Run request ---- *)48 rtStart(CLK := Start);49 RunLatch := (rtStart.Q OR RunLatch) AND NOT Stop AND ReadyToStart;50 RunRequest := RunLatch;5152 (* ---- Outputs ---- *)53 RunCmd := RunRequest AND ReadyToStart;54 Running := Feedback;5556END_FUNCTION_BLOCK57
Generated code comments are in English (ASCII) for compatibility with PLC editors.