ℹ️ Select 'Choose Exercise', or randomize 'Next Random Exercise' in selected language.

Choose Exercise:
Timer 00:00
WPM --
Score --
Acc --
Correct chars --

Motor Start/Stop with Safety Interlock and Mode Selection

PLC Ladder Diagram (LD)

Goal -- WPM

Ready
Exercise Algorithm Area
1PROGRAM MotorControlMode
2
3VAR
4StartButton : BOOL; // Manual start button
5StopButton : BOOL; // Manual stop button
6StartSignal : BOOL; // Automatic start signal
7StopSignal : BOOL; // Automatic stop signal
8SafetyInterlock : BOOL;
9ModeSelector : INT; // 0 for Manual, 1 for Automatic
10MotorRunning : BOOL;
11ManualModeActive : BOOL;
12AutomaticModeActive : BOOL;
13END_VAR
14
15// Determine current mode
16ManualModeActive := ModeSelector = 0;
17AutomaticModeActive := ModeSelector = 1;
18
19// Logic for starting the motor
20VAR
21ManualStartCondition : BOOL;
22AutoStartCondition : BOOL;
23END_VAR
24
25ManualStartCondition := (StartButton OR MotorRunning) AND NOT StopButton;
26AutoStartCondition := StartSignal;
27
28// Stop condition for the motor
29VAR
30StopCondition : BOOL;
31END_VAR
32
33StopCondition := StopButton OR StopSignal OR NOT SafetyInterlock;
34
35// Control logic for MotorRunning
36IF ManualModeActive THEN
37IF ManualStartCondition AND NOT StopCondition THEN
38MotorRunning := TRUE;
39ELSIF StopCondition THEN
40MotorRunning := FALSE;
41END_IF
42ELSIF AutomaticModeActive THEN
43IF AutoStartCondition AND NOT StopCondition THEN
44MotorRunning := TRUE;
45ELSIF StopCondition THEN
46MotorRunning := FALSE;
47END_IF
48ELSE
49// If mode is invalid, ensure motor is stopped
50MotorRunning := FALSE;
51END_IF
52
53// Edge case: If SafetyInterlock is lost, stop motor immediately regardless of mode or button state
54IF NOT SafetyInterlock THEN
55MotorRunning := FALSE;
56END_IF
57
58// Output signal to the motor contactor
59// MotorRunning is the direct output
60
61END_PROGRAM
Algorithm description viewbox

Motor Start/Stop with Safety Interlock and Mode Selection

Algorithm description:

This Ladder Diagram program controls a motor with different operational modes (Manual and Automatic) and a critical safety interlock. In Manual mode, a physical start/stop button pair controls the motor. In Automatic mode, external start/stop signals control the motor. The motor will only run if a `SafetyInterlock` is active, and will stop immediately if this interlock is lost. This system is used in applications where operational flexibility is needed, but safety is paramount, such as in manufacturing equipment or process control systems.

Algorithm explanation:

The algorithm first determines the active mode (`ManualModeActive` or `AutomaticModeActive`) based on the `ModeSelector` input. It then defines the conditions for starting and stopping the motor separately for each mode. The `ManualStartCondition` includes a seal-in logic (`MotorRunning`) and is gated by the `StopButton`. The `AutoStartCondition` is simply the `StartSignal`. The `StopCondition` is a composite of manual stop, automatic stop, and crucially, the negation of the `SafetyInterlock`. The `MotorRunning` variable is updated based on the active mode and the respective start/stop conditions. A critical edge case ensures that if `SafetyInterlock` becomes FALSE, `MotorRunning` is immediately set to FALSE, overriding any other logic. The space complexity is O(1) due to a fixed number of variables. The time complexity is O(1) as it involves a fixed number of logical operations executed once per scan cycle.

Pseudocode:

Initialize StartButton, StopButton, StartSignal, StopSignal, SafetyInterlock, MotorRunning to FALSE.
Set ModeSelector (e.g., 0 for Manual, 1 for Automatic).

Loop indefinitely:
  If ModeSelector is 0 (Manual):
    If (StartButton OR MotorRunning) AND NOT StopButton AND SafetyInterlock:
      Set MotorRunning to TRUE.
    Else If StopButton OR NOT SafetyInterlock:
      Set MotorRunning to FALSE.
    End If.
  Else If ModeSelector is 1 (Automatic):
    If StartSignal AND NOT StopSignal AND SafetyInterlock:
      Set MotorRunning to TRUE.
    Else If StopSignal OR NOT SafetyInterlock:
      Set MotorRunning to FALSE;
    End If.
  Else:
    Set MotorRunning to FALSE.
  End If.

  If SafetyInterlock is FALSE:
    Set MotorRunning to FALSE.
  End If.

  Output MotorRunning.