Programming Main Sequence
Modification Notation
It is recommended, that any modifications made to any of the
programming should be clearly recorded and commented within the project. This
allows for programmers to quickly revert back to known working code as well as
contact any programmers regarding any questions they may have regarding the
code that has been added. It also allows asset owners to contact the Service
Providers if any future changes are required.
[YYYYMMDD] [Initial].[Last Name] [Company] [Description of Change]
Input Section
The following section is for mapping inputs into working
variables. This assists with system upgrades, by reducing the number of points
which need to be modified when a PLC is changed. It also helps when upgrading a
system by allowing the programmer to easily switch the output from existing
code to the new code. If inputs are not programmed in a way which allows for
greater flexibility, it can present serious issues for programmers conducting
live changes to existing and running systems.
It is also recommended that the inputs which are directly associated
with that programming (module), be retained within the same module, unless it
is used in others. At which point the input should be programmed into a common mapping
module. The reason behind this is, if a System is going to be worked on, all
the associated inputs are within the same logical area. This helps with any
work being conducted post commissioning by programmers, who are unfamiliar with
the system.
==== INPUTS ==== SECTION DESCRIPTION: The following section is for programming all inputs specific for the control of this program module. Any inputs which are used in multiple modules will be listed within the common input mapping module.
Scaling Inputs
HMI Input Filtering
Default Parameter Restoration Section
The following section is for listing all critical default user defined variables. The purpose behind this code is to provide a working benchmark for programmers, if there are any doubts regarding the suitability of settings. Typically, once the System / Assembly has been commissioned, the settings, which have been proven to work, are loaded into this section. It is also possible to have the ‘System Default Reset Flag’ linked to an HMI which allows operators to switch back to a known working state, allowing them to self-recover if they have made an error entering a wrong value into the HMI.
==== DEFAULT SETTINGS ====
SECTION DESCRIPTION: The following section is for resetting user defined variables back to known working values. It is highly recommended that these values are updated at the completion of final commissioning.
General Operation Section
This section is primarily for any function which exists outside of the sequence. In other words, any function which is required to operate regardless of the Sequencing Stage.
==== GENERAL OPERATIONS ====
SECTION DESCRIPTION: The following section is for any operation which is required to be process regardless of the Sequence Stage.
Auto Run Function
Fault Section
Like the ‘General Operation Section’ this section is
dedicated for all fault monitoring. This section of programming will be processed
on each cycle. Any conditions, which should result in a positively switched variable,
is then picked up in the Sequence Stages.
==== FAULT MANAGEMENT ====
SECTION DESCRIPTION: The following section is for monitoring fault condition. Any faults detected are linked to a flag variable which is then programmed into the Sequence Stage.
Low Level Monitoring (with Nuisance Protection)
Low Level Monitoring (with Nuisance Protection)
Range Monitoring (with Nuisance Protection)
High Level Monitoring (with Nuisance Protection)
Contactor Monitoring (with Nuisance Protection)
Fault Signalling
PID Section
Sequence Section
As
discussed previously, the sequencing section is a step-by-step process. As the
system progresses through its operational phases, the PLC jumps from one
Sequence Stage to another. This allows for greater flexibility with future modifications
and allows for greater control when working on a live system.

STANDBY (Index: 0000)
==== SEQUENCING [STANDBY] ====
SECTION DESCRIPTION: The following section for having the System placed in an ‘idle’ type state. Typically, there should be Outputs engaged during this state.
if(Module_indexer == 0){
if(Operator_Attention_Trigger == true){Module_Indexer = 9800;}
if(System_Fault_Trigger == true){Module_Indexer = 9900;}
if(Emergency_Trip_Trigger == true){Module_Indexer = 9999;}
if(Next_Stage_Trigger == true){Module_Indexer = 1000;}
if(System_Fault_Trigger == true){Module_Indexer = 9900;}
}
RUNG DESCRIPTION: The following rung is for detecting the Stage Index value and setting a Stage Flag for the remaining rungs.

RUNG DESCRIPTION: The following rung is for setting a One Shot Bit, which may be required by certain functions like Timers, Latching Outputs and so forth.

RUNG DESCRIPTION: The following rung is for setting up Timers within the Stage. These are typically required for (although not restricted to) automatically skipping to the next Stage.

RUNG DESCRIPTION: The following rung is used for skipping to the Emergency Stage, if the Emergency Flag (the emergency input(s)) are triggered.
IMPORTANT: This is not a replacement for a certified Emergency Stop system.

RUNG DESCRIPTION: The following rung is used for skipping to the Equipment Fault Stage, if any of the Equipment Fault Flags are triggered.

RUNG DESCRIPTION: The following rung is for setting the speed and or state of an output.

RUNG DESCRIPTION: The following rung is for starting the System Sequence.

STARTING (Index: 1000)
==== SEQUENCING [STARTING] ====
SECTION DESCRIPTION: The following section is typically for completing System / Assembly Pre-Start Checks and or energizing supplies.
if(Module_indexer == 1000){
if(Next_Stage_Trigger == true){Module_Indexer = 2000;}
if(Operator_Attention_Trigger == true){Module_Indexer = 9800;}
if(System_Fault_Trigger == true){Module_Indexer = 9900;}
if(Emergency_Trip_Trigger == true){Module_Indexer = 9999;}
}
RUNG DESCRIPTION: The following rung is for detecting the Stage Index value and setting a Stage Flag for the remaining rungs.

RUNG DESCRIPTION: The following rung is for setting a One Shot Bit, which may be required by certain functions like Timers, Latching Outputs and so forth.

RUNG DESCRIPTION: The following rung is for setting up Timers within the Stage. These are typically required for (although not restricted to) automatically skipping to the next Stage.

RUNG DESCRIPTION: The following rung is used for skipping to the Emergency Stage, if the Emergency Flag (the emergency input(s)) are triggered.
IMPORTANT: This is not a replacement for a certified Emergency Stop system.

RUNG DESCRIPTION: The following rung is used for skipping to the Equipment Fault Stage, if any of the Equipment Fault Flags are triggered.

RUNG DESCRIPTION: The following rung is for progressing to the Quick Stop Stage.

RUNG DESCRIPTION: The following rung is for progressing to the Normal Stop Stage.

RUNG DESCRIPTION: The following rung is for progressing to the next stage. This can be triggered by an input, timer and or bypass (skipping).

STARTED (Index: 2000)
==== SEQUENCING [STARTED] ====
SECTION DESCRIPTION: The following section is typically for completing System / Assembly Post-Start Checks.
if(Module_indexer == 2000){
if(Next_Stage_Trigger == true){Module_Indexer = 3000;}
if(Operator_Attention_Trigger == true){Module_Indexer = 9800;}
if(System_Fault_Trigger == true){Module_Indexer = 9900;}
if(Emergency_Trip_Trigger == true){Module_Indexer = 9999;}
}
RUNG DESCRIPTION: The following rung is for detecting the Stage Index value and setting a Stage Flag for the remaining rungs.

RUNG DESCRIPTION: The following rung is for setting a One Shot Bit, which may be required by certain functions like Timers, Latching Outputs and so forth.

RUNG DESCRIPTION: The following rung is for setting up Timers within the Stage. These are typically required for (although not restricted to) automatically skipping to the next Stage.

RUNG DESCRIPTION: The following rung is used for skipping to the Emergency Stage, if the Emergency Flag (the emergency input(s)) are triggered.
IMPORTANT: This is not a replacement for a certified Emergency Stop system.

RUNG DESCRIPTION: The following rung is used for skipping to the Equipment Fault Stage, if any of the Equipment Fault Flags are triggered.

RUNG DESCRIPTION: The following rung is for progressing to the Quick Stop Stage.

RUNG DESCRIPTION: The following rung is for progressing to the Normal Stop Stage.

RUNG DESCRIPTION: The following rung is for progressing to the next stage. This can be triggered by an input, timer and or bypass (skipping).

WARM-UP (Index: 3000)
==== SEQUENCING [WARM-UP] ====
SECTION DESCRIPTION: The following section is for Warming-Up Equipment and or Charging Fluid Lines.
if(Module_indexer == 3000){
if(Timer_Indexer >= Timer_Setpoint){
Timer_Indexer = 0;
Module_Indexer = 4000;
}else{
Timer_Indexer = Timer_Indexer + 1;
}
if(Next_Stage_Trigger == true){Module_Indexer = 4000;}
if(Operator_Attention_Trigger == true){Module_Indexer = 9800;}
if(System_Fault_Trigger == true){Module_Indexer = 9900;}
if(Emergency_Trip_Trigger == true){Module_Indexer = 9999;}
}
RUNG DESCRIPTION: The following rung is for detecting the Stage Index value and setting a Stage Flag for the remaining rungs.

RUNG DESCRIPTION: The following rung is for setting a One Shot Bit, which may be required by certain functions like Timers, Latching Outputs and so forth.

RUNG DESCRIPTION: The following rung is for setting up Timers within the Stage. These are typically required for (although not restricted to) automatically skipping to the next Stage.

RUNG DESCRIPTION: The following rung is used for skipping to the Emergency Stage, if the Emergency Flag (the emergency input(s)) are triggered.
IMPORTANT: This is not a replacement for a certified Emergency Stop system.

RUNG DESCRIPTION: The following rung is used for skipping to the Equipment Fault Stage, if any of the Equipment Fault Flags are triggered.

RUNG DESCRIPTION: The following rung is for progressing to the Quick Stop Stage.

RUNG DESCRIPTION: The following rung is for progressing to the Normal Stop Stage.

RUNG DESCRIPTION: The following rung is for setting the speed and or state of an output.

RUNG DESCRIPTION: The following rung is for progressing to the next stage. This can be triggered by an input, timer and or bypass (skipping).

RUNNING ► INITIAL (Index: 4000)
==== SEQUENCING [RUNNING - INITIAL] ====
SECTION DESCRIPTION: The following section is for checking which Mode the Sequence needs to be switch to. This typically falls within Manual and Auto (although not limited).
if(Module_indexer == 4000){
if(Manual_Stage_Trigger == true){Module_Indexer = 5000;}
if(Warmdown_Stage_Trigger == true){Module_Indexer = 7000;}
if(Manual_Stage_Trigger == true){Module_Indexer = 5000;}
if(Auto_Stage_Trigger == true){Module_Indexer = 6000;}
if(Operator_Attention_Trigger == true){Module_Indexer = 9800;}
if(System_Fault_Trigger == true){Module_Indexer = 9900;}
if(Emergency_Trip_Trigger == true){Module_Indexer = 9999;}
}
RUNG DESCRIPTION: The following rung is for detecting the Stage Index value and setting a Stage Flag for the remaining rungs.

RUNG DESCRIPTION: The following rung is for setting a One Shot Bit, which may be required by certain functions like Timers, Latching Outputs and so forth.

RUNG DESCRIPTION: The following rung is for setting up Timers within the Stage. These are typically required for (although not restricted to) automatically skipping to the next Stage.

RUNG DESCRIPTION: The following rung is used for skipping to the Emergency Stage, if the Emergency Flag (the emergency input(s)) are triggered.
IMPORTANT: This is not a replacement for a certified Emergency Stop system.

RUNG DESCRIPTION: The following rung is used for skipping to the Equipment Fault Stage, if any of the Equipment Fault Flags are triggered.

RUNG DESCRIPTION: The following rung is for progressing to the Quick Stop Stage.

RUNG DESCRIPTION: The following rung is for progressing to the Normal Stop Stage.

RUNG DESCRIPTION: The following rung if for progressing to the Run – MANUAL Stage using a Mode Indexing variable.

RUNG DESCRIPTION: The following rung if for progressing to the Run – AUTO Stage using a Mode Indexing variable.

RUNG DESCRIPTION: The following rung is for progressing to the next stage. This can be triggered by an input, timer and or bypass (skipping).

RUNNING ► MANUAL (Index: 5000)
==== SEQUENCING [RUNNING - MANUAL] ====
SECTION DESCRIPTION: The following section is for running the System in Manual Mode.
if(Module_indexer == 5000){
if(Warmdown_Stage_Trigger == true){Module_Indexer = 7000;}
if(Auto_Stage_Trigger == true){Module_Indexer = 4000;}
if(Operator_Attention_Trigger == true){Module_Indexer = 9800;}
if(System_Fault_Trigger == true){Module_Indexer = 9900;}
if(Emergency_Trip_Trigger == true){Module_Indexer = 9999;}
}
RUNG DESCRIPTION: The following rung is for detecting the Stage Index value and setting a Stage Flag for the remaining rungs.

RUNG DESCRIPTION: The following rung is for setting a One Shot Bit, which may be required by certain functions like Timers, Latching Outputs and so forth.

RUNG DESCRIPTION: The following rung is for setting up Timers within the Stage. These are typically required for (although not restricted to) automatically skipping to the next Stage.

RUNG DESCRIPTION: The following rung is used for skipping to the Emergency Stage, if the Emergency Flag (the emergency input(s)) are triggered.
IMPORTANT: This is not a replacement for a certified Emergency Stop system.

RUNG DESCRIPTION: The following rung is used for skipping to the Equipment Fault Stage, if any of the Equipment Fault Flags are triggered.

RUNG DESCRIPTION: The following rung is for progressing to the Quick Stop Stage.

RUNG DESCRIPTION: The following rung is for progressing to the Normal Stop Stage.

RUNG DESCRIPTION: The following rung is for detecting that the mode has been changed and progressing back to the Run Initial Stage.

RUNG DESCRIPTION: The following rung is for setting the speed and or state of an output.

RUNG DESCRIPTION: The following rung is for progressing to the next stage. This can be triggered by an input, timer and or bypass (skipping).

RUNNING ► AUTO (Index: 6000)
==== SEQUENCING [RUNNING - AUTO] ====
SECTION DESCRIPTION: The following section is for running the System in Auto Mode.
if(Module_indexer == 6000){
if(Warmdown_Stage_Trigger == true){Module_Indexer = 7000;}
if(Manual_Stage_Trigger == true){Module_Indexer = 4000;}
if(Operator_Attention_Trigger == true){Module_Indexer = 9800;}
if(System_Fault_Trigger == true){Module_Indexer = 9900;}
if(Emergency_Trip_Trigger == true){Module_Indexer = 9999;}
}
RUNG DESCRIPTION: The following rung is for detecting the Stage Index value and setting a Stage Flag for the remaining rungs.

RUNG DESCRIPTION: The following rung is for setting a One Shot Bit, which may be required by certain functions like Timers, Latching Outputs and so forth.

RUNG DESCRIPTION: The following rung is for setting up Timers within the Stage. These are typically required for (although not restricted to) automatically skipping to the next Stage.

RUNG DESCRIPTION: The following rung is used for skipping to the Emergency Stage, if the Emergency Flag (the emergency input(s)) are triggered.
IMPORTANT: This is not a replacement for a certified Emergency Stop system.

RUNG DESCRIPTION: The following rung is used for skipping to the Equipment Fault Stage, if any of the Equipment Fault Flags are triggered.

RUNG DESCRIPTION: The following rung is for progressing to the Quick Stop Stage.

RUNG DESCRIPTION: The following rung is for progressing to the Normal Stop Stage.

RUNG DESCRIPTION: The following rung is for detecting that the mode has been changed and progressing back to the Run Initial Stage.

RUNG DESCRIPTION: The following rung is for setting the speed and or state of an output.

RUNG DESCRIPTION: The following rung is for progressing to the next stage. This can be triggered by an input, timer and or bypass (skipping).

WARM-DOWN (Index: 7000)
==== SEQUENCING [WARM-DOWN] ====
SECTION DESCRIPTION: The following section is for allowing system components to cool down under controlled measures.
if(Module_indexer == 7000){
if(Timer_Indexer >= Timer_Setpoint){
Timer_Indexer = 0;
Module_Indexer = 8000;
}else{
Timer_Indexer = Timer_Indexer + 1;
}
if(Next_Stage_Trigger == true){Module_Indexer = 8000;}
if(Operator_Attention_Trigger == true){Module_Indexer = 9800;}
if(System_Fault_Trigger == true){Module_Indexer = 9900;}
if(Emergency_Trip_Trigger == true){Module_Indexer = 9999;}
}
RUNG DESCRIPTION: The following rung is for detecting the Stage Index value and setting a Stage Flag for the remaining rungs.

RUNG DESCRIPTION: The following rung is for setting a One Shot Bit, which may be required by certain functions like Timers, Latching Outputs and so forth.

RUNG DESCRIPTION: The following rung is for setting up Timers within the Stage. These are typically required for (although not restricted to) automatically skipping to the next Stage.

RUNG DESCRIPTION: The following rung is used for skipping to the Emergency Stage, if the Emergency Flag (the emergency input(s)) are triggered.
IMPORTANT: This is not a replacement for a certified Emergency Stop system.

RUNG DESCRIPTION: The following rung is used for skipping to the Equipment Fault Stage, if any of the Equipment Fault Flags are triggered.

RUNG DESCRIPTION: The following rung is for progressing to the Quick Stop Stage.

RUNG DESCRIPTION: The following rung is for progressing to the Normal Stop Stage.

RUNG DESCRIPTION: The following rung is for setting the speed and or state of an output.

RUNG DESCRIPTION: The following rung is for progressing to the next stage. This can be triggered by an input, timer and or bypass (skipping).

STOPPING (Index: 8000)
==== SEQUENCING [STOPPING] ====
SECTION DESCRIPTION: The following section is typically for completing System / Assembly Post Run Checks and or de-energizing supplies.
if(Module_indexer == 8000){
if(Next_Stage_Trigger == true){Module_Indexer = 9000;}
if(Operator_Attention_Trigger == true){Module_Indexer = 9800;}
if(System_Fault_Trigger == true){Module_Indexer = 9900;}
if(Emergency_Trip_Trigger == true){Module_Indexer = 9999;}
if(Operator_Attention_Trigger == true){Module_Indexer = 9800;}
if(System_Fault_Trigger == true){Module_Indexer = 9900;}
}
RUNG DESCRIPTION: The following rung is for detecting the Stage Index value and setting a Stage Flag for the remaining rungs.

RUNG DESCRIPTION: The following rung is for setting a One Shot Bit, which may be required by certain functions like Timers, Latching Outputs and so forth.

RUNG DESCRIPTION: The following rung is for setting up Timers within the Stage. These are typically required for (although not restricted to) automatically skipping to the next Stage.

RUNG DESCRIPTION: The following rung is used for skipping to the Emergency Stage, if the Emergency Flag (the emergency input(s)) are triggered.
IMPORTANT: This is not a replacement for a certified Emergency Stop system.

RUNG DESCRIPTION: The following rung is used for skipping to the Equipment Fault Stage, if any of the Equipment Fault Flags are triggered.

RUNG DESCRIPTION: The following rung is for setting the speed and or state of an output.

RUNG DESCRIPTION: The following rung is for progressing to the next stage. This can be triggered by an input, timer and or bypass (skipping).

STOPPED (Index: 9000)
==== SEQUENCING [STOPPED] ====
SECTION DESCRIPTION: The following section is typically for completing System / Assembly Post-Stopped Checks.
if(Module_indexer == 9000){
if(Next_Stage_Trigger == true){Module_Indexer = 0;}
if(Operator_Attention_Trigger == true){Module_Indexer = 9800;}
if(System_Fault_Trigger == true){Module_Indexer = 9900;}
if(Emergency_Trip_Trigger == true){Module_Indexer = 9999;}
}
RUNG DESCRIPTION: The following rung is for detecting the Stage Index value and setting a Stage Flag for the remaining rungs.

RUNG DESCRIPTION: The following rung is for setting a One Shot Bit, which may be required by certain functions like Timers, Latching Outputs and so forth.

RUNG DESCRIPTION: The following rung is for setting up Timers within the Stage. These are typically required for (although not restricted to) automatically skipping to the next Stage.

RUNG DESCRIPTION: The following rung is used for skipping to the Emergency Stage, if the Emergency Flag (the emergency input(s)) are triggered.
IMPORTANT: This is not a replacement for a certified Emergency Stop system.

RUNG DESCRIPTION: The following rung is used for skipping to the Equipment Fault Stage, if any of the Equipment Fault Flags are triggered.

RUNG DESCRIPTION: The following rung is for progressing to the next stage. This can be triggered by an input, timer and or bypass (skipping).

OPERATOR ATTENTION (Index: 9800)
==== SEQUENCING [OPERATOR ATTENTION] ====
SECTION DESCRIPTION: The following section is typically used for notifying the operators of tasks which need to be completed before further operation.
RUNG DESCRIPTION: The following rung is for detecting the Stage Index value and setting a Stage Flag for the remaining rungs.

RUNG DESCRIPTION: The following rung is for setting a One Shot Bit, which may be required by certain functions like Timers, Latching Outputs and so forth.

RUNG DESCRIPTION: The following rung is for setting up Timers within the Stage. These are typically required for (although not restricted to) automatically skipping to the next Stage.

RUNG DESCRIPTION: The following rung is used for skipping to the Emergency Stage, if the Emergency Flag (the emergency input(s)) are triggered.
IMPORTANT: This is not a replacement for a certified Emergency Stop system.

RUNG DESCRIPTION: The following rung is used for skipping to the Equipment Fault Stage, if any of the Equipment Fault Flags are triggered.

RUNG DESCRIPTION: The following rung is for progressing to the next stage. This can be triggered by an input, timer and or bypass (skipping).

SYSTEM FAULT (Index: 9900)
==== SEQUENCING [SYSTEM FAULT] ====
SECTION DESCRIPTION: The following section is typically used for shutting equipment down and informing the operator / maintenance of System / Assembly faults.
RUNG DESCRIPTION: The following rung is for detecting the Stage Index value and setting a Stage Flag for the remaining rungs.

RUNG DESCRIPTION: The following rung is for setting a One Shot Bit, which may be required by certain functions like Timers, Latching Outputs and so forth.

RUNG DESCRIPTION: The following rung is for setting up Timers within the Stage. These are typically required for (although not restricted to) automatically skipping to the next Stage.

RUNG DESCRIPTION: The following rung is used for skipping to the Emergency Stage, if the Emergency Flag (the emergency input(s)) are triggered.
IMPORTANT: This is not a replacement for a certified Emergency Stop system.

RUNG DESCRIPTION: The following rung is for progressing to the next stage. This can be triggered by an input, timer and or bypass (skipping).

EMERGENCY STOP (Index: 9999)
/// READ THE FOLLOWING MESSAGE ////
The following is NOT a replacement for a certified safety system. The key difference between a standard Programmable Logic Controller (PLC) and that of a safety system is the difference in measurable certainty. A safety system is designed to respond when required to. If you use a standard PLC for a safety system - you risk the system not operating when required. A safety system can be a simple of using Safety Relays or complicated using Safety PLCs. Regardless of the complexity - Safety Systems need to be correctly Risk Assessed and have to appropriate Control Measures put in place. The following section is for the purpose programming a PLC of a standard control system responding to a Emergency Stop triggering (for example: having the Human Machine Interface (HMI) displaying that the Emergency System being triggered). This site does not provide any information with respect to Safety System design and certifications.
/// READ THE FOLLOWING MESSAGE ////
==== SEQUENCING [EMERGENCY STOP] ====
SECTION DESCRIPTION: The following section is typically used for shutting equipment down and informing the operator / maintenance of System / Assembly Emergency Stop(s).
RUNG DESCRIPTION: The following rung is for detecting the Stage Index value and setting a Stage Flag for the remaining rungs.

RUNG DESCRIPTION: The following rung is for setting a One Shot Bit, which may be required by certain functions like Timers, Latching Outputs and so forth.

RUNG DESCRIPTION: The following rung is for setting up Timers within the Stage. These are typically required for (although not restricted to) automatically skipping to the next Stage.

RUNG DESCRIPTION: The following rung is for setting the speed and or state of an output.

RUNG DESCRIPTION: The following rung is for progressing to the next stage. This can be triggered by an input, timer and or bypass (skipping).

Outputs Section
The output section is somewhat like the inputs section, however, focuses only on mapping Output variables with working variables. Please refer to the Input Section for further information.
==== OUTPUTS ====
SECTION DESCRIPTION: The following section is for programming all outputs specific for the control of this program module. Any communal outputs should be included in a separate Input Module.