Escolar Documentos
Profissional Documentos
Cultura Documentos
https://www.sciencedirect.com/science/article/pii/S1474667017337114
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.
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.
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….
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
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.
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.
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 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.
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 .....
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.
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.
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
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:
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…
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….
Congratulations…. you have just simulated a PLC latching logic using ladder logic
simulator software.
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.
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.
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.
After the magnifying glass icon is selected the Element Browser table will popup. Fill it in
as per below….
And then click Select.…
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.…
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….
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….
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….
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
Compared to text based programming languages, ladder logic programming is a lot easier to
use.
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.
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….
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.
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….
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
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.
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.
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.
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.
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.
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….
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.
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.
Operation:
If the input condition transitions from FALSE to TRUE then the output is ON, for the time
taken to do one PLC scan.
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.
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.
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.
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.
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.
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
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 Diagram – Rotary Switch On
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=$$$$.
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.
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.
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.
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.
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 …..
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.
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….
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…..
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 …..
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.