S7-1200 Basic Instructions
S7-1200 Basic Instructions
1
What are the PLC programs
Two types:
System program
Be intergrated in CPU of PLC
User program
A set of instructions are arranged in order
User program is loaded into PLC systems in machine code
A sequence of binary code numbers represent the program instructions
2
PLC Operation
3
Start Events in the Operating System
4
Blocks of User program
When you create a user program for the automation tasks, you insert the
instructions for the program into code blocks:
An organization block (OB) responds to a specific event in the CPU and can interrupt the
execution of the user program.
The default for the cyclic execution of the user program (OB 1) provides the base
structure for your user program and is the only code block required for a user program.
A function block (FB) is a subroutine that is executed when called from another code block
(OB, FB, or FC).
The calling block passes parameters to the FB and also identifies a specific data block (DB)
that stores the data for the specific call or instance of that FB.
A function (FC) is a subroutine that is executed when called from another code block (OB, FB,
or FC).
The FC does not have an associated instance DB. The calling block passes parameters to the
FC. The output values from the FC must be written to a memory address or to a global DB.
5
Basic Instructions
Bit instructions
Timer
Counter
Compare
Math
Move
6
Bit Instructions – Check Bit
Checked bit
Checked bit
Checked bit
7
Bit Instructions – Asign Bit
8
Bit Instructions – Set/ Reset Bit
9
Example_1
Draw the wiring diagram.
Inputs Sinking
Outputs Sourcing
The motor 3 phases, the lamp 24VDC.
The Coil contactor 220VAC (optional).
10
Example_2
Draw the wiring diagram.
Inputs Sinking
Outputs Relay
The motor 3 phases, the solenoids 24VDC.
The Coil contactor 220VAC (optional).
Write the PLC program.
The tank is empty (FS signals low): solenoids
A and B energized, C de-energized.
Start button pushed: solenoids A and B
energized. Motor runs forward.
When the tank is full (FS signals high):
STOP
solenoid B de-energized, C energized. Motor
runs reverse.
Stop button pushed: Motor stops, all solenoids START
de-energized
11
Positive and Negative Edge Instructions
12
Timers Instructions
You use the Timer instructions to create programmed time delays. Each Timer uses a 16 byte
IEC_Timer data type DB structure to store timer data that is specified at the top of the box or coil
instruction. STEP 7 automatically creates the DB when you insert the instruction.
13
The Parameters of Timer
14
The PT and IN Parameters
15
Operation of the Timer – TON
TON: ON-delay timer
The TON timer sets output Q to ON after a preset time delay.
16
Timer Programming
17
Example_3
Draw the wiring diagram.
DI Sourcing.
DO Sinking.
Write the PLC program.
The barrow must be in the correct
position (limit switch S1 actived).
Start button pushed (NO): M2 runs.
5s later M1 runs. 10s later Y opens.
Stop button pushed (NC): Y closes.
5s later M1 stops. 5s later M2 stops.
One of two motors overloaded: the
system stop. The lamp turned on.
Lamp and Valve Y 24VDC. Motors M1
and M2 3 phases. Contactor 220V
18
Example_4
19
Counter Instructions
20
The Parameters of Counter
21
Operation of the CTU
22
Operation of the CTD
23
Example_5
The ball classification system is controlled by S7-1200
CPU1214C DC/DC/DC.
The system contains two conveyor belts. The conveyor
carries balls and boxes, moving by two 3 phases motors.
If the Start button is pushed, box conveyor will begin to move.
When the box triggers the sensor SE2, the box conveyor
stops and the ball conveyor begins to move.
The weight sensor WS measures the ball weights. If the ball
weight is 500g, the WS is on state (it’s contact is closed).
The ball conveyor carries two size of the balls, 250g and
500g. If weight of the first ball is 500g, the box is filled with 3
balls. Otherwise the box filled with 5 balls with 250g.
In the system, the sensor SE1 is used to detect the balls.
After the box is filled with the balls as specified above, the ball
conveyor stops and box conveyor begins to move. 1. Draw the wiring diagram of the system.
The system can be reset by a Stop button any time. 2. Construct the PLC LAD program to control
SE1 and SE2 are NPN photoelectric sensors. WS is limit switch. the system.
24
Compare Instructions
25
Math Instructions – Calculate instruction
26
Add, Subtract, Multiply and Divide Instructions
27
Move and Block Move Instructions
28
Move and Block Move Instructions
29
Example_6
30