PLCLab Manual Final
PLCLab Manual Final
Objective
• To construct PLC programs in LAD using Siemens Step 7-Micro/Win 32.
• To run and debug the programs on S7-200 PLC.
Introduction to PLC
Controllers may consist of logical components and connections among them. Depending on the
current logical value of input, output is produced to change the status of the system. PLC may realize
such controllers.
Today, the command and feedback control systems of industrial automation systems are realized by
programmable logic controllers (PLCs). Siemens Simatic S7-200 is one of the PLC brands widely used
in industry.
In order for PLCs to work as controllers, they must be able to realize some functions. These functions
are basic and combinational logic operations such as AND, OR, AND-NOT, OR-NOT, timer and
counter operations. In addition to these, PLCs may have the ability to realize several transfer,
mathematical, and PID operations.
PLC consists of three main parts: CPU, memory and I/O units.
CPU is the brain of PLC. It reads the input values from inputs, runs the program existed in the program
memory and writes the output values to the output register. Memory is used to store different types of
information in the binary structure form. The memory range of S7-200 is composed of three main parts
as program, parameter, and retentive data fields. I/O units provide communication between PLC
control systems.
There are mainly two methods for composing PLC programs: Ladder Logic Diagram (LAD) and
Statement List (STL). LAD method is commonly used to implement the programs for process controls.
A network of LAD is a row of connected elements that form a complete circuit between the left and
right power rail. The left power rail represents the energized conductor whereas the right power rail
represents the return path conductor of the circuit. Power flows from the left rail, through the closed
contacts to the coils or boxes connected to the right power rail. You can then use the power flow to
activate the outputs according to your program.
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
You can also switch between LAD and STL by selecting Ladder or STL from View menu. By this way,
you can see how LAD and STL relate to each other.
In STEP 7-Micro/WIN 32, click on New option in the Project menu for new project. After composing
program, click the Compile button on the taskbar. By clicking this button, software translates the
program code block into machine language for execution by the CPU. A program can not be
downloaded to the CPU until it is compiled. If there is an error in your program, your program will not
be compiled and software will warn you about the errors in your program. After correcting errors, try to
compile again.
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
You can save your work by clicking Save All option in the Project menu. You can also load existed
projects by clicking Open option in the Project menu
When the program is compiled successfully, click on the Download button on the taskbar to transfer
the compiled program to the PLC. During this operation, be sure that PLC is STOP or TERM mode.
When the transfer is completed, switch the PLC to RUN mode or click RUN button in the toolbar.
Now, PLC is running. Switch the inputs ON and OFF, and observe the change on outputs of the PLC
module. Check if your program works correctly.
You can also transfer the existed program in PLC to PC. In a similar way, when the PLC is STOP
mode, click on the Upload button on the taskbar. When the operation is completed, you can see the
program code existed in PLC on computer screen. Now you can modify the program if it is necessary.
You can change the mode of PLC to either RUN, STOP or TERM using the switch on the PLC
module.
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
PRACTICAL – 2
Objective
• To study the operation of bit logic instructions.
• To construct PLC program using the bit logic instructions.
Contacts
Standard Contacts
The Normally Open contact instructions (LD, A, and O) and Normally Closed contact instructions (LDN, AN, ON)
obtain the referenced value from the memory or from the process-image register. The standard contact
instructions obtain the referenced value from the memory (or process-image register if the data type is I or Q).
The Normally Open contact is closed (on) when the bit is equal to 1, and the Normally Closed contact is closed
(on) when the bit is equal to 0. In STL, the Normally Open instructions Load, AND, or OR the bit value of the
address bit to the top of the stack, and the Normally Closed instructions Load, AND, or OR the logical NOT of the
bit value to the top of the stack.
Immediate Contacts
An immediate contact does not rely on the S7-200 scan cycle to update; it updates immediately. The Normally
Open Immediate contact instructions (LDI, AI, and OI) and Normally Closed Immediate contact instructions (LDNI,
ANI, and ONI) obtain the physical input value when the instruction is executed, but the process-image register is
not updated. The Normally Open Immediate contact is closed (on) when the physical input point (bit) is 1, and the
normally Closed Immediate contact is closed (on) when the physical input point (bit) is 0. The Normally Open
instructions immediately load, AND, or OR the physical input value to the top of the stack, and the Normally
Closed instructions immediately Load, AND, or OR the logical NOT of the value of the physical input point to the
top of the stack.
NOT Instruction
The Not instruction (NOT) changes the state of power flow input (that is, it changes the value on the top of the
stack from 0 to 1 or from1 to 0).
Coils
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
Output
The Output instruction (=) writes the new value for the output bit to the process-image register. When the Output
instruction is executed, the S7-200 turns the output bit in the process-image register on or off. For LAD, the
specified bit is set equal to power flow. For STL, the value on the top of the stack is copied to the specified bit.
Output Immediate
The Output Immediate instruction (=I) writes the new value to both the physical output and the corresponding
process-image register location when the instruction is executed. When the Output Immediate instruction is
executed, the physical output point (Bit) is immediately set equal to power flow. For STL, the instruction
immediately copies the value on the top of the stack to the specified physical output bit (STL). The “I” indicates an
immediate reference; the new value is written to both the physical output and the corresponding process-image
register location when the instruction is executed. This differs from the non-immediate references, which write the
new value to the process-image register only.
If the Reset instruction specifies either a timer bit (T) or counter bit (C), the instruction resets the timer or counter
bit and clears the current value of the timer or counter.
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
PRACTICAL - 3
Timers
Objective
• To study the operation of different types of timers.
• To use the PLC timers in a process control.
Timer Instructions
On-Delay Timer
Off-Delay Timer
The Off-Delay Timer (TOF) is used to delay turning an output off for a fixed period of time after the
input turns off.
The timer number (Txx) determines the resolution of the timer, and the resolution is now shown in the
instruction box.
10
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
Table 4-2 Operations of the Timer Instructions
The TON and TONR instructions count time when the enabling input is on. When the current value is
equal to or greater than the preset time, the timer bit is on.
• The current value of a TON timer is cleared when the enabling input is off, whereas the
current value of the TONR timer is maintained when the input is off.
• You can use the TONR timer to accumulate time when the input turns on and off. Use the
Reset instruction (R) to clear the current value of the TONR.
• Both the TON and the TONR timers continue counting after the preset is reached, and they
stop counting at the maximum value of 32,767.
The TOF instruction is used to delay turning an output off for a fixed period of time after the input turns
off. When the enabling input turns on, the timer bit turns on immediately, and the current value is set to
0. When the input turns off, the timer counts until the elapsed time reaches the preset time.
• When the preset is reached, the timer bit turns off and the current value stops incrementing;
however, if the input turns on again before the TOF reaches the preset value, the timer bit
remains on.
• The enabling input must make an on-to-off transition for the TOF to begin counting time
intervals.
• If the TOF timer is inside an SCR region and the SCR region is inactive, then the current value
is set to 0, the timer bit is turned off, and the current value does not increment.
You can reset a TONR only by using the Reset (R) instruction. You can also use the Reset instruction
to reset any TON or TOF. The Reset instruction performs the following operations:
• Timer Bit = off
• Timer Current = 0
After a reset, TOF timers require the enabling input to make the transition from on to off in order for the
timer to restart.
To guarantee a minimum time interval, increase the preset value (PV) by 1. For example: To ensure a
minimum timed interval of at least 2100 ms for a 100-ms timer, set the PV to 22.
11
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
Table 4-3 Timer Numbers and Resolutions
To guarantee that the output of a self-resetting timer is turned on for one scan each time the timer
reaches the preset value, use a normally closed contact instead of the timer bit as the enabling input
to the timer.
12
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
PRACTICAL - 4
Counters
Objective
• To study the operation of different types of counters.
• To use the PLC counters and timers in a process control.
Counter Instructions
Count Up Counter
The Count Up instruction (CTU) counts up from the current value each time the
count up (CU) input makes the transition from off to on. When the current value
Cxx is greater than or equal to the preset value PV, the counter bit Cxx turns
on. The counter is reset when the Reset (R) input turns on, or when the Reset
instruction is executed. The counter stops counting when it reaches the
maximum value (32,767).
STL operation :
• Reset input: Top of stack
• Count Up input: Value loaded in the second stack location
The Count Up/Down instruction (CTUD) counts up each time the count up (CU) input makes the
transition from off to on, and counts down each time the count down (CD) input makes the transition
from off to on. The current value Cxx of the counter maintains the current count. The preset value PV
is compared to the current value each time the counter instruction is executed. Upon reaching
maximum value (32,767), the next rising edge at the count up input causes the current count to wrap
around to the minimum value (-32,768). On reaching the minimum value (-32,768), the next rising
edge at the count down input causes the current count to wrap around to the maximum value
(32,767).
When the current value Cxx is greater than or equal to the preset value PV, the counter bit Cxx turns
on. Otherwise, the counter bit turns off. The counter is reset when the Reset (R) input turns on, or
when the Reset instruction is executed. The CTUD counter stops counting when it reaches PV.
Since there is one current value for each counter, do not assign the same number to more than one
counter. (Up Counters, Up/Down Counters, and Down counters with the same number access the
same current value.) When you reset a counter using the Reset instruction, the counter bit is reset and
the counter current value is set to zero. Use the counter number to reference both the current value
and the counter bit of that counter.
13
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
14
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
PRACTICAL - 5
Objective
• To use jump and subroutine in a process control.
Jump Instructions
The Jump to Label instruction (JMP) performs a ranch
to the specified label N within the program. The Label
instruction (LBL) marks the location of the jump
destination N.
Subroutine Instructions
The Call Subroutine instruction (CALL) transfers control to
the subroutine SBR_N. You can use a Call Subroutine
instruction with or without parameters. After the subroutine
completes its execution, control returns to the instruction that
follows the Call Subroutine.
15
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
itself) is not prohibited, but you should use caution when
using recursion with subroutines.
When a subroutine is called, the entire logic stack is saved, the top of stack is set to one, all other stack locations
are set to zero, and control is transferred to the called subroutine. When this subroutine is completed, the stack is
restored with the values saved at the point of call, and control is returned to the calling routine.
Accumulators are common to subroutines and the calling routine. No save or restore operation is performed on
accumulators due to subroutine use. When a subroutine is called more than once in the same cycle, the edge/up,
edge/down, timer and counter instructions should not be used.
16
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
Parameter Types for a Subroutine
BOOL: This data type is used for single bit inputs and outputs. IN3 in the following example is a Boolean
input.
BYTE, WORD, DWORD: These data types identify an unsigned input or output parameter of 1, 2, or 4 bytes,
respectively.
INT, DINT: These data types identify signed input or output parameters of 2 or 4 bytes,
respectively.
REAL: This data type identifies a single precision (4 byte) IEEE floating-point value.
Power Flow: Boolean power flow is allowed only for bit (Boolean) inputs. This declaration tells STEP 7-Micro/WIN
that this input parameter is the result of power flow based on a combination of bit logic instructions. Boolean
power flow inputs must appear first in the local variable table before any other type input. Only input parameters
are allowed to be used this way. The enable input (EN) and the IN1 inputs in the following example use Boolean
logic.
17
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
PRACTICAL - 6
Math Instructions
Objective
• To use some math instructions in a process control.
18
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
IN1 * OUT = OUT STL
Decrement
IN -- 1 = OUT LAD
OUT -- 1 = OUT STL
19
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
PRACTICAL – 7
Experimental Work
The system to be controlled by PLC consists of two belts. If the Start button is pressed, Conveyor
Belt-1 will begin to run. After 5 seconds Conveyor Belt-2 will be active. After the whole system runs
for 15 seconds, Conveyor Belt-1 will stop. Then Conveyor Belt-2 continues to move for 5 seconds
and then it will stop, too. Also the system can be reset by the emergency-stop button at any time.
Construct a LAD for S7-200 PLC to control the system.
20
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
21
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
PRACTICAL – 8
A PLC-controlled system operates as follows. If the Start button is pressed, MV1 will be
opened and dye starts to fill the tank. At the same time mixing-motor begins to run. As the
level of the dye passes TBL2 and reaches to TBL1, MV1 will be closed and mixing-motor
will stop. Then MV2 will be opened and dye begins to run out of the container. After the
level of the dye reaches to the below of TBL2, MV2 will be closed. This process is repeated
for two (2) times, then the system will stop.
We can observe the stopping of the system with the lamp and the buzzer.
After the system stops, buzzer will continue to run for 2 sec and then it stops. But the lamp
continues to light until the reset button is pressed. When the reset button is pressed, the
system will be ready to begin the same process again. Construct a LAD for this system.
22
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
23
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
PRACTICAL – 9
The parking lot which has a capacity of 100 cars is to be controlled by a PLC system. The
sensor S1 and S2 are used to count the car at the entrance and exit. If the number of the
cars reaches to 100, red light is lit and the gate arm is closed. The arm stays closed until one
or more parking space is available in the lot. The gate arm is controlled by
activating/deactivating the gate solenoid (GS).
Construct LAD for the parking lot controller by using math instructions. Do not use counter
instructions.
Input
Start and stop buttons
Sensors S1 and S2
Output
Gate Solenoid
Light
24
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
25
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
PRACTICAL – 10
An automatic stamp system shown in Figure 2 works as follows: When start switch is turned
on, system gets ready to run. When the operator puts a box at the beginning of the conveyor
(on LS1) the motor runs and conveyor moves. Upon reaching the mid point of the conveyor
(on LS2) the conveyor motor stops. Then the stamp comes down and puts the stamp on the
box. When this process is finished, the stamp goes up and conveyor moves again to the
other end of the conveyor. After box reaches to end of the conveyor (on LS3), the motor
stops. The system waits for the box to get and the another box to be placed at the beginning
of the conveyor. If start switch is turned off, the system can not run even if there is a box on
conveyor. The light on the start box indicates that the system is active whereas UP and
Down lights indicate that the stamp is UP and DOWN position respectively. Develop a LAD to
control the stamp system.
26
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)
27
You created this PDF from an application that is not licensed to print to novaPDF printer (http://www.novapdf.com)