Você está na página 1de 150

Programming of Sequential System in Ladder Diagram Language - ScienceDirect

https://www.sciencedirect.com/science/article/pii/S1474667017337114

Wcislik Miroslaw, PROGRAMMING OF SEQUENTIAL SYSTEM IN LADDER DIAGRAM LANGUAGE.

Fonte: PLC Sequencer Logic - Ladder Logic World - https://ladderlogicworld.com/plc-sequencer-logic/

PLC Sequencer Logic - Ladder Logic World - https://ladderlogicworld.com/plc-sequencer-logic/

Trecho 1
PLC Sequencer Logic
PLC sequencer logic is an essential component to have in your quiver of ladder logic sample code.It forms the backbone to the
majority of processes for industrial automation. Applications that require sequencer logic include conveyor systems, palletizing
machines, batching plants, packaging machines, storage and retrieval systems and the list goes on and on.

Lógica do Sequenciador PLC


A lógica do sequenciador PLC é um componente essencial para ter em seu quiver de código de exemplo de lógica ladder. Ele forma
a espinha dorsal da maioria dos processos de automação industrial. As aplicações que exigem lógica sequenciadora incluem
sistemas de transporte, máquinas de paletização, plantas de loteamento, máquinas de embalagem, sistemas de armazenamento e
recuperação e a lista continua.

Trecho 2
A sequence in industrial automation is merely a series of actions required to be taken to achieve a specific outcome
arranged in an orderly fashion.

The basis to develop a sequence in ladder logic is to use sequence steps.

It’s a good idea to declare the sequence steps as internal variables, which in turn can be used multiple times in the
program if required.

Uma sequência na automação industrial é apenas uma série de ações necessárias a serem tomadas para alcançar um
resultado específico organizado de forma ordenada.

A base para desenvolver uma sequência na lógica ladder é usar passos de sequência.

É uma boa ideia declarar as etapas de sequência como variáveis internas, que por sua vez podem ser usadas várias
vezes no programa, se necessário.

Trecho 3
To illustrate how sequence steps are derived for PLC Sequencer Logic let’s look at the sequence of events required for a common
household task, brushing your teeth….

1.Grab your toothbrush.


2.Grab your toothpaste.
3.Put some toothpaste on the toothbrush.
4.Put the toothbrush in your mouth.
5.Brush your teeth with the toothbrush for two minutes.
6.Remove the toothbrush from your mouth.
7.Rinse your mouth out with water.
8.Rinse your toothbrush with water.
9.Put your toothbrush away.

Para ilustrar como as etapas de sequência são derivadas para o PLC Sequencer Logic, vamos examinar a sequência de
eventos necessários para uma tarefa doméstica comum, escovar os dentes....
1. Pegue sua escova de dentes.
2. Pegue sua pasta de dente.
3. Coloque um pouco de pasta de dente na escova de dentes.
4. Coloque a escova de dentes na boca.
5. Escove os dentes com a escova de dentes por dois minutos.
6. Retire a escova de dentes da boca.
7. Lave a boca com água.
8. Lave a escova de dentes com água.
9. Guarde sua escova de dentes.

Trecho 4
To automate an industrial process with a sequence we use the same concept. The complexity of the sequence ladder logic program
will depend on the specific process outcomes required.

Even with the tooth brushing example above some of the steps can be broken down even further.
For example step 3 can be broken down into three steps with significantly more detail….

3a) Position the toothpaste nozzle at the far end of the toothbrush head.

Para automatizar um processo industrial com uma sequência utilizamos o mesmo conceito. A complexidade do
programa lógico de escada de sequência dependerá dos resultados específicos do processo necessários.
Mesmo com o exemplo de escovação de dentes acima, alguns dos passos podem ser divididos ainda mais.
Por exemplo, o passo 3 pode ser dividido em três passos com significativamente mais detalhes....
3a) Posicione o bocal da pasta de dentes na extremidade da cabeça da escova de dentes.

Trecho 5

Types of PLC Sequencer Logic


A sequence can either be cyclic or linear.
A cyclic sequence moves through the sequence steps and when the final step is completed the sequence automatically
restarts from the beginning and keeps repeating the sequence until a stop command is initiated.
A linear sequence moves through the sequence steps and when the final step is completed stops and sits idle until a
start command is re-issued manually by the operator.

Tipos de lógica do sequenciador PLC


Uma sequência pode ser cíclica ou linear.

Uma sequência cíclica se move pelas etapas da sequência e, quando a etapa final é concluída, a sequência é reiniciada
automaticamente desde o início e continua repetindo a sequência até que um comando de parada seja iniciado.

Uma sequência linear se move pelas etapas da sequência e, quando a etapa final é concluída, pára e fica ociosa até que
um comando start seja reemitido manualmente pelo operador.

Trecho 6
The 4 Essential Elements of PLC Sequencer Logic
There are various ways to structure the sequence ladder logic but as a minimum it must contain four essential items of code…..
1. Sequence start and stop.
2. The Sequence steps.
3. Sequence step transition conditions.
4. The outputs that initiate actions.

Os 4 elementos essenciais da lógica do sequenciador PLC


Existem várias maneiras de estruturar a lógica de escada de sequência, mas, no mínimo, ela deve conter quatro itens
essenciais de código.

1. Início e término da sequência.


2. As etapas de sequência.
3. Condições de transição de etapa de sequência.
4. As saídas que iniciam ações.

Trecho 7
Once we know the basic sequence ladder logic structure we can modify it to suit the process requirements. We can create multiple
sequences, parallel sequence branches and add logical expressions and timers to help control it.
The sequence start, stop and steps require latching logic using either hold in logic or Set (latch) Reset (Unlatch) symbols.

If you don’t know what hold in logic and Set/Reset symbols are then click here.

Uma vez que conhecemos a estrutura lógica básica da escada de sequência, podemos modificá-la para atender aos
requisitos do processo. Podemos criar várias sequências, ramificações de sequências paralelas e adicionar expressões
lógicas e temporizadores para ajudar a controlá-lo.

O início, a parada e as etapas da sequência exigem lógica de travamento usando a lógica de retenção ou os símbolos
Set (latch) Reset (Unlatch).

Se você não sabe o que é a lógica e os símbolos Set/Reset (Definir/Redefinir) clique aqui.

Trecho 8
PLC Sequencer Logic Example
Let’s follow on from our motor control example used earlier and define a sequence utilizing a motorized trolley.
The trolley runs forward to a certain position. Accepts a pallet of produce from an automated crane. Then reverses back to it’s starting position ready
to be unloaded by a forklift operator and put into the back of a truck for transportation.

Exemplo de lógica do PLC Sequencer


Vamos seguir nosso exemplo de controle de motor usado anteriormente e definir uma sequência utilizando um
carrinho motorizado.

O carrinho corre para a frente até uma determinada posição. Aceita uma palete de produtos de um guindaste
automatizado. Em seguida, reverte de volta à sua posição inicial pronto para ser descarregado por um operador de
empilhadeira e colocado na parte de trás de um caminhão para transporte.

Trecho 9
The motorized trolley has a limit switch for the unloading and loading positions so it can stop in the correct place.

It has a sensor to detect if there is a pallet on the trolley.

It also has a sensor to detect if the loading area is clear and is safe for the motorized trolley to start moving.

O carrinho motorizado tem um interruptor de limite para as posições de descarga e carga para que possa parar no lugar
correto.

Possui um sensor para detectar se há um palete no carrinho.

Ele também possui um sensor para detectar se a área de carga está clara e é segura para o carrinho motorizado começar
a se mover.
Trecho 10
To activate the sequence the operator decides if the trolley is unloaded and safe to run, then pushes the start push
button.
When the sequence completes a cycle it stops and waits for the operator to push the start button again. This is a linear
sequence with a start and end point.
Para ativar a sequência, o operador decide se o carrinho está descarregado e seguro para ser executado, em seguida,
pressiona o botão de inicialização.

Quando a sequência completa um ciclo, ela pára e espera que o operador pressione o botão de início novamente. Esta é
uma sequência linear com um ponto inicial e final.

Trecho 11
After the sequence is complete it must be re-initiated manually by an operator in order for the sequence to restart.

Having said that, we just as well could have chosen to do an automatic cyclic sequence. This is easily done at the last step by re-
activating the first sequence step instead of ending the sequence. We will also need to add some extra conditional logic to replace
the operators manual start operation.
Depois que a sequência for concluída, ela deve ser reiniciada manualmente por um operador para que a sequência seja
reiniciada.

Dito isto, poderíamos muito bem ter optado por fazer uma sequência cíclica automática. Isso é feito facilmente na
última etapa, reativando a primeira etapa da sequência em vez de terminar a sequência. Também precisaremos
adicionar alguma lógica condicional extra para substituir a operação de início manual do operador.

Abaixo está a lista de entradas necessárias que precisam ser declaradas .....
Em seguida, vamos declarar as saídas .....

Também precisamos declarar as seguintes variáveis internas.....

O diagrama lógico de sequência abaixo é uma sequência linear básica com três etapas que termina
após as condições de transição da terceira etapa serem atendidas.
Trecho 12
The transition conditions that enable the steps to progress to the next step and the actual
sequence steps are all declared as internal variables.
In this way we can take the conditional logic out of the sequence logic rungs to de-clutter it
and make it easily readable.
As condições de transição que permitem que as etapas progridam para a próxima etapa e as etapas de sequência reais
são todas declaradas como variáveis internas.
Desta forma, podemos tirar a lógica condicional dos degraus da lógica de sequência para desorganizá-la e torná-la
facilmente legível.

Devemos colocar a lógica condicional de transição antes da lógica de sequência para permitir que a
varredura do PLC vá de cima para baixo.

Trecho 13
Lastly we need some logic to trigger the PLC outputs to make the trolley move.

There’s no need to use additional latching logic for the motor start because we are utilizing the sequence step latching logic.

We should place logic that triggers the outputs after the sequence logic to allow for the PLC scan going from top to bottom.
Por fim, precisamos de alguma lógica para acionar as saídas do PLC para fazer o carrinho se mover.

Não há necessidade de usar lógica de travamento adicional para a partida do motor, porque estamos utilizando a lógica
de travamento de passo de sequência.
Devemos colocar a lógica que aciona as saídas após a lógica de sequência para permitir que a varredura do PLC vá
de cima para baixo.

Trecho 14
Auto and manual modes so that individual components can be operated in case of failures and maintenance.
Sequence status and indication lights and sirens.
A stopping sequence and/or emergency stop function can also be added if required.
Conditional logic that needs to be met before the sequence can be started.
Sequence pause logic to remember the last step before the sequence was stopped, so that the sequence can resume from where it left
off.
Conditional start logic that decides the step that must be triggered to resume operation.
Alarm and fault logic to capture failure of equipment.

Modos automático e manual para que componentes individuais possam ser operados em caso de falhas e manutenção.
Status da sequência e luzes de indicação e sirenes.
Uma sequência de parada e/ou função de parada de emergência também pode ser adicionada, se necessário.
Lógica condicional que precisa ser atendida antes que a sequência possa ser iniciada.
A lógica de pausa da sequência para lembrar a última etapa antes de a sequência ser interrompida, para que a
sequência possa ser retomada de onde parou.
Lógica de início condicional que decide a etapa que deve ser acionada para retomar a operação.
Lógica de alarme e falha para capturar falhas de equipamentos.

Trecho 15
It’s great using hold in logic to latch the sequence steps because all the transition and stopping conditional logic is located in the
same area.
When we encounter more complex processes then using hold in logic for our sequence steps can become difficult because we are
limited to using only one output.
Using multiple output symbols with the same variable declaration is a recipe for disaster.

É ótimo usar a lógica de retenção para travar as etapas de sequência porque toda a lógica condicional de transição e
parada está localizada na mesma área.

Quando encontramos processos mais complexos, o uso da lógica para nossas etapas de sequência pode se tornar difícil
porque estamos limitados a usar apenas uma saída.

Usar vários símbolos de saída com a mesma declaração de variável é uma receita para o desastre.

Trecho 16
We don’t want to do this because the output symbol may be overwritten inadvertently during the PLC scan causing haphazard like
behavior.

If the ladder diagram complexity is high then we can latch and unlatch sequence steps using the Set (Latch) and Reset (Unlatch)
symbols.

These symbols provide a lot more flexibility with the sequence programming, but require extra caution and expertise.

Não queremos fazer isso porque o símbolo de saída pode ser substituído inadvertidamente durante a varredura do
PLC, causando um comportamento aleatório.

Se a complexidade do diagrama de escada for alta, podemos travar e destravar etapas de sequência usando os símbolos
Set (Latch) e Reset (Unlatch).

Esses símbolos fornecem muito mais flexibilidade com a programação de sequência, mas exigem cuidado e
experiência extras.

Trecho 17
In the next section we’ll provide you with a comprehensive guide to programming ladder logic flip flop’s and toggle logic.

To go to the next section click here.


Na próxima seção, forneceremos um guia abrangente para programar flip flops de lógica de escada e lógica de
alternância.

Para ir para a próxima seção clique aqui.


Parte 2

PLC Toggle Logic & Flip Flops


PLC toggle logic emulates the function of flip flop circuits that are commonly used in
electronics and computer systems.
What is a Flip Flop in a PLC?
You may have heard of a flip flop in electronics and computer systems, but what is a flip
flop in a PLC?
A flip flop in PLC programming is created using toggle logic. Whenever the state of the
PLC input changes momentarily, the state of the PLC output will be latched to the
opposite of it’s current state. There can be either 1 or 2 inputs and outputs depending
on the type of PLC flip flop function required.
Understanding the flip flip function is the key to developing PLC toggle logic. So let’s take
a closer look at the different types of flip flops used in a PLC, how they work, how to
program them and what they can be used for.

The 3 Most Useful Types of Flip Flops in a PLC


There are several types of flip flops used in electronics and computer systems, but which
types are the most useful in a PLC?
The 3 most useful types of flip flops that can be emulated using PLC toggle logic are:
 T Flip Flop
 SR Flip Flop
 JK Flip Flop
The type of flip flop that is chosen will mainly depend on how many inputs are required to
trigger the output to toggle it’s state. If one input is required then then T flip flop type is
suited. But if 2 inputs are required then the SR flip flop or JK flip flop types are required.
Let’s look at how the electronic flip flops translate into PLC flip flops:

The T flip flop has a T input, a CLOCK input, a Q output and a NOT Q output. This type of
flip flop toggles the state of the output whenever the state of the input is TRUE and the
CLOCK input is triggered.
When the T flip flop is implemented using PLC toggle logic we use one input and generally
only one output. There is no need for a CLOCK input and a second output can be added if a
NOT output is required.
The SR flip flop has a S input, a R input, a Q output and a NOT Q output. This type of flip
flop toggles the output depending on the state of the S and R inputs.
When the SR flip flop is implemented using PLC toggle logic we use two inputs and one
output. The two inputs are called Set and Reset. A second output can be added if a NOT
output is required.

The JK flip flop has the same inputs and outputs as a SR flip flop except it has an extra
CLOCK input.
The JK flip flop operates the same way as a SR flip flop except it has bit stable operation
when both inputs are in the same state. The CLOCK input in the JK flip flop facilitates bit
stable operation by only initiating an output toggle when the CLOCK input is triggered.
When we talk about JK and SR flip flops in a PLC we refer to both of them as ladder logic
SR flip flops. The differentiation in functionality isn’t made because bit stable operation can
be achieved for the SR flip flop in a PLC without the need for the third clock input.
In fact, by virtue of our ladder logic code and the nature of the PLC scan cycle, we can
choose the state of the PLC output when both PLC inputs are the same state. In this
scenario, if we require that the output state be FALSE then we use SR flip flop toggle logic.
However, if we require that the output state be TRUE then we use a RS flip flop toggle
logic. 

How Does a PLC Flip Flop Work?


A handy piece of ladder logic programming to have in your kit is the flip flop, but do you
know how it works in a PLC?
The operation of a flip flop function in a PLC utilizes both PLC inputs and PLC
outputs. The PLC output is fed back to the input logic so that the state of the flip flop
output is dependent on both the state of the input and the current state of the output.

So when the input is triggered and the state of the output is FALSE then the output will
toggle from FALSE to TRUE. And vice versa, when the input is triggered and the state of
the output is TRUE then the output will toggle from TRUE to FALSE. Hence the use of the
term flip flop.
Let’s look at the most common types of flip flops and how they work in a PLC in a little
more detail….
How Ladder Logic T Flip Flop Works in a PLC
The ladder logic T flip flop is probably the mostly used flip flop when it comes to PLC
programming.
When used in a PLC the ladder logic T flip flop has 1 input that is used to toggle the
flip flop output every time the input changes state from FALSE to TRUE.

The operation of a ladder logic T flip flop is summarized in the truth table below:
Ladder Logic
T Flip Flop Truth Table
When the state of the PLC output is TRUE and the state of the PLC input changes from
FALSE to TRUE, the state of the PLC output will change to FALSE and be maintained.
Even if the state of the PLC input changes back to FALSE.
When the state of the PLC output is FALSE and the state of the PLC input changes from
FALSE to TRUE, the state of the PLC output will change to TRUE and be maintained. Even
if the state of the PLC input changes back to FALSE.

When the PLC input is FALSE, there is no change to the state of the PLC output and it
maintained at it’s present state.
How Ladder Logic RS and SR Flip Flop Works in a PLC
The RS and SR flip flops operate a little differently to the T flip flop. So how exactly do the
RS and SR flip flops work in a PLC?
The ladder logic RS and SR flip flop in a PLC have SET and RESET inputs that are
used to toggle the state of the flip flop output. When the SET input is TRUE, the state
of the flip flop output is maintained TRUE, even if the SET input changes state back to
FALSE. The state of the flip flop output will only revert back to FALSE if the RESET
input is TRUE.
If both the SET and RESET inputs are FALSE then there is no change in the state of the flip
flop output.
The difference in the operation of a ladder logic RS and SR flip flop is the way they handle
the situation where both SET and RESET inputs are TRUE at the same time. When both
SET and RESET inputs are TRUE at the same time the ladder logic SR flip flop unlatches
the output to FALSE. Whereas, the ladder logic RS flip flop latches the output to TRUE.
The operation of a ladder logic SR flip flop is summarized in the truth table below:
Ladder
Logic SR Flip Flop Truth Table
The operation of a ladder logic RS flip flop is summarized in the truth table below:

Ladder Logic
RS Flip Flop Truth Table

How to Program a Toggle Logic in a PLC Using


Ladder Logic
Now that we know the most useful types of flip flops and understand their operation, let’s
see how to program them in a PLC using ladder logic.
The main PLC programming component for developing toggle logic is a PLC output
latch. Equally important is PLC output feedback logic so that the state of the flip flop
output is dependent on both the state of the input and the current state of the output.
The most popular way to program toggle logic for a flip flop in a PLC is by using
ladder logic.

The three main methods of programming PLC toggle logic using ladder logic are latching
logic, SET and RESET instructions and flip flop function blocks.
In order for an electronic T flip flop to have bit stable operation we need to use a clock
input. However, with a ladder logic flip flop the PLC scan acts as a kind of clocked input
providing a cyclic update of the program state. We can use this to our advantage in our
ladder diagram to program in bit stable operation.
To implement a ladder logic flip flop in a PLC let’s firstly list the required inputs, outputs
and internal variables.
PLC manufacturers use different memory address allocation so the input, output and internal
variable allocations used here are arbitrary address. Below is the list of required inputs,
outputs and internal variables that need to be declared:

PLC Toggle Logic Variable Table

T Flip Flop Ladder Logic Examples


The 3 most common ways to program toggle logic for a T Flip flop in any PLC using ladder
logic are:
1. Positive edge one shot instructions and latching logic.
2. Latching logic.
3. SET and RESET instructions.
The 1st T flip flop ladder diagram example uses positive edge one shot instructions and
latching logic:
PLC Toggle Logic – T Flip Flop Ladder Diagram Example 1
The 2nd T flip flop ladder diagram example uses latching logic. But, if you’re working
with a super basic mega cheap PLC it may not have one shot instructions and you may be
forced to use this method.….
PLC Toggle Logic – T Flip Flop Ladder Diagram Example 2
The 3rd T flip flop ladder diagram example uses SET and RESET instructions, which
tends to simplify the ladder diagram a little….

PLC Toggle Logic – T Flip Flop Ladder Diagram Example 3


SR Flip Flop Ladder Logic Examples
The 2 most common ways to program toggle logic for a SR Flip flop in any PLC using
ladder logic are:
1. Latching logic.
2. SET and RESET instructions.
The 1st SR Flip Flop ladder diagram example using latching logic is shown below….
SR Flip Flop Ladder Diagram Example 1
The 2nd SR Flip Flop ladder diagram example using SET and RESET instructions is
shown below….

SR Flip Flop Ladder Diagram Example 2

RS Flip Flop Ladder Logic Examples


Remember, compared to the ladder logic SR flip flop, the ladder logic RS flip flop is the
same except it has a different result when both SET and RESET inputs are TRUE. We can
achieve this by using the PLC scan to our advantage and rearranging the code a little.
The 2 most common ways to program toggle logic for a RS Flip flop in any PLC using
ladder logic are:
1. Latching logic.
2. SET and RESET instructions.
The 1st RS Flip Flop ladder diagram example using latching logic is shown below….
RS Flip Flop Ladder Diagram Example 1
The 2nd RS Flip Flop ladder diagram example using SET and RESET instructions is
shown below….
RS Flip Flop Ladder Diagram Examples 2

Ladder Logic RS and SR Flip Flop in a Siemens


PLC
The Siemens PLC has dedicated ladder logic RS and SR flip flop function blocks as part of
their standard instruction library.
These function blocks operate exactly the same way as the other ladder logic RS and SR flip
flop examples, but requires an internal variable to be assigned to the function block.

The memory address allocation for a Siemens PLC is I=Inputs, Q=outputs and M=Internal
Variables.  Below is the list of required inputs, outputs and internal variables that need to be
declared for a Siemens PLC…..
Siemens PLC SR Flip Flop Variable Table
Siemens PLC SR Flip Flop Ladder Logic Example
The Siemens PLC SR flip flop function block has been implemented in the ladder diagram
example below…

SR Flip Flop in a Siemens PLC


Siemens PLC RS Flip Flop Ladder Logic Examples
The Siemens PLC RS flip flop function block is programmed in a similar fashion to the SR
flip flop function bock as per the ladder diagram example below…
RS Flip Flop in a Siemens PLC

How Can a Flip Flop Be Used in a PLC?


Now that you’re full bottle on PLC flip flops and PLC toggle logic you might be wondering
how they can be used in a PLC ladder logic program?
Using a ladder logic flip flop in a PLC is simple. If there is a situation where 1 input
must toggle an output, then use a ladder logic T flip flop. If there is a situation where 2
inputs are required to toggle an output then use a ladder logic RS or SR flip flop.

A Ladder logic flip flop application example could be a silo fill control sequence.
We could utilize north and south selection push button inputs and implement a ladder logic
SR flip flop to control which silo gets filled. Also, a pause toggle switch input could be
implemented using a ladder logic T flip flop in order to pause and resume the sequence to
allow for foreign debris to be removed from the inspection conveyor.
So when the operator pushes the north or south selection buttons the silo feed diverter
changes position from north to south and vice versa.
And when the operator pushes the pause toggle switch the filling sequence stops, the foreign
debris is removed, then the pause toggle switch is pressed again and the sequence resumes
from where it left off. 
Now that you know enough to be dangerous it’s time to get your hands dirty on a PLC
Programming Simulator.
To go to the next section click here.

Parte 3
So, Click on the X0 button in the PLC simulator to activate Input X0. Input X1 is already de-
activated so we don’t need do anything with it at this stage….

Ladder Logic Simulator – Latching Logic


Ladder Logic Simulator – X0 Sets the Latch
Notice that logic flows through X0 and X1 to output Y0 and they are all highlighted….
Once the latch is SET we can de-activate Input X0 by clicking on the X0 button in the PLC
simulator. Notice that Output Y0 is ON and is held in….

Ladder Logic Simulator – Latching Logic Set


To RESET the latch activate Input X1 by clicking on the X1 button in the PLC simulator.
Because Input X1 is assigned to a normally closed contact symbol logic flow is blocked
when the input is activated. That’s opposite to how a normally open contact symbol works
and it’s called reverse logic….
Ladder Logic Simulator – X1 Resets the Latch
To once again SET the latch from this point, Input X1 must be de-activated and then input
X0 can be activated.
Adding a Rung Comment Using the Ladder Diagram Editor
To really start program like a pro let’s add a comment to the rung. First click on rung 1 and
in the top toolbar click on Tools and then Comment Editor….
Enter the comments in the dialog box that pops up and hit OK….
Now our ladder diagram should have the comment displayed at the very top of the rung as
shown below….

Congratulations…. you have just simulated a PLC latching logic using ladder logic
simulator software.

Ladder Logic Simulator Tips


Here are some handy tips to remember…
 Turn Edit Mode on in the Main Toolbar to start programming changes.
 After changing the program click Accept in the Main Toolbar to compile the program.
 Remember to save any programming changes.
 Start the PLC programming simulator before connecting to it.
 When connecting to the PLC make sure to tick the “link Enable” box.
 Put the PLC programming simulator to Terminal mode before downloading.
 To download to your ladder logic to the PLC programming simulator click on the “Write
PLC” button in the Main Toolbar.
 Flick the PLC programming simulator to RUN mode to enable logic processing.
 Make sure Status is turned on in the Main Toolbar to see the logic flow indication.
If you are interested in knowing the basics of ladder logic programming then click here.
Ladder Logic Simulator
A ladder logic simulator is a software application that lets you simulate the operation of a
PLC ladder diagram with a personal computer, mobile phone or tablet. It allows you to test
your PLC ladder diagram without the need to purchase any PLC hardware.
A ladder logic simulator also has the ability to control the state of the inputs, outputs and
internal variables. This means that input and output devices do not need to be purchased or
connected to the PLC.

You can save time and money by using a ladder logic simulator to test your ladder diagram.
Saving 100’s, even 1000’s of dollars on purchasing a PLC sounds like a good idea.
Especially if you are just starting out on the journey to learn ladder logic programming.

Ladder Logic Simulator Free Download


The Do-more Designer PLC Programming Simulator is by far the easiest, most flexible,
feature packed ladder logic simulator that’s out there at the moment for a PC.
It’s free to download with no registration required and genuinely no strings attached.

The Do-more Designer is actually the PLC programming software used for the Do-more
PLC by Automation Direct.
The actual PLC Programming Simulator is built into the Do-more Designer software and is
a full-featured programming tool, not just a demo version.
The beauty of using actual PLC programming software with a built in PLC simulator is that
it allows you to get a feel for what real PLC programming software is like.
So when you transition to using real life PLC hardware the learning curve is much easier.
Even if you are using different PLC hardware.

The Do-more Designer Software is compatible with Windows Vista, Windows 7, Windows
8 and Windows 10 operating systems.
The minimum system requirements are a 1GHz single core CPU with 1GB RAM and
330Mb of storage.
To get the Do-more Designer PLC Ladder Logic Simulator Free Download from
Automation Direct click here.

Ladder Logic Simulator Example


Once you’ve installed the software it’s time to get stuck into a PLC ladder logic simulator
example.
Let’s do a ladder logic latch example with the PLC simulator.
For an explanation on ladder logic latch programming click here.
Create a New Project To Use With the PLC Simulator
Run the application and choose New Offline Project….

If the “Select Project” dialog box does not automatically pop up then go to File, New
Project and select Offline…
In the “New Offline Project” dialogue box select “Do-more Simulator” in the Do-more
Hardware Class. Then name the project, select the directory location and click OK….

Well done. We have just created a new project file for the PLC simulator.
PLC Simulator Layout
When your newly created project first fires up the layout should be similar to below….
The Main Toolbar is at the top, the Project Browser is on the left, the Instruction Toolbox is
on the right and the Status Bar is down the bottom.
The Main Toolbar and Project Browser can be hidden or made visible by selecting the View
menu in the Main Toolbar. And the Instruction Toolbox can be hidden or made visible by
selecting the Edit menu in the Main Toolbar.

We should have the Main program displayed. It will have a bunch of rungs connected to
NOP (no operation) outputs.
We can close the Dashboard and Start Page tabs (next to the Main tab) to simplify things.
If you accidentally close the Main program just double click on “Main” in the Project
Browser on the left hand side…

The Do-more Designer is fully functional PLC programming software. There is an awful lot
that we can do with this kind of software with regards to structuring and organizing our
program.
Because we are using the PLC programming simulator we will be limited to the amount of
ladder logic programming that we can simulate at any one time. So we don’t need to fully
utilize all of the software’s features.

We will only need to do our ladder logic programming in the Main program. There is no
need to create extra programs or sub routines at this stage. We’ll stick to the essentials for
now.
Using the Ladder Diagram Editor
So let’s get started with our first piece of ladder logic programming.
If Edit Mode is not highlighted in the Main Toolbar then click on it to enable program
editing….

This will also pop up the Instruction Toolbox on the right hand side.
Please note that the Do-more PLC simulator calls a symbol an instruction. Don’t worry, the
two terms, instructions and symbols, are readily interchangeable.
Grab a Normally Open contact symbol (or instruction) from the Instruction Tool bar and
drag and drop it into the start of the first rung….
If we drop the instruction in the wrong spot or have accidentally dropped the wrong
instruction then we can cancel it by hitting the ESC key.
If we have already declared the symbol and want to delete it then select the symbol and hit
the Delete key.

A dialogue box will popup so we can declare the symbol.


PLC Simulator Input Symbol Declaration
The Do-more PLC programming simulator allocates symbol addressing the same as the
actual real life PLC.
In this example we will be declaring digital inputs and digital outputs as per below….
X0-2047 (Digital Inputs)
Y0-2047 (Digital Outputs)
Because this PLC simulator is fully featured there are other symbol declarations possible,
but we will not be using them for this example….
C0-2047 (Digital Internal Variables)
RX0-255 (Real Analog Inputs)
WX0-255 (Signed Word Analog Inputs )
RY0-255 (Real Analog Outputs )
WY0-255 (Signed Word Analog Outputs
R0-2047 (Real Internal Analog Variables)
V0-2047 (Unsigned Word Internal Analog Variables)
N0-2047 (Signed Word Internal Analog Variables )
D0-2047 (Signed Double Word Internal Analog Variables)
T0-255 (Timers )
CT0-255 (Counters)
ST0-1023 (System Variables)
To declare the instruction as a digital input type X0 into the text field and click on the
magnifying glass icon. Don’t worry about the yellow popup box for now, you can close it if
you want….

After the magnifying glass icon is selected the Element Browser table will popup. Fill it in
as per below….
And then click Select.…

Save the changes when prompted.


Then click on the tick icon to accept the instruction declaration…

Now, the first rung of the ladder diagram should have the normally open contact with all the
declared information displayed above it, as per below…..
PLC Simulator Output Symbol Declaration
So let’s add an output to the first rung.
Double click on the NOP output on the right hand side of the first rung. The instruction
declaration pop up box appears.
This time we need to declare an output address, so type Y0 into the text field. Then click the
magnifying glass….

After the magnifying glass icon is selected the Element Browser table will popup. Fill it in
as per below….
And then click Select.…

Save the changes when prompted.


Then click on the tick icon to accept the instruction declaration…

The first rung of the ladder diagram should now have the normally open contact in series
with the output. All the declaration information should be displayed above each ladder logic
symbol….

Adding More Symbols Using the Ladder Diagram Editor


Let’s continue with adding the rest of the ladder diagram symbols for the Latching logic.
This time we need to drag and drop a normally closed contact into the position next to
INPUT A.
Use the same procedure as above to declare the instruction. This time declare it as input X1
as per the information below…

Remember to click Select, Save the changes if prompted and then click on the tick icon to
accept the instruction declaration.
Now we’re cooking. The Main program should look like this….
Adding a Symbol Branch Using the Ladder Diagram Editor
Time to add the last ladder diagram symbol to complete our ladder logic latch PLC
simulator example.
Grab a normally open contact and drag and drop it into the area just below the INPUT A
symbol.
This symbol has already been declare so we do not need to declare it again. Just enter Y0 in
the instruction declaration text box and hit the tick icon or press enter.
The Main program should look like this….
Notice there is a connection missing between the new symbol just added and rung 1.
We can add that connection by clicking on INPUT B symbol to select it. Then going to the
main toolbar and selecting Edit, Wire and the Down.
This will create a connection from rung 1 down to the end of Output Y normally open
contact. Thus creating a branch (or parallel) connection across INPUT A normally open
contact….

The final result should look like this….


Compile the Changes Made to the Ladder Diagram 
Before we can proceed we need to compile any changes that have been made to the ladder
diagram.
The yellow bar on the left hand side of the first rung on the ladder diagram prompts you to
compile the programming changes by clicking the Accept button in the Main Toolbar….

After the Accept button is clicked a green bar appears prompting you to save the ladder
diagram project.
Click the Save button in the Main Toolbar and if the properties pop up box appears click ok.
Once the project is saved the green bar disappears….
Connect to the PLC Simulator
We are now ready to connect to the PLC programming simulator.
The PLC programming simulator behaves just like a PLC. You need to connect to it,
download your program and place it in RUN mode.
First we need to fire up the PLC simulator by clicking on the Do-more/Sim button on the
Main Toolbar….

Click OK when the “Launch and Connect to Do-more PLC Simulator?” pop up appears.
The Do-more PLC Simulator will then launch….
PLC Simulator
You may have some communication errors pop up. This is because we haven’t connected to
the PLC simulator yet.
Please Note….The error popup box may be behind the PLC simulator window. This took a
bit to figure out, very sneaky. Hope that saves you some pain!
If you get an error pop up box appear displaying “Comm Link not responding” then click
Cancel….

If you get an error pop up box appear “Unable to establish a link to the PLC.” then click
OK….
Now, let’s connect to the PLC simulator. Go to the PLC tab in the Main Toolbar and click on
Connect….

The “Select Link…” pop up box appears with “MySim: on Local Port” highlighted. Make
sure to select the “Link Enabled” check box in the bottom left hand corner and then click the
Select button….
The “Resolve Online/Offline Differences” pop up box appears because we have not
downloaded the ladder diagram to the PLC simulator yet. Click on “Go Online and view the
DISK project” button….
Then click the Continue Online button when the “Online/Offline Incompatibility” pop up
box appears….
Click the Next button when the “Set PLC Clock” pop up box appears….

Click the Finish button when the “Setup System Configuration” pop up box appears….
We should now be connected to the PLC simulator. The Status Bar at the bottom of the
ladder diagram editor should read Online….

Also, the PLC simulator EthRX and EthTX indication boxes should be green to indicate
simulated Ethernet transmit and receive signals between the software and PLC simulator.
If they are flashing then the Status function is turned off, we’ll take care of that a bit later….
Download and Run the PLC Simulator
The light blue bar on the left hand side of the first rung on the ladder diagram indicate that
there are differences between the offline ladder diagram and online PLC programming
simulator.
Also, the S, P and D boxes in the bottom Status Bar are also highlighted light blue to
indicate that there are program differences between the offline ladder diagram and online
PLC programming simulator.
Lastly, there should be warning message appear just below the rung editing area which is
triggered because of the differences between the offline ladder diagram and online PLC
simulator …..

All we need to do to now is download the offline ladder diagram to the PLC programming
simulator.
Click on “Write PLC” in Main Toolbar to download the ladder diagram to the PLC
simulator….
When the “Download Project to PLC” pop up box appears select the check box to “Switch
to RUN mode after download completes” and then click OK….

Click Yes to turn ALL STATUS ON….


Now we are connected to the PLC programming simulator, have downloaded the ladder
diagram and have turned the Status indication ON.
We should have the status bar at the bottom of the ladder diagram editor window displaying
Online and Run….

The PLC simulator EthRX and EthTX indication boxes should change to be steady green
when the Status indication ON.
We have already put the PLC simulator into RUN mode when we did the download, but
while we are here we can drag and drop the PLC Mode Switch from TERM to RUN….
Now we’re ready to put the PLC simulator through its paces!
Using the PLC Simulator
To use the PLC Simulator we just need to click on the input address buttons X0-X15 to
change the state of the inputs. When the button is the depressed position the input is ON and
when the button is in the released position the input is OFF.
In the ladder diagram the status of the logic symbols highlights in light blue when the ladder
symbol logic flow is TRUE.
If the ladder diagram symbols are not highlighting then click on “Status” in Main Toolbar to
enable it….
PLC Programming Simulator
When Inputs X0 and X1 are both de-activated then the logic flow is blocked and Output Y0
is OFF….
To activate and de-activate inputs we simply click on the X0-15 buttons in the PLC
simulator. One click turns the input ON another click turns it OFF….

To SET the latch we must activate Input X0 and de-activated Input X1.
Parte 4

Ladder Logic Basics


Ladder logic is a programming language that is used to program a PLC
(Programmable Logic Controller). It is a graphical PLC programming language which
expresses logic operations with symbolic notation using ladder diagrams, much like the
rails and rungs of a traditional relay logic circuit.
Ladder logic is a fast and simple way of creating logic expressions for a PLC in order to
automate repetitive machine tasks and sequences. It is used in a multitude of industrial
automation applications. Some industrial automation application examples where PLC
ladder logic is used include….
 Material Handling Conveyor System.
 Pallet Packing and Strapping.
 Ball Mill Lubrication System.
 Logistics Package Conveying and Sorting.
 Cement Batching.
 Beverage Bottling and Labeling.
 Hopper and Tank Level Control.
 Air and Liquid Flow and Pressure Control.
In the good ol’ days, machine and process automation was accomplished using a hard wired
control system known as relay logic. With the advent of microprocessors and the invention
of the PLC, relay logic quickly became superseded by programming languages such as
ladder logic.

Why is Ladder Logic Popular?


Ladder logic is the most popular method of PLC programming because it has an easy
to use graphics based interface and the programming language resembles an electrical
schematic drawing. Engineers, electricians and students find the transition from an
electric circuit to ladder logic relatively easy.
When programming ladder logic in a PLC, the graphic, drag and drop nature of ladder
diagrams helps you formulate code quickly and easily. Ladder logic also helps you easily
trouble shoot your code because you can visually see the flow of logic from the LHS start
rail, through the logic symbols and to the RHS end rail.

Compared to text based programming languages, ladder logic programming is a lot easier to
use.

Learning the Basics of Ladder Logic


It’s relatively easy to learn the basic concepts of ladder logic programming, even if you
don’t have experience with electric circuits. Take comfort in knowing that ladder logic is
the quickest and easiest PLC programming language to learn.
In order to help you learn the basics of ladder logic we will cover the following….
 Introduce the ladder diagram.
 Examine the seven basic parts of a ladder diagram.
 Identify the binary and logic concepts used in ladder logic.
 Reveal the hidden ladder logic functions that are automatically built into the structure
of the ladder diagram.
 Discover the five fundamental logic functions that are essential to know.
So let’s begin….
What is a Ladder Diagram in a PLC?
A ladder diagram is the symbolic representation of the control logic used for
programming of a PLC. Ladder diagrams have horizontal lines of control logic called
rungs and vertical lines at the start and end of each rung called rails. It looks just like
a ladder, hence the name “ladder diagram”.
There are two main differences between an electrical schematic and a ladder diagram:
1. The control logic in an electrical schematic is represented using components whereas in a
ladder diagram symbols are used.
2. The control logic execution in an electrical schematic is as per the operation of an electrical
circuit whereas in a ladder diagram it relies on the methodical nature of the PLC scan

Why is a ladder diagram used for PLC


programming?
Ladder diagrams are used to formulate PLC logic expressions in graphical form. They
use symbols to represent conditional, input and output expressions. Ladder diagrams
are similar to relay control circuits and are used due to their ease of programming
compared to text based programming languages.
Early control system designers were accustomed to relay logic control circuits and ladder
diagrams closely mimic these. They preferred to use ladder diagrams for PLC programming
instead using text based programming languages of the day like C, BASIC, Pascal and
FORTRAN.

Factory maintenance staff already understand how to read relay control circuits. They can
use their knowledge of relay control circuits to help troubleshooting control system
problems that implement PLC programming with ladder diagrams.
Ladder Diagram (LD) is the official name given in the international PLC programming
standard IEC-61131. But, these days the terms ladder diagram, ladder logic diagram, ladder
drawing, ladder control, ladder circuit, control logic diagram and logic diagram (to name a
few) are all used to describe relay logic circuits and ladder logic programming.
So don’t get too caught up in the specific definition of each of these expressions, they kind
of generally all mean the same thing. At the end of the day most people will know what you
are talking about anyway. Personally, I use the term ladder logic for PLC programming
and relay logic for relay control circuits.

To access the body responsible for maintaining the IEC-61131 standard please click here.

How to Draw Ladder Logic Diagrams?


Ladder logic diagrams are drawn in a similar way to relay logic circuit. They use rails
and rungs to create the logic framework. The logic operations are drawn in using
symbolic notation.
The rails in a relay logic circuit represent the supply wires of a relay logic control circuit.
However, in ladder diagrams, the rails represent the start and end of each line of symbolic
code.
The rungs in a relay logic circuit represent the wires that connect the components together.
However, in a ladder diagrams, the rungs represent the logic flow through the symbolic
code.
When implementing a ladder logic program in a PLC there are seven basic parts of a
ladder diagram that critical to know. They are rails, rungs, inputs, outputs, logic
expressions, address notation/tag names and comments.  Some of these elements are
essential and others are optional.
To help understand how to draw ladder logic diagrams the seven basic parts of a ladder
diagram are detailed below…..
1. Rails – There are two rails in a ladder diagram which are drawn as vertical lines running
down the far most ends of the page. If they were in a relay logic circuit they would represent
the active and zero volt connections of the power supply where the power flow goes from
the left hand side to the right hand side.
2. Rungs – The rungs are drawn as horizontal lines and connect the rails to the logic
expressions. If they were in a relay logic circuit they would represent the wires that connect
the power supply to the switching and relay components. Each rung is numbered in
ascending sequential order.
3. Inputs – The inputs are external control actions such as a push button being pressed or a
limit switch being triggered. The inputs are actually hardwired to the PLC terminals and
represented in the ladder diagram by a normally open (NO) or normally closed (NC) contact
symbol.
4. Outputs – The outputs are external devices that are being turned on and off, such as an
electric motor or a solenoid valve. The outputs are also hardwired to the PLC terminals and
are represented in the ladder diagram by a relay coil symbol.
5. Logic Expressions – The logic expressions are used in combination with the inputs and
outputs to formulate the desired control operations.
6. Address Notation & Tag Names – The address notation describes the input, output and
logic expression memory addressing structure of the PLC. The tag names are the
descriptions allocated to the addresses.
7. Comments – Last but by not least, the comments are an extremely important part of a
ladder diagram. Comments are displayed at the start of each rung and are used to describe
the logical expressions and control operations being executed in that rung, or groups of
rungs. Understanding ladder diagrams is made a lot easier by using comments.
Parts of a Ladder Logic Diagram

How Does Ladder Logic Work?


Ladder logic works in a similar way to relay logic, but without all the laborious relay
control wiring. In simple terms, the field input and output devices are wired directly to
the PLC and the ladder logic program decides what outputs to activate, depending on
the status of the input signals.
Just like relay logic, ladder logic has supply rails, relay coils, relay contacts, counters,
timers, PID loop controllers and much more. The difference is that with relay logic the logic
expressions are created with relay control circuits. This can amount to large amounts of
relays and wiring. However, with ladder logic the logic expressions are programmed in the
PLC. So, the only wiring required is for the input and output devices.

How to Read Ladder Logic?


Ladder logic is read from the left hand rail to the right hand rail and from the first
rung to the last rung. In short – LEFT TO RIGHT AND TOP TO BOTTOM. The
rungs contain input symbols that either pass or block the logic flow. The result of the
rung is expressed in the last symbol, known as the output.
To start reading ladder logic we need to know some basic binary concepts, how they apply
to ladder logic, how ladder logic is executed and the basic logic functions that are built
into each rung. Let’s begin….

The Binary Concept Applied to Ladder Logic


Microprocessors, like the ones found in PLCs and personal computers operate on the binary
concept. You’ve probably heard of the term ‘binary’. It refers to the principle that things can
be thought of in one of two states. The states can be defined as:
True  or  False
1  or  0
On  or  Off
High  or  Low
Yes  or  No
Microprocessors love binary…..
10101011101000111010001010100010100100101010010011.
I don’t know about you, but my head hurts just looking at that! Luckily ladder logic uses
symbolic expressions and a graphical editor for writing and reading ladder diagrams making
it easier for us mere humans to comprehend.

In a PLC, binary events are expressed symbolically using ladder logic in the form of
a normally open contact (NO) and normally closed contact (NC).
The normally open contact (NO) is TRUE when the event is active and FALSE when
the event is NOT active. While the normally closed contact (NC) is FALSE when the
event is active and TRUE when the event is NOT active.
Let me explain NO and NC contacts a little further …..
Normally Open Contact (NO) in Ladder Logic
The event associated with a normally open contact (NO) can be TRUE or FALSE.
When the event is TRUE then it is highlighted green and the logic flow can move past
it to the next logic expression. Just like the current flow in an electric circuit when a
switch is turned on.
Let’s call a certain PLC input event ‘A’. This PLC input event could be something like a
button being pushed, a limit switch being activated or a temperature switch being triggered.
PLC input event ‘A’ follows the binary concept and has one of two states, TRUE or FALSE.
The ladder logic truth table for a normally open contact (NO) which denotes PLC input
event ‘A’ is shown below….

Ladder Logic Truth Table – Normally Open Contact


(NO)
Normally Closed Contact (NC) in Ladder Logic
The event associated with a normally closed contact (NC) can be TRUE or FALSE.
The result of the normally closed contact (NC) is basically the opposite state of an
event that occurs. So, if PLC input A is FALSE the result will be TRUE. And vise versa
when PLC input A is TRUE the result will be FALSE.
The normally closed contact (NC) is considered to be a ladder logic NOT function. It is
sometimes referred to as reverse logic. Check out the truth table below….

Truth Table – NOT Function


If we translate a NOT function into a ladder logic diagram we express it symbolically in the
form of a normally closed contact (NC) as seen in ladder logic truth table shown below….

Ladder Logic Basics


Truth Table – NOT Function
How Ladder Logic is Executed?
In order to successfully read ladder logic we need a basic understanding of how a PLC
works and how ladder logic is executed in a PLC. You see, the PLC follows a certain
execution procedure and if not adhered to it can lead to the ladder logic being read
incorrectly.
Ladder logic works in a similar way to relay logic, but without all the laborious wiring. It
has supply rails, relay coils, relay contacts, counters, timers, PID loop controllers and much
more. In simple terms, all the field input and output devices are wired to the PLC and the
ladder logic program decides what outputs to trigger depending on the status of the input
signals.

In basic terms, PLCs execute ladder logic by first reading all the input states and
storing them into memory. Secondly, scanning through and evaluating each rung of
ladder logic, from left to right and top to bottom. Lastly, at the end of the scan, the
resultant logic is executed and the outputs are written to.

Ladder Logic Basic Functions


In a ladder diagram the normally open (NO) and normal closed (NC) contacts merely tell us
what state an event is in, TRUE or FALSE. On their own they cannot decide what action to
take to automate something.
We need binary’s best friend ‘logic’ to help out.
Logic is the ability to decide what action needs to be taken depending on the state of one or
more events. We use the binary and logic concepts every day in our own lives. For example,
if I feel cold then I put my sweater on, but if I feel hot then I take my sweater off.
Binary concept – Cold or Hot, Sweater On or Sweater Off.
Logic concept – IF, THEN logic functions.
Binary Logic in action!
The binary and logic concepts are what makes ladder logic work. The hidden key to
unlock your understanding of how ladder logic works is: The logic functions in ladder
logic are automatically built into the structure of the ladder diagram.
Let me show you……
Ladder Logic IF, THEN Functions
Let’s take a real world event, allocate it to a normally open contact (NO) and call it ‘A’. In
ladder logic the real world events are defined as PLC inputs.
Now, let’s call the result of the logic function ‘Y’. In ladder logic the result of a rung logic
function is defined as a PLC output.

When we take these two fundamental elements and insert them into a rung in a ladder
diagram we get your first line of code!
It’s equivalent to “Hello World” in text based programming languages…..
L
adder Logic Basics – Your First Line of Code
Now, let’s expose the hidden inbuilt functions by highlighting them in blue in order to
illustrate the relationship between the ladder diagram rung structure and its inbuilt IF, THEN
functions….

Re
ading Ladder Logic Diagrams – In Built Functions
We can write out the logic expression in the above as rung as IF A THEN Y.
Because PLC input A follows the binary concept it has two possible states, TRUE or
FALSE. Therefore it results in two possible logic iterations:
IF A = FALSE THEN Y = FALSE
IF A = TRUE   THEN Y = TRUE
We also can express this in a truth table….

Truth Table
If we translate this into a ladder logic diagram we express it symbolically in the form of a
normally open contact (NO) for the input and a relay coil for the output. Remember the
logic flow is from left to right and follows the same concept of current flow in an electric
circuit.
The ladder logic truth table is shown below….
Ladder Logic Basics Truth Table
– Hello World
Ladder Logic AND Function
The AND function examines multiple PLC inputs and has one resulting output. If we
translate an AND function into a ladder diagram we can express it symbolically in the form
of two PLC inputs A and B using normally open (NO) contacts and a PLC output Y using a
relay coil.
They are all connected in line, just like a series connection in an electric circuit. This time
we have also highlighted the hidden AND function to illustrate the relationship between the
ladder logic functions and the ladder diagram rung structure….

La
dder Logic Basics – AND Function
We can write out the logic expression above as IF A AND B THEN Y.
The AND function examines if all the PLC inputs are TRUE, then the corresponding result
is also TRUE. However if any one of the PLC inputs is FALSE then the corresponding
result is also FALSE.

Because PLC input A and B follows the binary concept and are part of the AND function
there are four possible logic iterations. Check out the truth table below….
Truth Table – AND Function
The number of logic iterations increases with the number of PLC inputs (2 PLC Inputs). But that
doesn’t matter too much with the AND function because the result can only be TRUE if all
the PLC inputs are TRUE.
If we translate an AND function into a ladder logic truth table we get the table below….

Ladder
Logic Basics Truth Table – AND Function
Ladder Logic OR Function
The OR function examines multiple PLC inputs and has one resulting output. If we translate
an OR function into a ladder diagram we can express it symbolically in the form of two PLC
inputs A and B using normally open contacts (NO) and a PLC output Y using relay coil.
The inputs are placed in the rung in what is known as a branch. This is the equivalent of a
parallel connection in an electric circuit. The output is then connected in line with the rung.
This time we have also highlighted the hidden OR function when we create a branch
(parallel connection) with PLC input B across PLC input A….
Ladder Logic Basics – OR Function
We can write out the logic expression above as IF A OR B THEN Y.
The OR function examines if any of the PLC inputs are TRUE, then the corresponding
result is also TRUE. However, all the PLC inputs must be FALSE in order for the
corresponding result is also be FALSE.
Because PLC input A and B follows the binary concept and are part of the OR function there
are four possible logic iterations. Check out the truth table below….

Truth Table – OR Function


Remember, the number of logic iterations increases with the number of PLC inputs
(2PLC_inputs). But that doesn’t matter too much with the OR function because the result can be
TRUE if any of the PLC inputs are TRUE.
If we translate an OR function into a ladder logic truth table we get the table below….
Ladder
Logic Basics Truth Table – OR Function
Wow, you’ve flown through the binary and logic functions. Remember…
For basic ladder logic programming we express binary events using normally open
contacts (NC) and normally closed contacts (NC).
The five basic, yet essential, logic functions in ladder logic are:
1. NOT
2. IF
3. THEN
4. AND
5. OR
You may be surprised, but when we utilize all these functions in our ladder logic
programming we will be able to program the majority of automation control requirements.
Well done! You now have a handle on the basics of ladder logic.
In the next section we will jump straight into the most common symbols that you can’t do
without when ladder logic programming. We’ll also examine their operation and outline
some of their most popular uses. To go to the next section click here.
If you’d like to learn the basics of a PLC (Programmable Logic Controller) then click here.
Parte 5

PLC Basics
A PLC (Programmable Logic Controller) has some similarity to a personal computer (PC).
It has a microprocessor, memory, input and output interfaces. However, unlike a PC, it does
not have a keyboard, mouse, monitor or hard disk. And before for you ask, no – it can’t surf
the net, check your social media status or play your favorite music and games.
A PLC is a specially designed digital controller that is microprocessor based and can
be easily programmed to perform complex control tasks. They have been purpose-built
for industrial applications in order to provide control and automation to machinery
and processes with high accuracy and reliability. Programmable Logic Controller is
more often than not abbreviated to PLC.

The most important difference between a Programmable Logic Controller and a Personal
Computer is that the operating system of a PLC is extremely stable and reliable compared to
a PC. PLCs have been specifically designed to be used in industrial automation applications
so they also have a robust housings, higher interference immunity, built-in industrial
communication protocols and are able to efficiently interface with large amounts of input
and output devices.

Programmable
Logic Controller – PLC

A Brief History of the Programmable Logic


Controller
The father of the PLC is noted as being Richard E Morley. Commonly known as Dick
Morley, he was an American engineer who was an expert in the field of computer design,
artificial intelligence and automation receiving numerous industry awards throughout his
career. He was born in Clinton, Massachusetts on December 1, 1932 and died on October
17, 2017, in New Hampshire.
Dick Morley is credited with the invention of the Programmable Logic Controller in 1968.
He lead the team that spearheaded the development of the first PLC while he was at at
Bedford and Associates. The invention of the PLC was fuelled for the need to automate the
General Motors production facility.

The first Programmable Logic Controller was called a Modicon PLC. The name was a
shortened version of modular digital controller. The introduction of the Modicon PLC
revolutionized industry and how industrial processes and machines where automated.
Modicon was the company that created the Modicon PLC in 1968. But since then Modicon
have been owned by Gould, AEG and are presently owned by Schneider. PLCs have
certainly come along way since their inception +50 years ago.     

What are Programmable Logic Controllers Used


For?
Programmable Logic Controllers are used to automate tasks that where traditionally
controlled by hardwired relay logic control systems. PLCs are used to automate tasks
like pushing, lifting, sorting, cutting, flipping, weighing, transporting, washing, drying,
stacking, welding, sanding etc. The tasks that a PLC can be used to automate are
virtually endless.
The difference between a PLC and a relay is that a PLC is a microprocessor based device
whereas a relay is an electromechanical switching device. In order to provide intelligent
control of processes and machinery a PLC needs to be programmed whereas relays need to
be wired in combination with other relays.

Because PLC architecture is based on a computer microprocessor, it is not restrained to only


perform hardwired relay logic type operations. Programmable Logic Controllers can also
perform other operations such as comparison, mathematics, timing, counting, sequencing,
analogue signal processing, data manipulation and more.
The industrial applications of a PLC are numerous. They are used to automate applications
such as assembly lines, fan and pumping systems, batching plants, robotics, material
handling conveyors, stockpiling and reclaiming machines, packaging systems, grinding and
milling plants, building management systems etc. The list of application is virtually
unlimited.
Programmable Logic Controllers have penetrated into almost every industry. Some of the
industries that PLCs are used in include, but are not limited to, are manufacturing, mining,
oil and gas, food and beverage, logistics and baggage handling, timber processing,
irrigation, waste water processing, metal fabrication and welding, textiles and chemical
processing.

What are the Advantages and Disadvantages of a


PLC?
To realize the advantages and disadvantages of programmable logic controllers we need to
compare them with other types of control systems.
The 4 main types of controllers used in industrial control systems are relay logic, industrial
PCs, microcontrollers and PLCs. Each type of controller has it’s advantages and
disadvantages. The type of controller that is best suited will depend on the type and size of
the automation application.

A PLCs is best suited to automate a large amount of automation tasks, such as a


manufacturing plant. Relays are best suited to automate a hand full of simple automation
task, such as hopper level control. A Microcontrollers is best suited to automate an
application with a fixed set of parameters and has potential for mass production, like a
washing machine. While an Industrial PC would be best suited when high degrees of math
computation is required, such as a flight simulator.
The difference between a PLC and a microcontroller lies in the architecture of the units.
Both have a microprocessor with inputs and outputs, but a PLC is designed to be
expandable, accept and process large amounts of I/O and be able to communicate with other
devices. Whereas a microcontroller is usually purpose built for one particular automation
task, at lower cost and usually for mass production purposes.
What are the Advantages of a PLC?
The main advantages of a PLC are listed below:
1. Compact and robust.
2. Extremely reliable operating system.
3. Fast processor execution time.
4. Virtually maintenance free.
5. Easily expandable due to its modular design.
6. Lower power consumption compared to relay systems.
7. Built in communication for remote I/O, instrumentation, other PLCs and SCADA.
8. Can handle a large number of digital inputs and outputs.
9. Able to process analogue input signals and PID loops.
10. Multiple programming languages available.
11. Large programming instruction set.
12. Easy to use programming interface via PC.
13. Control logic modifications easily done via software, no hard wire modifications
required.
14. Installation costs greatly reduced compared to relay systems.
15. Excellent documentation facilities.
16. Increased ability for fault finding and diagnostics.
What are the Disadvantages of a PLC?
1. For simple applications where relay logic might suffice, using a PLC might blow out costs
due to the need to hire a programmer.
2. Math functions in a PLC are quite advanced, but when it comes to doing large amounts of
complex math computations then an industrial PC might be better suited.
3. Certain robotic and positioning applications may require extremely high speed execution
which may not be able to be achieved form a PLC.
4. Can be expensive for automating an application with fixed parameters for mass production
as compared to a microcontroller.
How Does a PLC Work?
The basic elements of a PLC that make it work are the Central Processing Unit (CPU),
data memory, program memory, input modules and output modules. The PLC CPU
continuously monitors the input signals, formulates decisions based on the application
program and then controls the output signals to automate a process or a machine. The
Programmable Logic Controller stores the application program in the program
memory and stores the status of the inputs and outputs in the data memory.
A microprocessor based CPU (Central Processing Unit) is what controls processes within
the PLC. The block diagram below simplifies the process flow within the PLC. The inputs
are read and their status stored in the data memory, the data is transferred to the application
program and processed, the data memory is updated and finally the outputs executed.
Pro
grammable Logic Controller (PLC) Block Diagram
Inputs are field devices such as button, switches and instrumentation which are used to
decide when and how the machine will operate. Inputs are wired directly into to the PLC or
via input modules.
Outputs are field devices such as relays, motor contactors, solenoid valves, lamps and
sirens which cause the machine to operate and provide feedback to the machine operator.
Outputs are wired directly out of the PLC or via output modules.

Data Memory is where inputs and outputs are declared and allocated to memory locations.
The data memory stores the status of the inputs and outputs and is continually updated by
the application program.
Program Memory is where the application program (such as ladder diagram) is stored and
processed. The program memory needs to be loaded with a program so that it can do
stuff. If there’s no application program loaded in the program memory, the PLC is just
an expensive paper weight.

Basic Operation of a Programmable Logic


Controller
Even though a PLC has a CPU just like a PC, the internal operation is not quite the same.
PLCs are designed to be extremely reliable and therefore have a fixed and dedicated internal
process. This process is called the PLC scan cycle.
The PLC scan cycle is a sequential and repetitive process that has 3 basic tasks.
Evaluate inputs, process the application program and execute outputs. The tasks in the
PLC scan cycle are strictly performed in a certain order and in an endless cyclical
manner.

PLC
Scan Cycle
Some Programmable Logic Controller from different manufacturers may have slight
variations to the scan cycle, but the 3 tasks mentioned above are common to all.
The PLC scan is part of the second task (process program) in the scan cycle and refers to
the way in which the CPU processes the application program. During the PLC scan the
rungs of the application program are processed from left to right and top to bottom. The
CPU continually updates the status of each the inputs, outputs and internal variables in the
data memory but only executes the outputs at the end of the PLC scan.
PLC Scan
This is super important to remember because it can affect the way the program is evaluated.
As a consequence the PLC Scan sequence may force you to modify the way your
application program is written in order to achieve the correct process control outcome.
The scan time is the total time that it takes for the PLC to complete one full scan cycle. The
scan time is universally expressed in milliseconds (ms). The PLC scan time is an essential
metric to measure and be aware of because it can have adverse effects on the PLCs ability to
control the application, especially if the speed of your application is faster than your PLC
scan time.

In summary, the basic working principles of a PLC is that it monitor the status of the
machine and process, then makes decisions bases on the logical functions created by the
ladder logic program stored in the PLC’s memory. The Programmable Logic Controller then
initiates output signals to control the behavior of the machine or process.

PLC Automation
When it comes to industrial automation the PLC is literally considered to be the “brains of
the operation”. It’s a programmable device that makes all the decisions on how a machine is
controlled depending on the data gathered from field instrumentation and operator feedback.
To better understand PLC automation we can compare to how the human brain works. If we
look at the human brain we realize it relies on our five senses of sight, hearing, smell, taste
and touch to understand what our environment is doing. Also, the human brain controls
movement in our body to create actions such as walking, running, kicking a ball etc.
So let’s say we sense that our body is getting hot. Then we can roll our sleeves up a little too
cool down. We can actually roll our sleeves up and down to regulate our body temperature
to what feels comfortable. If we’ve rolled up our sleeves all the way and we are still too hot
after a certain amount of time and we can’t tolerate it any more then we can take our sweater
off. 

Basic Brains Control System


How would a Programmable Logic Controller Automate an Industrial
Application?
Just like the human brain relies on information provided by our senses, a Programmable
Logic Controller requires instrumentation to measure it’s surroundings. These are known as
PLC inputs.
And just like the human brain uses data gathers from the body’s senses to decide on what
actions are required to be taken, a PLC gathers information from instrumentation and uses
the application program to decide what actions are required to be taken.

The information gathered by instrumentation is stored in the data memory and the
application program is stored in the program memory.
Lastly, just like the brain controls movement in our body, a PLC controls movements in a
machine using electric, pneumatic and hydraulic devices. These are known as PLC outputs.
Let’s Connect a Programmable Logic Controller with Input and Output
devices for a Basic Temperature Control Application.
If we connect a temperature sensor as a PLC input we can measure how hot it is. Then if we
connect an electric fan as a PLC output we can regulate the temperature.
P
LC Automation – Block Diagram
A PLC is just a boat anchor if it does not have a program stored in its memory. For a
PLC to automate an application we need to define our control objectives in order to be
able to program some control logic expressions.
A basic functional description of a basic temperature control application could be….
1. If the temperature measured increases above a certain threshold, the Programmable Logic
Controller can switch an electric fan on to cool down the system.
2. Then if the temperature measured increases or decreases the Programmable Logic
Controller can adjust the speed of the fan to regulate the temperature to maintain a certain
level.
3. Once the temperature reduces below a certain threshold, for a certain period of time, then
the electric fan can be switched off.
Remember, the level of PLC automation is only as good as the information gathered by
instrumentation and the quality of the application program contained in it’s memory.
So a good program with solid logic expressions will ensure trouble free operation.
A PLC can control industrial automation applications. The amount of applications that a
PLC can control are endless, but here are just a few examples….
1. Controlling the level of a process water tank by monitoring the tank level and varying the
speed of an inlet pump.
2. Controlling the temperature of a drying oven by monitoring it’s internal temperature and
varying the burner control valve position.
3. Controlling the starting and stopping sequence of a series of material handling conveyors.

The PLC Control System


A PLC system is the combination of various hardware and software components. Each
component plays a specific and important role in the overall PLC control system. The
essential elements that make up a PLC control system are the PLC itself, peripheral input
and output devices, Human Machine Interfaces (HMI) and a programming device.
PLC Input devices include instrumentation like switches, sensors and push buttons. PLC
Output devices include equipment such as electric motors and actuators. They are either
hardwired to the PLC or connected via a fieldbus (communication link) such as Ethernet IP,
Profibus, Modbus etc).
Human Machine Interfaces (HMI) form the bridge between the operator and the PLC by
allowing operator control and providing visual and audible feedback. They include devices
such as touch screens, SCADA systems (Supervisory Control & Data Acquisition) and
hardwired control panels that have switches, push buttons and indicator lamps.
A PLC Programming device is needed to be able to configure and program the PLC
control system. In the past dedicated programming terminals were used, but today a PC is
the tool of choice.
The PLC System works by accepts the input device signals, process the data according to
the program stored in the PLCs memory and then activating the appropriate outputs to
control the machine or process.
A basic block diagram of PLC control systems is shown below:

P
LC Control System Block Diagram
Because a Programmable Logic Controller is specialized to execute it’s scan cycle it
performs with high speed and with extremely high reliability. This is essential for
maintaining high reliability for PLC machine control and process automation.
Imagine the Programmable Logic Controller crashing, just like your home PC operating
system, midway through a machine operation. It can be dangerous to personnel, production
and equipment causing injury, damage, downtime and unnecessary expense.
Programmable Logic Controllers have also been designed, unlike the home PC, to operate
under harsh industrial environments where electrical noise and Electro Magnetic
Interference (EMI) exist.
They generally, but not always, require a separate power supply and have input and output
terminal strips for connection of electrical devices. For some PLC machine control
applications extendable and remote mounted input and output modules are usually available.
These days PLC machine control systems have communication options such as Ethernet/IP
(Allen Bradley), Profinet (Siemens) and Modbus TCP/IP (Modicon), to name a few. PLC
machine control system communication options such as these allow for networking with
other PLC’s, remote input/output modules, instrumentation, motors, actuators and Human
Machine Interfaces (HMI) such as touchscreens and SCADA systems.
In the next section we will examine the current PLC Manufacturers in today’s automation
industry, their ranking, revenues and the latest PLC products on offer. To go to the next
section click here.
If you’d like to learn the basics of ladder logic programming then click here.
Parte 6
S
e
a
Related Articles r
c
h
 Ladder Logic Basics
 Ladder Logic Symbols
f
 Relay Logic Vs Ladder Logic
o
 Ladder Logic Programming
r
 Ladder Logic Programming
:
Examples
 PLC Timer
 PLC Sequencer Logic
 PLC Toggle Logic & Flip Flops
 Ladder Logic Simulator
 PLC Basics
 PLC Manufacturers
 PLC Architecture
 PLC Hardware
Ladder Logic Basics
Ladder logic is a programming language that is used to program a PLC (Programmable Logic
Controller). It is a graphical PLC programming language which expresses logic operations with
symbolic notation using ladder diagrams, much like the rails and rungs of a traditional relay logic
circuit.
Ladder logic is a fast and simple way of creating logic expressions for a PLC in order to automate
repetitive machine tasks and sequences. It is used in a multitude of industrial automation applications.
Some industrial automation application examples where PLC ladder logic is used include….
 Material Handling Conveyor System.
 Pallet Packing and Strapping.
 Ball Mill Lubrication System.
 Logistics Package Conveying and Sorting.
 Cement Batching.
 Beverage Bottling and Labeling.
 Hopper and Tank Level Control.
 Air and Liquid Flow and Pressure Control.
In the good ol’ days, machine and process automation was accomplished using a hard wired control system
known as relay logic. With the advent of microprocessors and the invention of the PLC, relay logic quickly
became superseded by programming languages such as ladder logic.

Why is Ladder Logic Popular?


Ladder logic is the most popular method of PLC programming because it has an easy to use graphics
based interface and the programming language resembles an electrical schematic drawing.
Engineers, electricians and students find the transition from an electric circuit to ladder logic
relatively easy.
When programming ladder logic in a PLC, the graphic, drag and drop nature of ladder diagrams helps you
formulate code quickly and easily. Ladder logic also helps you easily trouble shoot your code because you
can visually see the flow of logic from the LHS start rail, through the logic symbols and to the RHS end
rail.
Parte 7

Ladder Logic Symbols – Operation and


Common Uses
The ladder logic symbols that are used in PLC programming have been derived from
traditional relay logic control circuits. If you have a basic knowledge of electric circuits then
getting started in ladder logic programming should be a breeze. If not, don’t worry, ladder
logic is a graphical programming language and getting to know the basic ladder logic
symbols and concepts is quite easy.
Ladder logic symbols are the fundamental programming components used in ladder
diagrams. In PLC programming, ladder logic symbols can be used individually or in
combination to create logic instructions. Traditionally, ladder logic symbols were
created for bit logic operations, but now include higher level functions such as timers,
counters, math, comparison, PID loops, data manipulation and data conversion.
Learning the basic ladder logic symbols will give you a solid foundation. Generally
speaking a large majority of real world applications can be accomplished with the basic
ladder logic symbols. As your desire to program complex automation and process control
Functions increases, then higher level ladder logic symbols can be used like math
operations, PID loops, data manipulation and data conversion.
The main symbols for PLC ladder logic are the input symbols and output symbols.
Digital inputs are expressed as normally open contact (NO) symbols or normally closed
contact (NC) symbols. While digital outputs are expressed as a coil symbol.
In ladder logic the normally open contact (NO) and normally closed contact
(NC) symbols are mainly used to define PLC digital inputs and internal logic instructions.
They have been translated into ladder logic from switches and relay contacts used in electric
circuits.
An coil in ladder logic is the symbol which mainly defines PLC digital outputs. However, a
coil can also be used with internal memory in order to trigger internal logic instructions. The
coil symbol has been translated into ladder logic from relay coils used in electric circuits.

The NO and NC contacts are some of the fundamental symbols used in PLC programming.
Let’s take a more detailed look at them and other symbols used in PLC programming by
investigating their operation and how they are commonly used in a ladder diagram….

Normally Open Contact (NO) Symbol

Operation:
If the condition is TRUE then the contact is CLOSED and output logic flow is enabled. If
the condition is FALSE then the contact is OPEN and output logic flow is blocked. 

Ladder Logic
Normally Open Contact (NO) Symbol – State Diagram
Common Uses:
 Start Push buttons.
 Selector switches.
 Digital instrumentation.
 Internal programming.
Normally Closed Contact (NC) Symbol

Operation:
If the condition is TRUE then the contact is OPEN and output logic flow is blocked. If the
condition is FALSE then the contact is CLOSED and output logic flow is enabled. The NC
contact symbol operation is opposite to the NO contact symbol.

Ladder Logic
Normally Closed Contact (NC) Symbol -State Diagram
Common uses:
 Stop Push buttons.
 Fail safe instrumentation.
 Motor Thermal Overloads.
 Internal programming.

Output Coil Symbol

Operation:
If the input condition is TRUE then the output is ON. If the input condition is FALSE then
the output is OFF.
Ladder Logic
Output Coil Symbol – State Diagram
Common uses:
 Motor control.
 Actuator control.
 Indication lamps.
 Warning sirens.
 Internal programming.
 Sequence logic.

One Shot Symbol– Positive Edge Detection

Operation:
If the input condition transitions from FALSE to TRUE then the output is ON, for the time
taken to do one PLC scan.

Ladder Logic One


Shot Symbol (Positive Edge Detection) – State Diagram
Common uses:
 Counting applications.
 Math commands.
 Data Transfer commands.
 Latch output during a specific set of conditions.

Set Coil Symbol

Operation:
If the input condition transitions from FALSE to TRUE then the output is set ON. Once the
output is set ON, it stays ON, even if the input condition goes FALSE.

Ladder Logic Set


Coil Symbol – State Diagram

Reset Coil Symbol

Operation:
If the input condition is TRUE then the output is reset to OFF. If the input condition is
FALSE it has no effect on the output.  The SET and RESET coils can share the same
variable address and therefore work hand in hand.
Ladder Logic Reset
Coil Symbol – State Diagram
Common uses for Set and Reset Coil Symbols:
 Motor and actuator outputs.
 Indication lamp and warning sirens.
 Internal programming.
 Toggle logic (flip flops).
 Complex latching logic which is set and reset in multiple locations.

Timer Delay On Symbol

Operation:
If the input condition is TRUE then the timer begins. When the preset time set point has
been reached the output turns ON. If the input condition goes FALSE, at any stage, the timer
stops and the output turns OFF as well.

Ladder Logic Timer


Delay On Symbol– State Diagram
Common uses:
 Time delay for Warning Sirens.
 Star/Delta Motor Starters.
 Sequence start delays.
 De-bounce time delay to fix digital instrumentation flicker.

Timer Delay Off Symbol

Operation:
If the input condition is TRUE then the output turns ON. Then if the input condition goes
FALSE the timer begins. When the preset time set point has been reached the output turns
OFF. If the input condition goes TRUE, at any stage, the timer stops and the output turns
ON as well.

Ladder Logic Timer


Delay Off Symbol – State Diagram
Common Uses:
 Cooling Fan run on time delay.

Comparison Symbols 
Operation:
If the comparison between two inputs is TRUE then the output turns ON.
Common uses:
 Product Stacking and Un-Stacking complete.
 Batching system weight set point achieved.
 Alarm & Fault activation (Temperature, Flow, Motor Current etc).

Math Symbols

Operation:
Executes the mathematical operation using the inputs with the result written to the output.
Common uses:
 Scaling of Analogue Inputs and Outputs (Temperature, Flow, Motor Current, Weight,
Pressure etc).
 Calculating Motor Speed and Position profiles.

Up Counter

Operation:
If the input condition transitions from FALSE to TRUE then the counter is incremented by a
value of 1. The accumulated count value is written to an output. When the count value
reaches the preset value the done output is set TRUE. The counter is set back to 0 by
triggering the reset input.

Down Counter
Operation:
If the input condition transitions from FALSE to TRUE then the counter is decremented by
a value of 1. The accumulated count value is written to an output. When the count value
reaches zero the done output is set TRUE. The counter is set back to the preset value by
triggering the reset input.
Common uses for Up & Down Counters:
 Counting items for a stacking sequence.
 Counting items for a batching sequence.
 Counting items for a diverting conveying.
 Counting items to be queued in a conveyor line.
 Counting events for alarm and fault triggering.

PID Closed Loop Controller

Operation:
The process variable is measured via the input and the output is adjusted to maintain the
process variable at the set point input value. The Proportional, Integral and Derivative input
values are adjusted to tune the performance of the PID controller.
Common uses:
 Oven Temperature control.
 Irrigation Pressure control.
 Process Flow control.
In the next section were we will fast forward your learning of ladder logic programming by
understanding basic operating principles of relay control circuits and also discover the
difference between relay logic and ladder logic.
To go to the next section click here.
Parte 8

Relay Logic Vs Ladder Logic


Relay logic is a hard wired control system using instrumentation, switches, timers,
relays, contactors, motors and actuators. Traditional machine and process automation
was accomplished using relay logic. Automating a machine using relay logic requires a
mass of wiring and magnitude of devices to perform even the simplest of tasks.
Some of the other problems with implementing relay logic are:
 Requires a lot of switchboard space.
 Installation is very labor intensive.
 Trouble shooting is extremely difficult.
 Modifications to the control functionality are complicated and seriously tedious.
Relay Logic Vs Ladder Logic – Relay Logic Panel
The advent of the microprocessor meant that relay logic control functionality could be
programmed and stored in a computer. In the late 1960’s some really brainy people realized
this and pressed ahead to create a device called a Programmable Logic Controller (PLC).
Relay logic in a PLC is the method of formulating logical expressions in order to
automate machinery and processes in industrial applications. The programming
language that is used to create relay logic in a PLC is called Ladder Logic.
This was a massive breakthrough in the industrial automation industry which would
eventually render relay logic control systems near redundant.
In an automated control system the main advantages of a PLC over relays are:
 Easier to develop complex logical expressions with ladder logic software.
 Increased reliability with PLC life easily reaching +10years,
 Easier and cheaper to modify or expand the control system at a later date.
 Reduced design, installation and component costs.
 Virtually maintenance free compared to relays.
 Superior monitoring and reporting functionality making process trouble shooting and
optimization easier.

Relay Logic Vs Ladder Logic – PLC Ladder Logic


To understand the difference between relay logic and ladder logic it’s really important that
you understand relay logic and how a relay works. Understanding relay logic is a good
stepping stone to understanding ladder logic. After all, ladder logic was originally derived
from relay logic. Makes sense, right?

How Do Relay Logic Systems Work?


Relay logic systems are a network of hard wired electrical components. The relay is the
fundamental component and it works by switching electric circuits on and off to form
logic operations that in turn provide process control to the system. You can think of
relay logic systems as a mechanical computer that does computation with 1’s and 0’s
by switching relays instead of using a silicon chip.
The fundamental component of a relay logic is the relay. So let’s look at how relays work in
a little more detail…
What Is A Relay?
A relay is an electromechanical device that consists of two basic components, a relay coil
and relay contact. The relay contact is used to switch a circuit on or off and the relay coil is
used to change the state of the relay contact. The three main types of relays are spring return
relays, latching relays and multipole relays.
Why Are Relays Used In Control Circuits?
Relays are used because they allow electric isolation between the switching circuit (contact)
and control signal circuit (coil) via means of electromagnetics. That means relays can be
used to connect circuits with different voltage and current levels to control equipment like
motors and actuators. A relay can also switch multiple circuits with different states at the
same time making them ideal for logic control circuits in industrial automation.   
What Functions Does A Relay Perform?
Relays perform 3 main functions in an electric circuit:
 Allowing control circuits to switch a load circuit even if the voltages of both circuit are
different.
 Able to switch a high current device using a low current electronic control signal.
 Relays can be wired in combination to perform logical operations using a network of
electric circuits known as relay logic.
How a Relay Works
A relay is an electromechanical device that consists of two basic components….
 Relay coil.
 Relay Contact.
A relay coil is essentially copper wire wound around a chunk of iron that is used to produce
an electromagnetic field that can attract metal. Think of a junk yard crane that is used to
pick up scrap metal. It uses the same principle to generate a magnetic field that attracts
metal.
A relay contact is basically a switch that is used to turn an electric circuit on or off.

Hang on a minute! If the contacts of a relay turn an electric circuit on or off why do we need
the coil?
Well, the relay coil’s purpose is to change the state of the relay contacts. Just like your
finger is used to change the state of a light switch from off to on. So, we are changing the
state of the contacts using an electrical signal instead of your using your finger.
Electromechanical Relay
To energize the coil we need to connect it to a voltage source, which is sometimes called a
relay input.
Some common DC voltage relays are 5V relay, 12V relay and 24V relay. Some common AC
voltage relays are 120VAC relay and 240VAC relay.

The voltage rating is usually written on the casing of the relay. The coil voltage rating needs
to be adhered to otherwise the relay coil may fail to change the state of the contacts or
overheat and burn out.
When we energize the relay coil with it’s rated voltage it allows current to flow within the
relay coil and produces and electromagnetic field. This electromagnetic field is used to
attract the relay contact towards the relay coil, thus changing the state of the relay contacts.
The relay contacts are either configured normally open (NO) or normally closed (NC).
Quite often a relay will have changeover contacts.
So what is a changeover contact?
A changeover contact is the combination of both normally open (NO) and normally closed
(NC) contacts in the same contact block. The changeover contact allows selection of either
the normally open (NO) or the normally closed (NC) contact depending on the way it is
wired. It is sometimes called a double throw contact.
The contact voltage and current rating is usually written on the casing of the relay. The
contact voltage and current rating needs to be adhered to otherwise the relay contact may
overheat and burn out.
If the relay coil voltage rating and contact voltage and current rating are not written on the
relay casing then check the relay base. Sometimes it’s a combination of both the case and
base. If all else fails then consult the data sheet.
Relay Coil With
Contact Voltage & Current Rating
Relay Operation
If a relay is wired to a normally open (NO) contact and the relay is energized then the
contact will change state from OPEN to CLOSED…..

Basic Relay
Operation with Normally Open (NO) Contact
If a relay is wired to a normally closed (NC) contact and the relay is energized then the
contact will change state from CLOSED to OPEN…..
Basic Relay
Operation with Normally Closed (NC) Contact
If a relay with changeover contacts is wired in a normally open (NO) configuration and the
relay is energized then the contact will change state from OPEN to CLOSED…..

Basic Relay
Operation with Changeover Contacts wired Normally Open (NO)
If a relay with changeover contacts is wired in a normally closed (NC) configuration and the
relay is energized then the contact will change state from CLOSED to OPEN. Notice that
the wiring of the contacts has changed sides…..
Relay
Operation with Changeover Contacts wired Normally Closed (NC)
Types of  Relays
There are several types of relays each with their specific characteristics and uses. The 3
types that are used frequently in industrial applications are spring return relays, latching
relays and multipole relays.
Spring Return Relay
The most common relays are spring return relays. They have one relay coil and use a spring
to return the relay contact back to it’s normal state after the relay coil is de-energized and
the electromagnetic field has collapses.
The relay coil must be energized at all times in order for the state of the relay contact to
remain in it’s changed state. As soon as the coil is de-energized then the relay contact
returns back to it’s normal state.

Can you see the spring in the “Electromechanical Relay” picture above? The spring is at the
very top of the relay.
Latching Relay
A latching relay is a type of relay that can change and maintain the state of the contact
without the need for the coil to be constantly energized. It utilizes two separate coils, each of
which are responsible for a certain state of the contact either open or closed. A short voltage
pulse to energize either coil in the latching relay is all that is required to change the state of
the contact. 
Multi Pole Relay
A multi pole relay is any type of relay with more than one contact. Each relay contact is
called a pole. So a relay with two contacts will be called a two pole relay and a relay with
four contacts will be called a four pole relay.
When using multi pole relays multiple coils are not required to change the state of the
contacts. The state of all the relay contacts is changed at the same time by a single relay coil.
Two Pole Relay
In short, the operation of a single pole relay is the same as a multi pole relay, we just have
more contacts to play with!
This is handy when we are activating more than one device. Especially when the devices
need different voltage levels or the combined current draw of multiple devices exceeds the
current rating of a single contact. It’s also handy having multi pole relays when the process
control logic gets complex.
How do you connect a Relay?
In order to connect a relay we need to wire the coil to a voltage supply (generally switched)
and the contacts to the load device like a light, motor, solenoid valve or another relay. This
can be done by connecting the relay coil and contact wires to the terminals of a relay base.
The relay base terminal allocation for connection is usually drawn on the relay casing,
labelled on the relay base or detailed in the relay data sheet.
How
to connect a Relay
The common on a relay is the terminal associated with the part of the contact that does not
switch when the relay coil is energized. In a relay with a changeover contact it is the
terminal “common” to both the NO and NC contacts. When the common is wired correctly
it is connected to the load supply voltage.
Common On A Relay
Relay Logic Circuits
The fundamental elements of relay logic circuits are….
 Power supply.
 Relay components.
 Connection wires.
The power supply voltage needs to match the rated relay coil voltage. Also, the power
supply needs to be big enough to accommodate the current draw of all the relays when they
are energized.
The relays are selected according to the power supply’s output voltage, functionality and
current rating of the contacts required.

Because relay logic is a hard wired system some sort of wiring diagram or relay schematic
diagram is required to make sense of it all.
Now please take note, there are many ways to draw an electric circuit. Depending on which
country you are from will determine which standard relay wiring diagram you will need to
use.  The way circuits are laid out and the component symbols will vary from one drawing
standard to the next. Also, some drawing standards arrange their control circuits from left to
right and some use top to bottom. Check out the sample drawings below….
Power and Relay Schematic
Diagram Examples
For the purposes of this explanation a left to right arrangement will be used because it ties in
with ladder logic diagrams later on.
A relay schematic diagram consists of a supply voltage rail on the left hand side and a zero
voltage rail on the right hand side drawn as vertical lines.

The relay components and other devices are packed in between connected by wires, drawn
as horizontal lines, to form a circuit.
Relay Logic Symbols
The relay coil and relay contacts can be drawn as per the relay logic symbols diagram
below….
Relay Logic
Vs Ladder Logic – Relay Logic Symbols
How to Read a Relay Schematic
The most basic of relay logic circuits uses a power supply, a relay, a switch and a device that
needs to be switched ON or OFF all wired together as shown in the simple relay diagram
below….

Re
lay Logic Vs Ladder Logic – Relay Logic Circuit Example
The above relay logic circuit example shows a lamp (Lamp No.1) being switched on via a
relay (Relay No.1).
The first line has a rotary switch connected to the coil of Relay No.1 with the relay coil
labelled as R1.
The second line has a normally open contact from Relay No.1 also labelled R1 which is
connected to Lamp No.1.
To aid in understanding relay schematics the sequence of events is read from the first
horizontal line downwards and from the left hand side power rail to the right hand side
power rail.
We read from left to right because the potential difference between the left and right hand
side power rails creates current flow in that direction. In the example relay schematics a
green line is used to highlight current flow in the circuit.
So, in the first line we start at the left hand side power rail and follow the horizontal line
until we get to the normally open Rotary Switch.
If the rotary switch is in the OPEN state there is an open circuit and current cannot flow to
the right hand side of the circuit. So the relay coil (R1) stays de-energized.
If we go to the second line we notice that the normally open relay contact (R1) stays OPEN
because Relay No.1 coil (R1) is de-energized. Therefore there is also an open circuit on the
second line so no current can flow to the lamp and it stays OFF….

Ba
sic Relay Logic Circuit Example – With Rotary Switch Off
What happens when we turn the Rotary Switch on?
When the Rotary Switch is turned ON it’s state changes from OPEN to CLOSED.
If we look at the first line and start at the left hand side power rail then follow the horizontal
line until we get to the Rotary Switch we can observe that it is in the CLOSED state and
current can flow to the right hand side of the circuit.
So in this case the relay coil (R1) is energized and then we reach the end of the right hand
side rail.
Now let’s go to the left hand side of the second line where we notice that the normally open
relay contact (R1) has also changed state to CLOSED because the relay coil is energized.
Therefore there is a closed circuit on the second line so current can flow to the right hand
side of the circuit and Lamp No1 turns ON….
Ba
sic Relay Logic Circuit Example – With Rotary Switch On
Let’s spice it up and add another line to the relay logic circuit.
This time we’ll use a second relay contact from Relay No1 and wire it as a normally closed
contact.  Then we’ll add a second lamp (Lamp No2) to the new circuit.
In this case the operation of that lamp will be reversed. So when the Rotary Switch is OFF,
Lamp No.2 is ON and when the Rotary Switch is ON, Lamp No.2 is OFF.
Wait, what????
Don’t believe me then check out the relay logic circuit below….

Re
lay Reverse Logic – With Rotary Switch Off
The new relay contact in the third line is now a normally closed instead of normally open.
When Relay No.1 coil is de-energized it’s normally closed contact is in it’s normal state,
that is CLOSED.
When Relay No.1 coil is energized it’s normally closed contact changes state to OPEN.
A normally closed contact behaves the opposite of a normally open contact. It’s sometimes
referred to as reverse relay logic or just reverse logic. See below….

R
elay Reverse Logic – With Rotary Switch On

Ladder Logic Control


Remember the statement earlier on this page – Ladder Logic was originally derived from
Relay Logic.
So, what is the difference between relay logic and ladder logic?
The big difference between relay logic and ladder logic is that relay logic needs to hard
wire each and every control circuit for every single control function. Whereas ladder
logic uses the assistance of a microprocessor based device called a Programmable
Logic Controller (PLC).
And, how does a PLC differ from relay logic?
The difference between a PLC and relay logic is that a PLC is a programmable device
whereas relay logic is a network of hardwired electrical devices. Both a PLC and relay
logic can perform logical computation, but a PLC does it using a microprocessor and
relay logic does it using electric circuits.
So essentially what we are doing is getting a mass of relays and wires and replacing them
with a tiny box that has awesome computing power.
Even with a PLC and ladder logic programming we still need to hard wire certain devices
such as the switches and lamps just like in the relay logic examples above. But the wiring is
greatly reduced because only the input and output devices need hard wiring. The control
relays that are used to form the control functionality and logic functions are replaced by the
ladder logic program stored internally within the PLC memory.

Relay Logic Vs Ladder Logic – Programmable Logic Controller


The format of a ladder logic diagram is similar to that of a relay logic circuit.
There is power rail on the left hand side and a power rail on the right hand side drawn as
vertical lines.
The logic programming is inserted in between the power rails and connected with horizontal
lines to form a logic expression.
Each line of the ladder logic diagram is called a rung.
STOP…. rails and rungs….That’s why the term “Ladder” is used in Ladder Logic…. Light
bulb moment!
However the symbols used are a bit different to the relay logic circuit drawings. Check out
the table below to compare the differences of the basic components…
Relay Logic
Vs Ladder Logic Symbols
If we were to use a latching relay which uses two coils, one to latch (or set) the relay and the
other to un-latch (or reset) the relay. The relay symbols are represented as below….

Ladder Logic Latching Relay


To outline the difference let’s use the example above where a switch is turning two lamps
ON and OFF alternatively.
If we use a PLC with a ladder logic program we firstly need to hard wire the switch to the
input terminals of the PLC. Then we need to hard wire the lamps to the output terminals.
Lastly, we need to write our ladder logic program and load it into the PLC memory.
The diagram below shows a ladder logic diagram when the Rotary Switch is OFF….
Ladder
Logic Diagram – Rotary Switch Off
The diagram below shows a ladder logic diagram when the Rotary Switch is on.
Remember the normally closed contact is reverse logic!

Ladder
Logic Diagram – Rotary Switch On

Ladder Logic Advantages


Some of the advantages that ladder logic control systems have over relay logic control
systems are:
 Installation time is greatly reduced with ladder logic control systems due to the reduced
amount of hard wiring required. In other words, we only need to hard wire the input and
output devices. The control logic is implemented using software not hard wired relays.
 Modifications to the control logic can easily be done using software to modify the ladder
logic program rather than hardware and wiring modifications that would normally be the
case with relay logic control.
 The same PLC can be used for a wide range of control system applications by simply
loading a different ladder logic program into the PLC memory.
 Control system expansion is simplified with a PLC by adding expansion modules as
opposed to complex hardware and wiring modifications that would be the case with relay
logic control.
 Ladder logic is microprocessor based which has faster execution times, is far more reliable
and longer lasting than relay logic control systems which have a large amount of mechanical
components.
 Ladder logic control systems are far more compact than relay logic control systems.
So, in the battle of relay logic vs ladder logic we can confirm that ladder logic is definitely
winning. In fact it can be said that relay logic control systems for larger installations are all
but dead. Some countries still have regulations for burner control panels to be relay logic
controlled, but these will no doubt be eventually replaced with PLC based control systems.
For some smaller installations where you have a handful of devices to control with basic
functionality it’s still handy to use relay logic for controlling the application. But with the
cheap price of PLC’s and the ease of ladder logic programming they are increasingly
attractive for even the smaller applications.
In the next section we’ll build on ladder logic basics and uncover the seven essential rules
that you must know to in order to program a Programmable Logic Controller (PLC) with
ladder logic diagrams along with the basics of implementing PLC ladder logic
programming.
To go to the next section click here.
Parte 9

Ladder Logic Programming


In the very early days of PLC programming ladder diagrams were configured and loaded
into the PLC using dedicated hand held programmers. These hand held programmers were
extremely slow and tedious to use.
Programming was made a lot easier with the introduction of PC’s and interface software
using text based operating systems such as the Microsoft platform MS-DOS. The eventual
move away from text based operating systems and into graphical operating systems such
as Microsoft Windows has in turn led to the development of graphical PLC programming
software.
In fact, the latest software uses many of the operating features that common word
processing software utilizes….
 Menu bar and tool bar system
 Drop down boxes
 Drag and drop capability
 Directory like layout and organization
 Comprehensive search functionality
 Advanced editing functionality
 Multiple window for multitasking
 Data tables for variable declaration
 On the fly variable declaration
 Graphical and tabular debugging features
The latest versions of programming software from the major PLC manufacturers such as
Allen Bradley, Siemens, Omron, Schneider, Unitronics, Idec, Koyo and Mitsubishi have
made even advanced PLC programming easier than ever.
Ladder logic programming is based on the use of ladder diagrams. Therefore writing such
programs for a Programmable Logic Controller (PLC) are very similar to drawing electric
relay control circuits. Ladder diagrams consist of two vertical lines that represent the power
rails. The circuit components are connected as horizontal lines between the two vertical
lines…the rungs of a ladder.

Writing Ladder Logic Programs


In order to learn ladder logic programming there is no need to have experience in other
text based programming languages such as C, BASIC, Pascal and FORTRON. However if
you are an Electrician, Electrical/Electronic Engineer or Student then you will have a basic
understanding of electric circuits and ladder logic programming will be a breeze. If not,
don’t worry, the concepts of ladder logic programming are simple enough to grasp and
you’ll be writing your first line of code in no time at all!
Ladder logic diagrams are structured to look like an electric circuit schematic. The logic
flow is from left to right and simulates the current flow in an electric circuit. The basic logic
expressions can be arranged to form AND, OR and NOT logic operations by implementing
normally open/closed contacts and series/parallel connections.

There is always a left hand side rail and right hand side rail with inputs, logic expressions,
internal variables and outputs packed in between. Each element is interconnected to form a
line of code, called a rung.
Multiple rungs of code end up looking like a ladder….. Hence the name “Ladder Logic”.
The ladder logic diagram below shows the basic components and how they are arranged
when writing a ladder logic program…..
Lad
der Logic Diagram
Because ladder logic is a graphical programming language these days the programming
software is drag and drop, so it makes it very user friendly. The programming software to
write ladder logic code is obtained from the manufacturer and is installed onto your PC.
Some manufacturers have free programming software and some require a software license.
Be careful because software license=$$$$.

Ladder Logic Programming Rules


Every PLC manufacturer has slightly different ladder logic programming rules when it
comes to building the logical expressions contained within a rung. Even a manufacturer
with multiple PLC models can have varying rules depending on processing power of each
PLC model. But there are seven basic rules that all PLC manufacturers use for ladder logic
programming….
1. A PLC scans each rung in the ladder diagram from the left hand side to the right hand side
and from the top to the bottom.
2. The PLC scan runs in a repeated cyclic manner where the inputs are monitored, the rung
logic evaluated and then the state of the outputs are executed. The scan time is expressed in
milliseconds (ms).
3. The logic state of the outputs is evaluated as the program scans through the rungs. But
they are only updated at the very end of each PLC scan, simultaneously.
4. There must be at least one input or logic expression at the start of each rung.
5. There must be at least one output at the end of each rung.
6. Each rung in the ladder diagram represents one logic operation in the overall control
operation.

7. An input, output or logic expression can be used more than once in the ladder diagram.
The same tag name and address is used to label it if used more than once.
To learn more about the PLC scan cycle click here.

Memory Structure For Ladder Logic


Programming  
The memory structure for Ladder Logic Programming is just like that of a computer. It is
made up of bits, bytes, words and double words.
 Bit – The smallest memory unit. It is either 1 (True) or 0 (False).
 Byte – Is made up of 8 bits.
 Word – Is made up of 16 bits or 2 Bytes.
 Double Word – Is made up of 32 bits, 4 Bytes or 2 Words.
Ladder Logic Programming Memory Structure
Defining Variables For Use In Ladder Logic
Programming  
In order for the PLC to process the ladder logic rungs each symbol needs to be allocated to a
variable name weather it’s an input, output or internal data. There are three essential
elements that must be defined when declaring a variable and one optional element.
1. Variable Name – The name must be unique and is used to make the ladder logic easily
readable by human beings, such as yourself. There will be restrictions on the length and
sometimes characters that can be used.
2. Address – the address can be either an Input, Output, Internal or System memory address.
The address nomenclature is dependent on the PLC manufacturer.
3. Data Type – The data type used will depend on the symbol being used and the
programming operation required. Defining a variable as a BOOL (Boolean) means it has a
binary value, an INT (integer) means it has a whole number value and a REAL (floating
point) means it has a number value with a decimal point.
4. Comment – Adding a comment is optional, but can assist in describing the variable if the
amount of characters in the variable name was insufficient.
The table below shows some standard data types, PLC memory allocation and common uses
for each data types.

Ladder Logic Data Types


Different PLC manufacturers use slightly different naming conventions for variables and
memory allocation. It’s just a matter of checking the PLC’s help file to determine what to
use. Some examples of variable addressing nomenclature for different PLC manufacturers is
shown in the table below….

Ladder Logic Programming Data Table

Start Ladder Logic Programming


To start programming you’ll need to get your hands on some software from the PLC
manufacturer. Some PLC manufactures have yearly licensing fees $$ for their programming
software and others have free programming software.
Regardless of what PLC programming software you use every PLC will have an area in
their programming software where the ladder logic programming is done, usually called the
“Main Program”. Now-a-days PLC development software for ladder logic is drag and
drop….it makes it so easy. Grab the symbol in the toolbar and drag it onto the rung. Next
add a variable to the symbol. Most PLC development software allows you to declare
variable as you add symbols.

Remember to add lots of descriptive comments to each rung. It helps with readability and
trouble shooting.
It’s a good idea to keep each rung as simple as possible. Cramming too much into a rung can
save on memory but it can create a really complex network of logic that can come back and
bite you if you need to return at a later date to upgrade or modify your program.
Trust me….you’ll spend ages trying to figure out the monster you’ve created….ouch!
A well written PLC program will ensure your machine or plant will be highly productive,
efficient and with low downtime.

Ladder Logic Programming with Sub-Routines


If the program starts to get quite large then addition of sub-routines are recommended. Some
PLC models will also have additional areas where the sub-routine programming is done.
Either way subroutines can help your ladder logic programming to be easier to read and
assist in troubleshoot by providing a way to organize your code into kind of a filing system.
It’s up to you with regards to naming your subroutines. Remember to create sub routines so
that you can group all the same type of code in the one place. Some examples of possible
sub routines that can be created are…..
 Main Program
 Sequence Steps
 Motor control
 Fault logic
 Interlock logic
 Analogue scaling

Upload And Download Your Ladder Logic


Program
Once your ladder logic program is complete you will need to compile the program. The
compile, button is usually located in the toolbar. Compiling the program is just checking for
syntax, memory and program structural errors. If there are any issues then error messages
will be generated that directly points you to the source of the problem.
Once all the errors are fixed it’s time to download to the PLC. The download button is also
usually located in the toolbar of the PLC programming software.

PLC Upload Vs Download


The PLC is taken to be the point of reference when we talk about program upload and
download. Therefore a PLC Download is transferring the program from your PC to the
PLC. While a PLC Upload is transferring the program from the PLC to your PC.
PLC Upload
Vs Download

Remember To Set Your Ladder Logic


Programming To RUN MODE
So you’ve written the ladder logic program, compiled and downloaded to the PLC, but
nothing is happening ……….You need to put the PLC into run mode.
Run mode simply starts the PLC scan cycle.    
Some PLC’s have a key switch, others have a soft switch done through the PLC
development software (usually some buttons in the toolbar). Either way there should be a
RUN light that illuminates on the face of the PLC……now you’re cooking!

Debugging Your Ladder Logic Program


Ladder logic is great for debugging your program. When you place the PLC development
software in ONLINE mode the symbols in each rung highlight in real time when their
respective conditions are TRUE. So if your rung is fully highlighted all way up to your
output, then the output is TRUE…… Just like current flow in an electric circuit.
To assist in testing and commissioning you can also force the state of binary variables to
TRUE or FALSE and also force analogue variables to a specific value. This can be very
useful, but remember to release all the forced variables after you’ve finished testing your
program.

Most PLC programming software have the facility to create variable tables which display
the variable information and status or value. This gives you a handy display area for
analyzing the status and value of the variables instead of scrolling up and down through
your rungs of code.
With the latest programming software multiple windows, with the program and variables
table, can be displayed simultaneously which comes in super handy when debugging.

Ladder Logic Programming IEC 61131 Standards


International PLC programming standards are contained in IEC 61131 in which ladder logic
programming standards are outlined in IEC 61131 section 3 (IEC 61131-3).
Don’t panic….you don’t have to start learning the IEC 61131-3 standards. All the
IEC61131-3 standard means is that if you learn ladder logic then you’ll be able to apply it to
any manufacturers PLC’s. Good news, right!!
You see, ladder logic and PLC’s have become an extremely popular alternative for
automation control system compared to traditional methods. As it’s popularity grew, so did
the amount of companies manufacturing PLCs. Soon there were a multitude of
manufacturers each with their own version of a PLC programming language. So the
International Electrotechnical Commission published a PLC programming standard to bring
commonality to the various versions of each programming language found in all the
different manufactures PLC’s.
The ladder logic programming language is denoted by (LD) in the IEC 61131-3 standard.
There are other programming languages that are contained in the IEC 61131-3 standard, but
you will find that the most common PLC language is ladder logic. It is by far the best
“foot in the door” when it comes to PLC programming and it can accomplish the majority of
application control tasks.
Nowadays most PLC manufacturers fully or partially support the IEC6111 standard. There
is no obligation for manufactures to comply with the IEC 61131 standard and in fact some
PLC manufacturers have designed their programming software to be more user friendly than
the IEC 61131-3 standard. So it’s good to be aware that the IEC 61131 standard for PLC
programming exists, but there’s no need to get too caught up in it all!

Ladder Logic Programming Samples


The best way to progress from this point is to dive into some ladder logic programming
samples. We can think of a sample ladder logic program as a piece of the overall
programming puzzle. If we create enough ladder logic programming pieces and join them
together we can form a complete program.
In the next section we will begin to investigate programming examples with one of the most
important pieces of ladder logic you’ll ever use.
To go to the next section click here.
Parte 10

Ladder Logic Programming Examples


Experience tells us that once a piece of ladder logic is created that accomplished a specific
task it can be re-used in other areas of the program and in other applications as well. So by
creating ladder logic programming examples we can speed up or overall programming time.
Constructing a program is then a simple matter of grabbing the appropriate ladder logic
programming examples and connecting them in an orderly fashion.

Let’s take a look at some very simple, but extremely important ladder logic programming
examples…

Latching in a PLC
Latching is one of the most important pieces of ladder logic programming that you’ll ever
use.
When we use the term latching in a PLC it refers to changing the state of an output to
TRUE, holding the state of that output TRUE until certain conditions occur, then returning
the state of the output back to FASLE.
This can be achieved with two methods….
1. Set and Reset instructions. In an Allen Bradley PLC they are called Latch and Unlatch
instructions. These instructions simulate the function of an electro-mechanical latching
relay. Advantages include flexibility in programming because the Set (Latch) and Reset
(Unlatch) symbols do not need to be in the same rung. The disadvantage is that debugging
can become more difficult because the Set (Latch) and Reset (Unlatch) symbols may be
scattered throughout the program.
2. Latching logic. Quite often hold in logic is referred to as hold in logic. It’s ok to
interchange the terms. The advantage of latching logic is that troubleshooting is easier
because the symbols used are all in the same rung. The disadvantage is that there is some
inflexibility in programming because latching logic requires all the symbols to be on the
same rung and may even overflow to the next rung. This can be restrictive in some cases.
Simple applications requiring a latch are well suited to use latching logic.
But when it comes to more complex applications the use of Set (Latch) and Reset (Unlatch)
symbols may be required.
Sometimes it just comes to personal preference.
Latching in a PLC requires at least one input to set the latch (Input A), one input to reset the
latch (Input B) and one output to store the latch state (Output Y).
The inputs that set and reset the latch are usually momentary pulses. A great example of a
device that can provide a momentary pulse to a PLC input is a push button.

Ladder Logic Latch with SET & RESET Symbols


Let’s start with the Set (Latch) and Reset (Unlatch) logic. Remember Allen Bradley PLC’s
use Latch and Unlatch symbols.
The rungs below show the basic code.
When both Input A and Input B are FALSE then the state of Output Y does not change. If
Output Y is FALSE then it stays FALSE….

La
dder Logic Programming Examples – Ladder Latch
If Input A goes TRUE momentarily then the SET symbol changes the state of Output Y to
TRUE.
Then, after subsequent scans, if Input A changes state to FALSE it does not affect the state
of Output Y. In other words, Output Y is latched TRUE…
La
dder Logic Programming Examples – Ladder Latch (Set or Latch)
Only when Input B changes state to TRUE will the RESET symbol change the state of
Output Y back to FALSE. In other words, Output Y is now unlatched….

La
dder Logic Programming Examples – Ladder Latch (Reset or Unlatch)
Remember the PLC scan runs from left to right and from top to bottom.
So if both Input A and Input B are TRUE at the same time, then in the ladder diagram above
the first rung is evaluated and Output Y is set TRUE.

But, then the second rung is evaluated and Output Y is set FALSE.

Once the scan reaches the end of the entire program it will execute the state of Output Y as
FALSE.
Ladder Logic Latch with Hold In Logic
Using hold in logic to achieve latching has a similar outcome to using Set (Latch) and Reset
(Unlatch) symbols.
But with hold in logic both Input A and Input B are on the same rung as Output Y. Also, the
way in which the latch is SET and RESET is done differently.
Notice that Input B is a normally closed (NC) contact symbol and Output Y is used twice
and branched (or in parallel with Input A).
Ponder that thought for a second, let’s continue….

Lad
der Logic Programming Examples – Ladder logic latch with hold in logic
Remember the scan goes from left to right and top to bottom.
So the scan starts from the left hand side of the rung and moves right to Input A.

If Input A goes TRUE and Input B is FALSE then Output Y goes TRUE….

The scan continues on with the rest of the program and it cycles back to the rung.
Previously Output Y had changed state to TRUE, so now Output Y that is in a branch across
Output A, also goes TRUE and there is no other change….
When the scan cycles back again from the top, if Input A goes FALSE, with Input B still
FALSE, then Output Y stays TRUE.
This is because Output Y is held in by itself using the branch across Input A.

Notice that the logic flows from the left hand side rail through the Output Y branch and then
through Input B to Output Y at the right hand side rail. Pretty cool…..

La
dder Logic Programming Examples – Ladder hold in logic (Latched)
Once we have triggered the hold in logic using Input A,  Output Y will remain latched even
if Input A goes FALSE.
Output Y will remain latched TRUE until Input B goes TRUE. Because Input B is a
normally closed (NC) contact symbol, when it goes TRUE, the logic flow is blocked and
Output Y goes FALSE. Thus releasing the latch.
Remember the NC contact symbol works like a NOT statement, it’s reverse logic….
So, when the scan cycles back again from the top then Output Y, branched across Input A,
also goes FALSE….

La
dder Logic Programming Examples – Ladder hold in logic (Unlatched)
Once Input B returns to the FALSE state we are back at the start, ready to initiate the latch
again.
We can write out the logic expression above as…
IF  (INPUT A  OR  OUTPUT Y)  AND  NOT (INPUT B)  THEN  OUTPUT Y.
Hold in logic is great to use because it simplifies your code. It enables us to place all the
conditions that initiate and release latch in the same rung. This makes it easier to read and
troubleshoot.

PLC Motor Control
Ladder logic for motor control can be accomplished using hold in logic. Remember it’s ok
to also call it latching logic.
Simple ladder logic for motor control using push button start stop logic includes a start
button, stop button, motor thermal overload and motor run contactor.
When we wire up the inputs to the PLC the start push button input is wired normally open
(NO). So when the start button is pushed the PLC input changes state from FALSE to
TRUE…

PL
C Wiring Basics – Start button
But the stop push button and thermal overload are always wired normally closed (NC). So
when the stop button is pushed it changes from CLOSED to OPEN. In turn the PLC input
changes state from TRUE to FALSE….

PL
C Wiring Basics – Stop Button
In fact the rule of thumb is that any device that is required to stop the motor should be wired
normally closed (NC), to make it “fail safe”.
The most common failures are wire break, device failure or PLC input failure.

Wiring the stop push button normally closed (NC) is done because when a failure occurs in
the PLC input circuit it will, more often than not, lead to an open circuit which changes the
state of the PLC input from TRUE to FALSE.
However, if we wire the stop PLC inputs as normally open (NO) and a failure occurs then
the state of the PLC input does not change. It stays FALSE, even if the stop button is
pressed, because there is an open circuit in the connection to the PLC input.
So if there is no change in state, we cannot tell the motor to stop in our ladder logic
program. This is really bad!!!
So for any PLC input that is intended to stop the motor we need to..…
WIRE THE MOTOR STOP SIGNALS NORMALLY CLOSED AND USE A NORMALLY
OPEN SYMBOLS IN THE PLC.
Now that we’ve grasped the concept of the fail safe stop input let’s move on to the motor
control ladder logic programming example.
Motor Control Ladder Diagram
First up let’s list the required inputs and outputs for our motor control ladder diagram.
PLC manufacturers use different memory address allocation so the input output allocations
used here are arbitrary address.
Below is the list of required inputs …..

Next let’s list the required outputs…..

The ladder logic programming example uses the M1 START push button input to activate
the M1 RUN output.
The M1 RUN output is used a second time to latch the M1 RUN output.
Both M1 STOP and M1 TOL are wired normally closed (NC) to the PLC inputs and thus
need to be configured as normally open (NO) symbols in the logic.
So when either stop is activated the logic flow is broken and the latch is reset….

La
dder Logic Programming Examples – Motor Control Ladder Diagram
Remember, we must wire M1 Stop and M1 TOL using normally closed (NC) contacts to the
PLC inputs to make it “fail safe” and for this motor control ladder diagram to work.
If you don’t know what the heck I’m talking about you’ve probably skipped straight to the
motor control ladder diagram. Please….Go back and read the section above to get full
bottle on latching logic…..It’s important!
PLC Wiring Basics
If you are still a little confused about the different PLC wiring and ladder diagram symbol
combinations and their different logic states then….DON’T PANIC!
To help out we’ve developed a nifty table which displays the different combinations of PLC
digital input wiring and ladder logic symbols that can be used.
Further more, it outlines the logic state each of the ladder logic symbols depending on
whether the PLC input is activated or de-activated. When the symbol is BLACK it’s state is
FALSE and when the symbol is GREEN it’s state is TRUE.

PLC
Wiring Basics and Ladder Logic Symbols
In the next section we’ll build on our newly discovered knowledge by exploring the timer
symbol and it’s use in PLC motor control.
To go to the next section click here.
Parte 11

PLC Timer
There are various types of PLC timers used in ladder logic programming. By far the most
common PLC timer is the ON delay timer.
The symbol for an ON delay timer is expresses differently depending on the PLC
manufacturer.

But all ON delay timers have four essential elements…..


1. Tag/Address
2. Start Input
3. Done Output
4. Preset Time Value
Some PLC manufacturers also have accumulated time value, remaining time value, a time
base value (seconds, milliseconds, etc) and timer reset input.
A basic symbol for an ON delay timer in PLC ladder diagram is shown below….

Timer in PLC Ladder Diagram


The ON delay timer is activated when the start input is TRUE.
After the preset time expires then the DONE output also goes TRUE.

If at any time the start input goes FALSE the timer is reset and the done output goes to
FALSE.
Check out the timing chart below to get a better picture of how the ON delay timer works….

Timer in PLC Ladder Diagram ON Delay Timer Timing Chart


PLC Timer Example
Let’s build on the previous example of motor control using latching logic. To jump to the
previous example of motor control using latching logic click here. We can introduce a
warning siren in order to let operators know that the motor is about to start. But we need to
add an ON delay timer in order to delay the motor from starting.
Because we are trying to accomplish two actions (siren and motor run) we’ll need to add an
intermediate internal variable to replace M1 Run output.

Let’s call the internal variable Start Command with address M1.0 (remember PLC
manufacturers use different memory address allocation so M1.0 is an arbitrary address).
Then we can use the Start Command to trigger each action on a different rung and add the
required control logic.
Below is the list of required inputs, no change …..
Next let’s add the extra siren output…..

We need to add an extra internal variable…..

Finally let’s add the ON delay timer…..

Remember, we must wire M1 Stop and M1 TOL using normally closed (NC) contacts to the
PLC inputs to make it “fail safe” and for this motor control ladder diagram to work. For a
refresher, click here to jump the motor control using latching logic example.
Check out the motor control ladder diagram with delay start warning siren below……
Mot
or Control Ladder Diagram – Delay Start Warning Siren
The first rung works the same as the standard motor control latching logic. 
The difference is we replace the M1 Run output with an internal variable called Start
Command. So now we can use the Start Command latch to trigger multiple actions.

After the first rung is scanned it moves to the second rung. If the Start Command is TRUE
from the motor control latching logic on the first rung and the M1 Run output is FALSE
(motor is not running) then the Siren output is activated.
Please Note – The M1 Run symbol is triggered from the third rung.
The scan then jumps to the last rung and if the Start Command is TRUE then timer T1 is
activated.
After the Start Command is TRUE for ten seconds (preset time) the T1 ON delay timer will
activate the M1 Run output. Therefore Motor No.1 will start running.
That’s not the end of the story, because the siren is still activated. So, when the PLC scan
cycles back to the top and moves through the rungs.
If the stop inputs have NOT been triggered, the Start Command latch will still be active.
So, when the scan gets to the second rung the Start Command is still TRUE and the M1 Run
output is also TRUE (the motor is running).
On the second rung the M1 Run output is normally Closed (NC). So when it is TRUE no
logic flows and the Siren output goes FALSE and switches off.

If either of the stop inputs are activated then logic flow is broken in the latching logic of the
first rung and the Start Command goes FALSE. This also breaks the logic flow in the second
and third rungs resulting in the motor stopping.
If either of the stop inputs are activated during the ten second starting time, while the siren
is activated, then the logic flow to the Siren output is also broken and the siren de-activates.

On Off Timer
On off timer logic is often referred to as flasher logic. Why? Because, among other things,
we can use it to make lights flash on and off.
It’s basically a two step cyclic sequence based on time. Both the on and off times are
adjustable.
We can develop this code with two ON delay timers and two rungs of ladder logic
programming.
The preset time of the first timer dictates the OFF time and the preset time of the second
timer dictates the ON time.
This can prove handy when you have an application that requires two different cycle times.
Such as a plastic shredder that runs forward for 60 seconds and then reverses for 5 seconds
cyclically to reduce jamming.
On Off Timer Example
Let’s use the motor control ladder diagram example above and add a flashing warning light.
It will activate after the siren has finished and the motor starts running. In this case we
would use the M1 Run output to trigger our timing circuit.
We need to add an extra output, internal variable and two ON delay timers.
Below is the list of required inputs, no change …..

Next let’s add the extra light output…..


We need an extra internal variable for the timers…..

Finally let’s add the two extra ON delay timers…..

Check out the PLC on off timer ladder diagram which we can tack onto the bottom of the
previous ladder diagram….

On
Off Timer Ladder Diagram – Delay Start Warning Siren and Flashing Warning Light
When the PLC scan hits the first rung it comes across the M1 Run output symbol.
If the motor is running this symbol will be TRUE and the logic will flow to the next symbol
M1 Light Timer.
The M1 Light Timer symbol is normally closed (NC) and will be FALSE because timer T3
(on the second rung) is not active and done. This means the M1 Light Timer symbol allows
logic flow to timer T2.
Timer T2 starts timing and after 1 second  timer T2 done output goes TRUE. So then logic
flows to M1 Light output and it too goes TRUE.
Then the PLC scan moves to the second rung where M1 Light output is now TRUE
allowing timer T3 to start timing.
While timer T3 is timing the logic flow is broken therefore M1 Light output is FALSE.
The scan keeps cycling through the rungs until the 1 second preset time for timer T3 has
expired. Then time T3 done output goes TRUE. Logic flows to M1 Light Timer output and
it too goes true.
When again the scan cycles back to the top and moves through the first rung  we notice that
M1 Light Timer has changed state from FALSE to TRUE. Thus breaking the logic flow.
As the scan progresses through the rungs M1 Light output, timer T3 and M1 Light Timer all
go back to a FALSE state. Effectively resetting the timer sequence.
So when the scan cycles back to the top it starts the timing cycle once again.
M1 Light will be OFF for T1 time preset and ON for T2 timer preset.
The timing cycle will continue until the motor stops running, when the M1 Run symbol
changes state to FALSE.
In the next section we’ll discover the four fundamental elements required to structure
sequence logic and apply it to automate a real life application.
To go to the next section click here.

Você também pode gostar