Siemens S7300 Basic Programming
Siemens S7300 Basic Programming
Siemens S7300 Basic Programming
Digital Fundamentals
Basic Logic Operations
Number Systems
Combining Logic in Mechatronic Systems
PLCs in Mechatronic System
Basic PLC Operations (Bit Logic )
Course Goals:
Upon completion of the course, students should:
1. Understand the role of programmable logic
controllers in complex mechatronic systems,
modules and subsystems.
2. Understand the flow of information in the
system.
3. Understand and apply troubleshooting,
maintenance and safety rules.
Description
This training introduces the basic hardware and
software components of a Programmable Controller
(PLC). It details the architecture and basic
instruction set common to all PLC’s with an
emphasis on S7300 Siemens PLC . Basic
programming techniques and logic designs are
covered. This training describes the operating
features of the PLC, the advantages of the PLC over
hard-wired control systems, practical applications,
troubleshooting and maintenance of PLC’s.
4
Logic Levels
At
least 11 bits are needed
Basic Logic
Circuit diagram of a NOT function
When the push button is not actuated, the relay
is switched on. When the push button is
actuated, the relay goes off
AND gate
AND CCT
AND gate used as a frequency
counter
1. Number Systems
Common Number Systems
The possibilities:
Decimal Octal
Binary Hexadecimal
pp. 40-46
Quick Example
Base
Decimal to Decimal (just for fun)
Decimal Octal
Binary Hexadecimal
Next slide…
Weight
Base
Binary to Decimal
Decimal Octal
Binary Hexadecimal
Binary to Decimal
Technique
– Multiply each bit by 2n, where n is the “weight” of
the bit
– The weight is the position of the bit, starting from 0
on the right
– Add the results
Example
Bit “0”
1010112 => 1 x 20 = 1
1 x 21 =
2
0 x 22 =
0
1 x 23 =
8
0 x 24 =
0
1 x 25 =
32
Octal to Decimal
Decimal Octal
Binary Hexadecimal
Octal to Decimal
Technique
– Multiply each bit by 8n, where n is the “weight” of
the bit
– The weight is the position of the bit, starting from 0
on the right
– Add the results
Example
7248 => 4 x 80 = 4
2 x 81 = 16
7 x 82 = 448
46810
Hexadecimal to Decimal
Decimal Octal
Binary Hexadecimal
Hexadecimal to Decimal
Technique
– Multiply each bit by 16n, where n is the “weight” of
the bit
– The weight is the position of the bit, starting from 0
on the right
– Add the results
Example
Decimal Octal
Binary Hexadecimal
Decimal to Binary
Technique
– Divide by two, keep track of the remainder
– First remainder is bit 0 (LSB, least-significant bit)
– Second remainder is bit 1
– Etc.
Example
12510 = ?2 2 125
2 62 1
2 31 0
15 1
2
7 1
2
2 3 1
2 1 1
0 1
12510 = 11111012
Octal to Binary
Decimal Octal
Binary Hexadecimal
Octal to Binary
Technique
– Convert each octal digit to a 3-bit equivalent binary
representation
Example
7058 = ?2
7 0 5
7058 = 1110001012
Hexadecimal to Binary
Decimal Octal
Binary Hexadecimal
Hexadecimal to Binary
Technique
– Convert each hexadecimal digit to a 4-bit
equivalent binary representation
Example
10AF16 = ?2
1 0 A F
10AF16 = 00010000101011112
Decimal to Octal
Decimal Octal
Binary Hexadecimal
Decimal to Octal
Technique
– Divide by 8
– Keep track of the remainder
Example
123410 = ?8
8 1234
8 154 2
8 19 2
8 2 3
0 2
123410 = 23228
Decimal to Hexadecimal
Decimal Octal
Binary Hexadecimal
Decimal to Hexadecimal
Technique
– Divide by 16
– Keep track of the remainder
Example
123410 = ?16
16 1234
16 77 2
16 4 13 = D
0 4
123410 = 4D216
Binary to Octal
Decimal Octal
Binary Hexadecimal
Binary to Octal
Technique
– Group bits in threes, starting on right
– Convert to octal digits
Example
10110101112 = ?8
1 3 2 7
10110101112 = 13278
Binary to Hexadecimal
Decimal Octal
Binary Hexadecimal
Binary to Hexadecimal
Technique
– Group bits in fours, starting on right
– Convert to hexadecimal digits
Example
10101110112 = ?16
10 1011 1011
2 B B
10101110112 = 2BB16
Octal to Hexadecimal
Decimal Octal
Binary Hexadecimal
Octal to Hexadecimal
Technique
– Use binary as an intermediary
Example
10768 = ?16
1 0 7 6
2 3 E
10768 = 23E16
Unsigned Binary Coded Decimal
(BCD)
58
Hexadecimal to Octal
Decimal Octal
Binary Hexadecimal
Hexadecimal to Octal
Technique
– Use binary as an intermediary
Example
1F0C16 = ?8
1 F 0 C
1 7 4 1 4
1F0C16 = 174148
Exercise – Convert ...
Hexa-
Decimal Binary Octal decimal
33
1110101
703
1AF
66
Example
In the lab…
1. Double click on My Computer
2. Right click on C:
3. Click on Properties
/ 230 =
Review – multiplying powers
For common bases, add powers
ab ac = ab+c
or…
26 210 = 64 210 = 64k
Binary Addition (1 of 2)
Two 1-bit values
A B A+B
0 0 0
0 1 1
1 0 1
1 1 10
“two”
pp. 36-38
Binary Addition (2 of 2)
Two n-bit values
– Add individual bits
– Propagate carries
– E.g.,
1 1
10101 21
+ 11001 + 25
101110 46
Multiplication (1 of 3)
Decimal (just for fun)
35
x 105
175
000
35
3675
pp. 39
Multiplication (2 of 3)
Binary, two 1-bit values
A B AB
0 0 0
0 1 0
1 0 0
1 1 1
Multiplication (3 of 3)
Binary, two n-bit values
– As with decimal values
– E.g.,
1110
x 1011
1110
1110
0000
1110
10011010
Fractions
Decimal to decimal (just for fun)
pp. 46-50
Fractions
Binary to decimal
pp. 46-50
Fractions
Decimal to binary .14579
x 2
3.14579 0.29158
x 2
0.58316
x 2
1.16632
x 2
0.33264
x 2
0.66528
x 2
1.33056
11.001001... etc.
p. 50
Exercise – Convert ...
Hexa-
Decimal Binary Octal decimal
29.8
101.1101
3.07
C.82
Don’t use a calculator!
motor should
be activated,
while the
container is
being filled.
Orange ,
carrot coctail
Boolean Algebra
INTRODUCTION TO PLCS
Advantages of PLCs
• Less wiring.
• Wiring between devices and relay contacts are done in the PLC
program.
• Easier and faster to make changes.
• Trouble shooting aids make programming easier and reduce
downtime.
• Reliable components make these likely to operate for years before
failure.
PLC Origin
MOTOR
A
FS FLOAT SWITCH
SOLENOIDS B
SOLENOID
C
TIMER
1 -MINUTE
90
Tank Used to Mix Two Liquids
A tank is used to mix two liquids. The control circuit
operates as follows:
2. When the tank is filled, the float switch trips. This de-
energizes solenoids A and B and starts the motor used
to mix the liquids together.
I M O M
N O
P D U O
U U PROCESSOR T D
T L P U
From E U L
To
SENSORS T E
OUTPUT
Pushbuttons, Solenoids,
contacts, contactors,
limit switches, alarms
etc. etc.
PROGRAMMING
DEVICE
92
Major Components of a Common PLC
PROCESSOR
PROGRAMMING DEVICE
93
Programming Device
Also known as:
Industrial Terminal ( Allen Bradley )
Program Development Terminal ( General Electric )
Programming Panel ( Gould Modicon )
Programmer ( Square D )
Program Loader ( Idec-Izumi )
Programming Console ( Keyence / Omron )
94
Programming Device
Types:
Hand held unit with LED / LCD display
Desktop type with a CRT display
Compatible computer terminal
95
I/O Module
• The I/O interface section of a PLC connects it to
external field devices.
Current Buffer,
FROM Limiting Filter,
OPTO- TO
INPUT Resistor ISOLATOR hysteresis
PROCESSOR
DEVICE Circuits
97
I/O Module
AC INPUT MODULE
IS NEEDED TO:
CONVERTS THE AC · Prevent voltage
INPUT TO DC AND transients from
DROPS THE damaging the
VOLTAGE TO LOGIC processor.
LEVEL ·Helps reduce
the effects of
electrical noise
Rectifier, Buffer,
FROM Resistor Filter,
OPTO- TO
INPUT Network ISOLATOR Hysteresi
PROCESSOR
DEVICE s Circuits
98
99
100
101
I/O Module
DC / AC OUTPUT MODULE
IS NEEDED TO:
· Prevent voltage
transients from
damaging the
processor.
·Helps reduce
the effects of
electrical noise
Amplifier
FROM RELAY
TTL OPTO- TO
PROCESSOR ISOLATOR TRIAC
Circuits OUTPUT
X’SISTOR
DEVICE
102
103
OUTPUTS
INPUTS MOTOR
CONTACTOR
LAMP
PUSHBUTTONS
PLC
104
Allen-Bradley 1746-1A16
L1 L2 I= Input
Module
I:2 slot # in rack
P. B SWITCH 0 Module
Terminal #
Address I:2.0/0
LADDER PROGRAM
INPUT
MODULE
WIRING DIAGRAM
105
CONTACTOR
L2 L1 N.
O
MOTOR
L2
C •SOLENOID
L1 •VALVES
FIELD •LAMP
•BUZZER
WIRING
OUTPUT MODULE
WIRING
L1 O:4 L2
CONTACTOR 0
LADDER PROGRAM
106
Discrete Input
A discrete input also referred as digital input is an input that
is either ON or OFF are connected to the PLC digital input.
In the ON condition it is referred to as logic 1 or a logic high
and in the OFF condition maybe referred to as logic o or
logic low.
Normally Open
Pushbutton
Normally Closed
Pushbutton
Normally Open switch
OFF PLC
Logic 0
Input
Module
24 V dc
IN
OFF PLC
Logic 1
Input
Module
24 V dc
108
Analog Input
An analog input is an input signal that has a continuous
signal. Typical inputs may vary from 0 to 20mA, 4 to 20mA
or 0 to10V. Below, a level transmitter monitors the level of
liquid in the tank. Depending on the level Tx, the signal to the
PLC can either increase or decrease as the level increases
or decreases.
Level IN
Transmitter PLC
Analog
Tank Input
Module
109
Digital Output
A discrete output is either in an ON or OFF condition.
Solenoids,
contactors coils, lamps are example of devices connected to
the
Discrete or digital outputs. Below, the lamp can be turned ON
or OFF by the PLC output it is connected to.
Lamp
OUT
PLC
Digital
Output
Module
110
Analog Output
OUT
E Supply air
PLC 0 to 10V P
Analog
Output
Module
Pneumatic control valve
111
Processor
The processor module contains the PLC’s microprocessor, its supporting
circuitry, and its memory system.
The memory system in the processor module has two parts: a system
memory and an application memory.
112
Memory Map Organization
•System memory includes an area called the EXECUTIVE,
composed of permanently-stored programs that direct all
system activities, such as execution of the users control
program, communication with peripheral devices, and other
SYSTEM system activities.
•The system memory also contains the routines that
implement the PLC’s instruction set, which is composed of
specific control functions such as logic, sequencing, timing,
counting, and arithmetic.
•System memory is generally built from read-only memory
devices.
APPLICATION
•The application memory is divided into the data table area
•Data Table and user program area.
•The data table stores any data associated with the user’s
•User Program control program, such as system input and output status
data, and any stored constants, variables, or preset values.
The data table is where data is monitored, manipulated, and
changed for control purposes.
•The user program area is where the programmed
instructions entered by the user are stored as an application
control program.
113
Memory Designs
VOLATILE.
A volatile memory is one that loses its stored
information when power is removed.
115
Memory Designs
Several Types of RAM Memory:
1.MOS
2.HMOS
3.CMOS
116
Memory Designs
NON-VOLATILE
Has the ability to retain stored information when power is
removed, accidentally or intentionally. These memories
do not require battery back-up.
117
While the PLC is running, the scanning process
includes the following four phases, which are repeated
continuously as individual cycles of operation:
PHASE 1
Read Inputs
Scan
PHASE 2
Program
Execution
PHASE 3
Diagnostics/
Comm
PHASE 4
Output
Scan
118
PHASE 1 – Input Status scan
119
PHASE 4 - Output Status Scan
• An output status scan is then performed, whereby the
stored output values are sent to actuators and other
field output devices. The cycle ends by updating the
outputs.
120
As soon as Phase 4 is completed, the entire cycle begins
again with Phase 1 input scan.
121
PLC Communications
Common Uses of PLC Communications Ports
Changing resident PLC programs -
uploading/downloading from a supervisory controller
(Laptop or desktop computer).
Forcing I/O points and memory elements from a
remote terminal.
Linking a PLC into a control hierarchy containing
several sizes of PLC and computer.
Common Standards
RS 232
Used in short-distance computer communications,
with the majority of computer hardware and
peripherals.
Has a maximum effective distance of approx. 30 m at
9600 baud.
123
PLC Communications
Local Area Network (LAN)
Used for longer-distance links, often between several
PCs in a distributed system. RS 485 can have a
maximum distance of about 1000 meters.
125
Specifications
Several factors are used for evaluating the quality and
performance of programmable controllers when selecting
a unit for a particular application. These are listed below.
NUMBER OF I /O PORTS
126
Selecting a PLC
Criteria
SCAN TIME
129
Specifications
MEMORY CAPACITY
130
PLC Status Indicators
•Power On
•Run Mode
•Programming Mode
•Fault
Troubleshooting
Power flows through these contacts when they are closed. The
normally open (NO) is true when the input or output status bit
controlling the contact is 1. The normally closed (NC) is true
when the input or output status bit controlling the contact is 0.
135
Coils
136
Boxes
137
Basic Programming Simatic S7-300
By:
Andri Kuncoro
SIMATIC Overview
SIMATIC Controller (PLC)
S7-400
S7-200
S7-300
S7 – 300
Features :
Modular small controll system
Performance graded range of CPU
Extensive selection of modules
Expandable design with up to 32 modules
Backplane bus integrated in the modules
Can be networked with MPI, Profibus or Industrial ethernet
Central PG/PC connection with access to all modules
No slot restrictions
Configuration and parameter setting with the help “HW Config”
S7 – 300
Mode Selector
MRES = Memory reset function
STOP = Stop mode, program not executed
RUN = Program execution
RUNP = Program execution, read/write access
Status Indicator
SF = Group error, internal CPU or fault in
module
BATF = Battery fault
DC5V = Internal 5 VDC voltage indicator
FRCE = FORCE
RUN = Flashes when the CPU is starting up,
then steady light in Run mode
STOP = Show steady light in Stop mode
SF DP = Physical bus fault
BUSF = No configuration or incorrect
configuration
Starting with SIMATIC Manager
SIMATIC Manager menus and toolbars
Standard Library
Context-Sensitive Help in S7
F1
Creating a project
Insert Station
Starting Hardware Configuration Editor
Generating a Hardware setpoint Configuration
Addressing S7 Modules
Module Address Overview
Variable Addressing
2x
CPU Properties
2x
Saving the HW Configuration and Downloading
it in the Module
Inserting S7 Block
Inserting S7 Block
Block architecture and Block editor
AND - OPERATION
Binary Operation
OR - OPERATION
Binary Operation
EXCLUSIVE - OR - OPERATION
Binary Operation
RESET DOMINANT
SET DOMINANT
Binary Operation
POSITIVE EDGE
Binary Operation
NEGATIVE EDGE
Binary Operation
JUMP UNCONDITIONAL (JU)
BYTE For a unit of 8 binary characters, the term BYTE is used. A byte has the size of 8 bits.