Unit 1
Unit 1
Unfortunately, every PLC manufacturer had its own version of ladder diagram programing. This variation in
programming grew as PLCs were developed to handle a wider range of tasks. Today, most PLCs can still use ladder diagram
(LAD) programing, but the IEC 61131 international standard now defines this PLC programming
language.
This same standard also defines other types of programming languages available for PLCs, so that they can be used for
the even the most complex applications.
International Electrotechnical Commission (IEC), five standard languages are
1).Ladder Diagram (LD)
2.)Function Block Diagram (FBD)
3 )equential Function Chart (SFC)
4 )Instruction List (IL)
5 )Structured Text (ST)
programming blocks:
Organization Blocks (OBs) : called by OS there are multiple OB s for different functionality) like
start OBS, interrupt Obs , Error handling Obs etc)
Functions (FCs) : To make programme modular and structured , does not have data block
associated with it.
Function Blocks (FBs) : To make programme modular and structured have data block associated
with it
Data blocks: memory blocks to store the instance data
FB and FC are called inside from OB
Types of Program Blocks
Organization Block for Cyclic Program Processing (OB1)
1 The operating system starts the cycle monitoring time.
2 The CPU reads the state of the inputs of the input modules and updates the
process image table of the inputs.
3 The CPU processes the user program and executes the instructions contained in
the program.
4 The CPU writes the values from the process image table of the outputs to the
output modules.
5 At the end of a cycle, the operating system executes any tasks that are pending,
for example downloading and deleting blocks, receiving and sending global data.
6 Finally, the CPU returns to the start of the cycle and restarts the cycle
monitoring time.
Scan Cycle Time: PLC cycle time is defined as the time it takes to run the cyclic code start to
finish once with interrupts.
Cycle Monitoring Time: configured in the project . PLC starts monitoring the time for cyclic
execution. If it exceeds the configured cycle monitoring time , error handling OB is called if
nothing is programmed for error OB,the goes into stop mode
OR
Program scanning in organization block OB 1 is monitored by the so-called “scan cycle
monitor”
or “scan cycle watchdog”. The default value for the scan cycle monitoring time is 150 ms. You
can change this value in the range from 1 ms to 6 s by parameterizing the CPU accordingly. If
the main program takes longer to scan than the specified scan cycle monitoring time, the CPU
calls OB 80 (“Timing error”). If OB 80 has not been programmed, the CPU goes to STOP.
Process Images table : memory with CPU from where i/o status is stored
Hardware Logic: Actual or physically connected sensors wires etc
Hardware Logic:
Normally Open Input switches/sensor/ actuator: When inactive sends 0 to PLC/ input image process table
Normally closed Input switches/sensor/ actuator When inactive sends 1 to PLC/ input image process table
Software Logic:
Normally Open Instruction: When receives 0 from image table then RLO is 0
Normally closed Instruction : When receives 0 from image table then RLO is 1
When receives 1 from image table then RLO is 1
Explain the difference between ‘real’ NC contacts and NO contacts connected in
the hardware, and programmed check symbols...
Result of Logic Operation (RLO)
Flip Flops
Timers and Counters
Timers and counters are extremely useful PLC instructions. Timers allow PLCs to control and monitor time-dependent
aspects of machines and processes. Counters allow PLCs to keep track of actions or events. The IEC 61131 standard
identifies PLC programming languages and standardizes the instructions available. Some Siemens S7 PLCs were already in
use when the IEC 61131 specification was developed. This is noticeable when reviewing the SIMATIC timer and SIMATIC
counter instructions available for S7-300 and S7-400 PLCs. While the tasks performed by SIMATIC timers and counters are
similar to those performed by IEC timers and counters, there are noticeable differences. Keep in mind that S7-300 and
S7-400 PLCs also allow IEC timers and IEC counters to be implemented through use of system function blocks.Because
S7-1200 and S7-1500 PLCs were developed well after the deployment of IEC 61131, these PLCs include IEC timers and
counters as basic instructions. Therefore, to minimize the complexity of this lesson, the IEC timers and counters included
are consistent with those used with S7-1200 PLCs.
A TP timer, also called a pulse timer, is an instruction that generates a pulse at output parameter (Q) when the input parameter
(IN) transitions from 0 to 1, unless the timer has already started timing. The pulse duration is defined by the preset time
parameter (PT). The elapsed time (ET) increases from 0 to the preset time during the pulse duration and is retained until IN
transitions from 1 to 0. The PT and ET values are stored in a data block (DB). The accompanying graphic shows a TP timer in a
network and an associated timing diagram. Note that PT is set to 10 seconds. When the I1.0 contact closes at time T1, IN
transitions from 0 to 1. This starts the timer timing and causes Q and output Q2.3 to transition from 0 to 1. At time T2, when ET
reaches 10 seconds, the timer stops timing, and Q and output Q2.3 are reset to 0. The 10 seconds elapsed time is retained until
time T3 when the I1.0 contact opens, and IN and ET are reset to 0. This sequence begins again at time T4 when the I1.0 contact
closes. However, the TP timer continues to time and Q, and output Q2.3 remain on when IN is reset to 0 during the preset time.
At T5, the elapsed time reaches 10 seconds and Q and output Q2.3 are reset to 0. Because IN is already at 0, ET is also reset to
0. is already at 0, ET is also reset to 0.
TON Timer Box Instruction:
A TON timer, also called an on-delay timer, is an instruction that begins timing when the input parameter (IN) transitions from 0
to 1. When the elapsed time (ET) reaches the preset time (PT), the output parameter (Q) transitions from 0 to 1. Q remains a 1
until IN transitions from 1 to 0. If IN
transitions from 1 to 0 before ET is equal to PT, the timer stops timing, ET is reset to 0, and Q remains a 0. The PT and ET values
are stored in the data block (DB) associated with the instruction.
A TOF timer, also called an off-delay timer, is an instruction that sets the output parameter (Q) to 1 when input parameter (IN)
transitions from 0 to 1. However, the TOF timer does not begin timing until IN transitions from 1 to 0. When the elapsed time
(ET) reaches the preset time (PT), Q transitions from 1 to 0. Q remains a 0 and the elapsed time is retained until the next 0 to 1
transition of IN. The PT and ET values are stored in the data block (DB) associated with the instruction.
A TONR timer, also called an on-delay retentive timer, is an instruction that begins timing when the input parameter (IN)
transitions from 0 to 1. If IN transitions from 1 to 0, the elapsed time (ET) is retained. When IN again transitions from 0 to 1,
the timer resumes timing from the retained ET
value. When ET reaches the preset time (PT), the timer stops timing, and the output parameter (Q) transitions from 0 to 1.
When the reset parameter (R) transitions from 0 to 1, ET and Q are reset to 0, even if IN remains a 1. The PT and ET values are
stored in the data block (DB) associatedwith the instruction.
For LAD programs, S7-1200 PLCs support the IEC counter instructions shown in the accompanying graphic. CU, CD, and CTUD
counter instructions use software counters with a maximum counting rate that is limited by the execution rate of the
organization block (OB) they are placed in. S7-1200 PLCs also provide high-speed counters for counting events that occur
faster than can be handled by IEC counters. Each IEC counter instruction uses a data block (DB) to maintain counter data. The
number of counter instructions that you can use in a user program is limited only by the amount of memory in the CPU. The
amount of memory required for an instruction depends on the data type selected to store count values; therefore, it makes
sense to choose the data type that matches the application requirements.
Program for Lamp on 5 sec , Off 6 sec and repeat 7 times and stop
Basics of PLC programming
Assignment :
Two switches A and B are used to ON and Off the lamp. If any one switch is activated and other
is deactivated Lamp will be ON and if both switches are activated or deactivated lamp will be
off.
Hint:
Assignment :
Two switches S1 and S2 are used to ON and Off the lamp. if both switches are activated or
deactivated lamp will be ON. If any one switch is closed and other is open Lamp will be off.
A B
B
A
B
A
B
A
Assignment 1:
A warehouse is used to store industrial chemicals. Toxic fumes produced by chemicals are
removed from the warehouse using three exhaust fans. These fans should continuously work.
Three sensors are used detect the failure of fans. These sensors are connected to PLC. The
output of PLC is used to activate alarm which indicates failure of one or more exhaust fan.
Assignment 2:
Prepare ladder logic such that if any one of these sensors generates logic 1 output machine
should stop.
This example will show the practical aspect of programming in Step 7 with a
real, existing part of a system. A motor starter coil (M) is wired in series with a
normally open, momentary Start push-button, a normally closed, momentary
Stop push-button, and normally closed overload relay (OL) contacts.
PLC Motor Control
The motor control application can also be accomplished with a PLC. In the following example, a
normally open Start push-button is wired to the first input (I0.0), a normally closed Stop push-button
is wired to the second input (I0.1), and a normally closed overload relay contacts (part of the motor
starter) are connected to the third input (I0.2). These inputs are used to control normally open
contacts in a line of ladder logic programmed into the PLC.
Initially, I0.1 status bit is a logic 1 because the normally closed (NC) Stop push-button is closed.
I0.2 status bit is a logic 1 because the normally closed (NC) overload relay (OL) contacts are
closed. I0.0 status bit is a logic 0, however, because the normally open Start push-button has not
been pressed.
Normally the open output Q0.0 contact is also programmed on Network 1 as a sealing
contact. With this simple network, energizing the output coil Q0.0 is required to turn on the
motor. When the Start push-button is pressed, the CPU receives a logic 1 from input I0.0. This
causes the I0.0 contact to close. All three inputs are now a logic 1. The CPU sends a logic 1 to the
Q0.0 output. The motor starter is energized and the motor starts.
The output status bit for Q0.0 is now equal to 1. On the next scan, when the normally open
contact Q0.0 is solved, the contact will close, and the output Q0.0 will stay on, even if the Start
push-button is released.
When the Stop push-button is pressed, the input I0.1 turns off, the I0.1 contact opens, the
output coil Q0.0 de-energizes and the motor turns off.
Sequence control :
Sequence control is a means of control for systems with an innately step-by-step nature, whereby the advance from
one step to the following step in a program depends on step enabling conditions (transition conditions, transitions).
sequence control is very frequently used since many production and process systems involve a step-by-step
sequence of events.
Step-by-step sequences can be clearly and simply described through the individual steps of the sequence control
program. Once the logic diagram of the sequence control is established (specified), converting it into a PLC program
can be accomplished systematically.
Steps are represented by boxes and are connected by lines. The initial step to be taken when the control gets activated is
marked by a double frame. The example contains three steps that are marked by the numbers 1, 2 and 3.
Step (transition) conditions are indicated by a dash crossing the lines between steps. Alongside these dashes is a name
that represents the conditions under which the sequence proceeds to the next step (in the example: Trans12, Trans 23,
Trans34).
Commands (actions) are also depicted as boxes and are each assigned to a single step.
One or more commands can be issued from a step while it is active. Commands are used to control actuators (valves and
motors) in a system. A command's action depends on the command type which is indicated by graphic supplements.
Only the frequently needed command types are considered next.
Continuously acting command (or non-stored command) and Stored command.
continuous (non-stored) command is represented by a simple rectangle. Such commands remain in effect only while their
sources are active. In the case of a continuous command, the controlled actuator remains active only for as long as the
related step remains set. When the step is reset, the actuator is deactivated.
stored command results in lasting activation of an actuator over several steps until the actuator is deactivated by another
stored command. This type of command proves practical when actuator needs to remain active over several consecutive
Transition condition for step 1-> step 2: The workpiece carrier is at the left-hand limit (I_IMS3_IL=1) and sensor -B4
indicates a full magazine (I_IMS3_B4=1). This is the home position. Actuating the start button (I_IMS3_START=1) then
causes the control unit to proceed with step 2.
Commands for step 2: Activate rightward travel with a non-stored command and trigger the stopper with a stored
command.
Transition condition for step 2 -> step 3: 1 s after activation of step 2, the control unit commences step 3.
Commands for step 3: Continue rightward travel, activate and maintain creep mode.
Transition condition for step 3 -> step 4: 1 s after activation of step 3, the control unit commences step 4.
Transition condition for step 4 -> step 5: After a waiting period of 1 s, the control unit commences step 5.
Commands for step 5: Reset the stopper with a stored command (Q_IMS3_M1).
Transition condition for step 5 -> step 6: If sensor -B3 is triggered (I_IMS3_B3=1) and a waiting period of 1 s elapses, the
control unit commences step 6.
Commands for step 6: Continue rightward travel (Q_IMS3_QR=1).
Mixer Application:
a) Pump1 and pump 2 to pump two different liquids into tank.
b) Two level switches Level and H_ level ( NO) and one
emergency stop switch.
c) one mixer motor
d) one discharge valve
e) both pumps starts when liquid level goes below L_ level and
stops when liquid level researches H_ level.
f) Then mixer is turned on for 5 sec.
g) after 5 sec mixer turns off and discharge valve is opened.
h) discharge valve remains on till liquid level drops to L_ level
I ) the process repeats