Sie sind auf Seite 1von 58

Programabilni Logiki Kontroleri

PLC
1. PLC hardware
2. PLC programiranje i nain funkcionisanja
3. PLC programske funkcije
4. Diskretne I/O funkcije i ureaji
Uvod
PLC je digitalni elektronski ureaj projektovan da upravlja mainam i/ili procesima
primenjujui sekvencijalno (vremensko ili voeno dogaajima) upravljanje.
PLC je dizajniran za upotrebu u tekim industrijskim uslovima. Moe se programirati bez
posebnih znanja programiranja i moe ga odravati tehniar za odravanje fabrike.
Neke od prednosti PLC-a su:
1. Fleksibilnost. Jedan PLC moe da obradi mnogo razliitih operacija. Softverske
izmene se lake implementiraju od hardverskih.
2. Pouzdanost. Solid-state ureaji su pouzdaniji i laki za odravanje od mehanikih
releja i tajmera.
3. Nia cena. Bazira se na injenici da poluprovodnika tehnologija (procesori)
omoguuje implementaciju sloenih funkcija i sloenih izraunavanja po veoma
niskoj ceni.
4. Dokumentacija. Iz softvera za programiranje je mogue direktno iscrtati eme
regulacionih krugova. Nema potrebe za posebnim crtanjem odreenih crtea koji
postaju zastareli istog trenutka im se izvri neka izmena.
PLC hardware
PS
(opcija)
Napajanje
CPU
Procesor
IM
(opcija)
Interfejs
SM:
DI
SM:
DO
SM:
AI
SM:
AO
FM:
- brojanje
- pozicija
-Zatvorena
povratna petlja
Funkcijiski
Moduli
CP:
- Point-to Point
- PROFIBUS
- Industrial Ethernet
Signalni Moduli
PLC hardware
CPU 314 until Oct. 2002
CPU 314 after Oct. 2002
PLC hardware
S7-400 Automation System
PLC programiranje i funkcionisanje - Ladder Diagram
LD (Ladder Lestviasti Diagram) programski jezik koristi simbole kontakata za
formiranje dijagrama koji su veoma slini kontaktorskim emama.
Simbol za normalno otvoreni kontakt podsea simbol za elektrini kondenzator.
Simbol za normalno zatvoren kontakt je isti kao za otvoreni kontakt sa dijagonalnom
linijom preko.
Simbol za izlaz se sastoji od dve male zagrade.
Svaki kontakt i izlazni simbol ima broj upisan odmah ispod (ili iznad) njega.
Ovaj broj identifikuje lokaciju u procesorskoj memoriji (RAM), gde se uva vrednost
(podatak) sa tog kontakta ili izlaza.
PLC programiranje i funkcionisanje - Ladder Diagram
Upravljanje pneumatskim cilindrom
PLC programiranje i funkcionisanje - Ladder Diagram
Upravljanje pneumatskim cilindrom
PLC programiranje i funkcionisanje - Ladder Diagram
Upravljanje pneumatskim cilindrom
Slika na prethodnom slajdu prikazuje ulazne, procesorsku i izlazne jedinice PLC-a koritene
za upravljanje pneumatskim cilindrom.
Kvadrati (1,2, 3 i 4) u ulaznom modulu IM:1 sadre konvertore koji konvertuju prekidake
ulaze u logike naponske nivoe.
etiri linije povezuju ulazne kvadratie sa memorijskim elijama (lokacijama) koje uvaju
informacije o statusu odgovoarajuih ulaza.
Gornja desna elija ulaznog dela memorije je povezana sa ulazom 1, ulaznog modula IM-1,
tak oda nosi oznaku IM: 1-1.
Kreui se nalevo kroz memorijske elije njihove oznake su IM:1-2, IM:1-3, IM:1-4. Vrednost 0
u memorijskoj eliji IM:1-1 znai da je taster START povezan sa ulazom 1 otvoren, to i jeste.
J edinica u memorijskim elijama IM:1-2 and IM:1-3 oznaava da su prekidai STOP i LS1
zatvoreni, to i jeste.
Nula u eliji IM:1-4 pokazuje da je SW1 otvoren.
ZAPAMTITE! Ulazni podaci na lokacijama IM:1-2 i IM:1-3 daju informaciju da su kontakti
prikljueni na odgovarajue ulaze zatvoreni. Nemamo informaciju da li su to neaktivirani NC ili
aktivirani NO kontakti.
PLC programiranje i funkcionisanje - Ladder Diagram
Upravljanje pneumatskim cilindrom
PLC programiranje i funkcionisanje - Ladder Diagram
Upravljanje pneumatskim cilindrom
Kvadratii(1, 2, 3 i 4) izlaznogmodula OM:1 sadre prekidaka kola koji koriste logike
naponske nivoe (vrednosti izlaznih memorijskih elija) kako bi aktivirali ili deaktivirali izlazne
ureaje (stanja ON ili OFF).
Linija povezuje izlazni kvadrati 1 sa gornjom desnom izlaznom memorijskom elijom, tako da
je njena adresa OM:1-1.
Kreui se nalevo od elije OM:1-1 su elije OM:1-2, OM:1-3, and OM:1-4.
Nule u memorijskim elijama OM:1-1 i OM:1-2 znai da su solneoid i sijalica iskljueni (stanje
OFF).
PLC programiranje i funkcionisanje - Ladder Diagram
Upravljanje pneumatskim cilindrom
Ladder diagram
PLC program - Ladder diagram language
Uporeujui PLC program sa lestviastim dijagramom (kontaktorskom emom K) mogu se uoiti
slinosti, ali i neke razlike.
K ima tri linije (preage, lestvice) a program samo dve. Druga linija se izgubila poto je Sol a,
izlazni ureaj povezan na izlazni terminal OM:1-1. Iz tog razloga se on ne pojavljuje u programu.
Izlaz OM:1-1 na prvoj liniji programa kontrolie relej CR1, koji aktivira Sol a. Prva linija programa
sadri prve dve linije kontaktorske eme.
PLC programiranje i principi funkcionisanja - Ladder Diagram
LD programski jezik postavlja odreena ogranienja po pitanju pisanja programa, i ta
ogranienja variraju od proizvoaa do proizvoaa ureaja. Tipina ogranienja su:
1. Izlaz mora biti na desnom kraju grane.
2. Tok energije mora biti s leva na desno, nagore ili nadole.
3. Energija NE SME da tee s desna na levo.
4. Broj kontakata povezanih na red je maksimalno 11 (ili neki drugi broj postavljen od
strane proizvoaa).
5. Broj paralelnih kontakata je maksimalno 7 (ili neki drugi broj postavljen od strane
proizvoaa).
6. Grana moe da ima samo jedan izlaz.
7. Izlaz mora da bude postavljen u najgronjoj liniji grane.
PLC programming and operation - Ladder Diagram Programming
U relejnoj logici, tok energije s desna na levo se naziva puzajui put. Puzajui putevi nisu
dozvoljeni u PLC programiranju, to pojednostavljuje samo progrmiranje ali i zahteva
prilagoenje relejne logike (dijagrama). Puzajui putevi se moraju konvertovati u odgovarajue
ladder dijagrame (kontaktorske eme) koji ih ne sadre.
U LD programskom jeziku otvoreni i zatvoreni kontakti su u stvari programske instrukcije, a ne
preslikani kontakti kontaktorskih ema. Oni govore PLCu kako da interpretira 1 i 0 koji se nalaze
na ulaznim memorijskim lokacijama (za svaki pojedinani kontakt). Simbol normalno otvorenog
kontakta () daje PlCu instrukciju da interpretira 1 kao TANO (TRUE) a 0 kao NETANO
(FALSE). Ako PLC uspe da pronae TAAN put od ulaza do izlaza, tada je izlaz ON, u
odgovarajuu izlaznu memorijsku eliju se upisuje 1 i aktivira se odgovarajui izlazni ureaj.
Ako nije pronaen taan put, tada je izlaz OFF, i upisuje se 0 u odgovarajuu izlaznu
memorijsku lokaciju.
Simbol NO kontakta se moe koristiti i za NO i za NC fizike kontakte. Naravno, mi kreiramo
rezultate u skladu sa potrebama.
PLC programming and operation - Ladder Diagram Programming
PLC programming and operation - Ladder Diagram Programming
PLC programming and operation - Ladder Diagram Programming
When a PLC is in the RUN mode, the processor repeats the following four-step cycle:
1. Input scan. Store a new image of input conditions.
2. Program scan. Derive the new image of output conditions.
3. Output scan. Transfer the new image of output conditions to output devices.
4. Housekeeping tasks. Communication and other tasks.
PLC programming and operation - Ladder Diagram Programming
Control circuit for a pneumatic cylinder
Cycle 1. start and SW1 are open, stop and LS1 are closed.
Input scan. New input image is IM:1-1 =0, IM:1-2 =1, IM:1-3 =1, IM:1-4 =0.
Program scan. Rung 1: IM:1-1 =FALSE, OM:1-1 =FALSE, IM:1-2 =TRUE, IM:1-3 =
TRUE, path is FALSE, so 0 is stored in cell OM:1-1. Rung 2: IM:1-4 =FALSE so 0 is
stored in cell OM:1-2.
Output scan. Both solenoid a and the light are off.
PLC programming and operation - Ladder Diagram Programming
Control circuit for a pneumatic cylinder
Cycle 2. START, SW1, STOP, and LS1 are all closed.
Input scan. New input image: IM:1-1 =1, IM:1-2 =1, IM:1-3 =1, IM:1-4 =1.
Program scan. Rung 1: IM:1-1 =TRUE, OM:1-1 =FALSE, IM:1-2 =TRUE, IM:1-3 =TRUE,
path is TRUE, so 1 is stored in cell OM:1-1. Rung 2: IM:1-4 =TRUE, so 1 is stored in cell
OM:1-2.
Output scan. Both solenoid a and the light are ON.
PLC programming and operation - Ladder Diagram Programming
Control circuit for a pneumatic cylinder
Cycle 3. START is open, SW1, STOP and LS1 are all closed.
Input scan. New input image: IM:1-1 =0, IM:1-2 =1, IM:1-3 =1, IM:1-4 =1.
Program scan. Rung 1: IM:1-1 =FALSE, OM:1-1 =TRUE, IM:1-2 =TRUE, IM:1-3 =TRUE,
path is TRUE, so 1 is stored in cell OM:1-1. Rung 2: IM:1-4 =TRUE so 1 is stored in cell
OM:1-2.
Output scan. Both solenoid a and the light are ON.
PLC programming and operation - Ladder Diagram Programming
Control circuit for a pneumatic cylinder
Cycle 4. START and LSI are open, STOP and SW1 are closed.
Input scan. New input image: IM:1-1 =0, IM:1-2 =1, IM:1-3 =0, IM:1-4 =1.
Program scan. Rung 1: IM:1-1 =FALSE, OM:1-1 =TRUE, IM:1-2 =TRUE, IM:1-3=FALSE,
path is FALSE, so 0 is stored in cell OM:1-1. Rung 2: IM:1-4 =TRUE so 1 is stored in cell
OM:1-2.
Output scan. Solenoid a is OFF, the light is ON.
PLC programming functions Timer function
The Timer is the most frequently used PLC function, and Time Delay On is the most
common timing function.
Both Time Delay On and Time Delay Off are used in PLCs.
Two types of timers are used in programmable logic controllers:
1. one-input nonretentive timer
2. two-input retentive timer.
The nonretentive timer has one input, one output, and a preset delay time.
The retentive timer has two inputs, one output, and two status bits that can be used as
internal outputs. The inputs are the Enable/Reset line and the Run line. The output is the
Done.
PLC programming functions Timer function
A generic, two-input, retentive
timer and a typical timing
diagram. The timer is shown
with the output address T:12. In
the timing diagram,
Enable/Reset, and Run are
inputs, T:12, T:12-E, and T:12-R
are outputs. Observe that the
timing diagrams of T:12-E and
Enable/Reset match exactly,
but the diagrams of T:12-R and
Run do not. Output T:12-R is
ON only when Enable/Reset is
ON, Run input is ON, and Done
is OFF. Output T:12 (Done) is
ON only after the preset time
delay has been reached, and it
goes OFF when Enable/Reset
goes OFF.
Traditional Timer Functions
S5T#35s
S_PEXT
TV
Q
BI
R
I 0.7
I 0.5
MW0
QW12
T44
BCD
=
M8.5
S
T44
S_OFFDT
TV
Q
BI
R
I 0.7
I 0.5
S5T#35s
MW0
QW12
BCD
=
M8.5
S
T44
S_ODTS
TV
Q
BI
R
I 0.7
I 0.5
S5T#35s
MW0
QW12
BCD
=
M8.5
S
T44
S_PULSE
TV
Q
BI
R
I 0.7
I 0.5
S5T#35s
MW0
QW12
BCD
=
M8.5
S
Pulse Timer (SP)
Extended Pulse (SE)
Stored ON Delay (SS)
T44
S_ODT
TV
Q
BI
R
I 0.7
I 0.5
S5T#35s
MW0
QW12
BCD
=
M8.5
S
ON Delay (SD)
OFF Delay (SF)
Example
A I 0.7
L S5T#35s
SD T4
A I 0.5
R T4
L T4
T MW0
LC T4
T QW12
A T4
= Q8.5
STL
Example of Timer Function: ON Delay (SD)
LAD
T4
S_ODT
TV
S Q
BCD
BI
R
I 0.7
I 0.5
S5T#35s
Q8.5
MW0
QW12
FBD
S_EVERZ
TV
Q
BI
R
I 0.7
I 0.5
S5T#35s
MW0
QW12
T4
BCD
=
Q8.5
S
RLO at S
RLO at R
Time
operation
Q
Units of time: 0 to 999 (BCD-coded)
0.01s <--
0.1s <--
1s <--
10s <--
0 0
0 1
1 0
1 1
Data type
S5TIME
PLC programming functions Counter function
The PLC counter keeps track of the number of times a contact opens and ignores the
times the contact closes between each pair of openings.
In this way, the counter is "counting" the event that causes the contact to open.
The event might be an item that is conveyed past a photo detector. It might be a vehicle
that is driven over a pneumatic pressure detector. It might be a metal object on a shaft
that rotates past a magnetic detector. Industry has many events to count.
Some PLC counters count from 0 up to a preset value; others count from the preset value
down to 0. Most PLCs include both up and down counters.
PLC programming functions Counter function
A generic, two-input counter. The
counter is shown with the output
address C:7, the preset value 120, and
the counter register address RA:0027.
When the Enable/Reset line is OFF, the
counter ignores changes on the count
input line, output (C:7) is OFF, and the
count register (RA:0027) is reset to 0.
When the Enable/Reset line is ON, the
counter increments the count by 1 each
time the count input line goes from OFF
to ON. The counter output (C:7) is OFF
until the count in RA:0027 reaches the
preset value (120). At that time, C:7 is
turned ON and remains ON until
Enable/Reset is turned OFF. The
counter continues to increment the
count register beyond the preset value,
even though the output is ON, indicating
it is done.
Traditional Counter Functions
STL
A I 0.4
CU C5
A I 0.5
CD C5
A I 0.3
L C#5
S C5
A I 0.7
R C5
L C5
T MW4
LC C5
T QW12
A C5
= Q8.3
LAD
Q
I 0.4
I 0.5
CU
I 0.7
C#5
S_CUD
CD
S
I 0.3
PV
R
Q 8.3
CV
CV_BCD
MW 4
QW 12
C5
Q
FBD
I 0.4
I 0.5
I 0.7
C#5
I 0.3
Q
CU
S_CUD
CD
S
PV
R
Q 8.3
CV
CV_BCD
MW 4
QW 12
C5
= Q
Counters: Function Diagram
CU
CD
S
R
Q
Count
5
4
3
2
1
0
PLC programming functions Counter function
Exercise: explain the LD for a
two-counter PLC program
maintains a count of the
number of customers in a
store.
PLC programming functions Sequencer Function
The sequencer function goes through a sequence of steps, producing specified conditions
in a number of ON/OFF outputs at each step.
The specified output pattern for each step is stored in one word of memory, and patterns
for successive steps are stored in successive memory cells.
Each bit in the word is matched with one output (bit 0 is matched with output No.1, bit 1 is
matched with output No.2, . . . , bit 7 is matched with output No.8).
If a bit holds a logical 1, the sequencer turns the matching output ON (or leaves it ON).
If a bit holds a logical 0, the sequencer turns the matching output OFF (or leaves it OFF).
The number of outputs that a sequencer can control depends on the word size of the
PLC. An 8-bit PLC can control up to 8 outputs, and a 16-bit PLC can control up to 16
outputs.
Additional sequencer functions can be used to control additional outputs. For example,
two 16-bit sequencers can control up to 32 outputs.
PLC programming functions Sequencer Function
A generic sequencer with timed
steps.
The timer is enabled by its own
output, causing it to reset
immediately after it has finished
a 30-s delay.
After it has reset, the timer
immediately begins another 30-
s delay (assuming OM:1-1 is
ON).
The timing diagram illustrates
the sequence of pulses
produced by the timer in this
circuit.
PLC programming functions PID Control Function
In some PLCs, the PID control function
is built into an I/O module.
In other PLCs, the PID function is
programmed as a rung in the ladder
diagram program.
Enable: Enables the function when ON
Manual/Auto: OFF for manual, ON for
automatic control
Setpoint: Register that holds the process
variable
Error: Register that holds the error
Output: Register that holds the output
P: Register that holds the proportional gain
setting
I: Register that holds the integral action
time constant
D: Register that holds the derivative time
setting
A generic PID controller function
DISCRETE I/O FUNCTIONS AND DEVICES - BINARY
OPERATIONS
I 0.0 I 0.1
Q 8.0
Q 8.1
I 1.0
I 1.1
P =
&
M1.0
M8.0
T4
S_ODT
TV
S Q
BCD
BI
R
I 0.7
I 0.5
S5T#35s
Q8.5
MW0
QW12
Binary Logic Operations: AND, OR
I 0.2
I 0.3
>=1
=
Q 8.2
O I 0.2
O I 0.3
= Q 8.2
I 0.0 I 0.1
Q 8.0
Q 8.1
LAD
=
Q 8.0
&
I 0.0
I 0.1
=
Q 8.1
FBD
A I 0.0
A I 0.1
= Q 8.0
= Q 8.1
STL
I 0.2
I 0.3
Q 8.2
L3 (Q 8.2)
S3
(I 0.2)
S4
(I 0.3)
OR
AND
L1
(Q 8.0)
S1 (I 0.0)
S2 (I 0.1)
L2
(Q 8.1)
Circuit Diagram
Binary Logic Operations: Exclusive OR (XOR)
I 0.4
I 0.5
XOR
=
Q 8.0
I 0.4 I 0.5
I 0.4 I 0.5
Q 8.0
LAD
>=1
=
Q 8.0
&
I 0.4
I 0.5
&
I 0.4
I 0.5
FBD
A I 0.4
AN I 0.5
O
AN I 0.4
A I 0.5
= Q8.0
STL
X I 0.4
X I 0.5
= Q8.0
Assignment, Setting, Resetting
(S)
Q 8.1
I 1.2 I 1.3
I 1.2
&
S
Q 8.1
I 1.3
I 1.4
>=1
R
Q 8.1
I 1.5
A I 1.2
A I 1.3
S Q 8.1
O I 1.4
O I 1.5
R Q 8.1
I 1.0
&
=
Q 8.0
I 1.1
A I 1.0
A I 1.1
= Q 8.0
Assignment
Set
Reset
(R)
Q 8.1
I 1.4
I 1.5
( )
Q 8.0
I 1.0 I 1.1
LAD FBD STL
RLO Edge Detection
A I 1.0
A I 1.1
FP M1.0
= M8.0
A I 1.0
A I 1.1
FN M1.1
= M8.1
P
I 1.0 I 1.1 M1.0 M8.0
N
I 1.0 I 1.1 M1.1 M8.1
I 1.0
I 1.1
P =
&
M1.0
M8.0
I 1.0
I 1.1
N =
&
M1.1
M8.1
I 1.0
I 1.1
RLO
M1.0
M8.0
M8.1
M1.1
LAD FBD STL
OB1 Cycle
Example
Digital Operations
I 0.0 I 0.1
Q 8.0
Q 8.1
I 1.0
I 1.1
P =
&
M1.0
M8.0
T4
S_ODT
TV
S Q
BCD
BI
R
I 0.7
I 0.5
S5T#35s
Q8.5
MW0
QW12
DEC: +662 BIN.: 2# 0 0 0 0 1 0 1 0 0 1 0 1 1 0 0 0
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
DEC: - 662
Integer (INT, 16-Bit Integer) Data Type
Value range -32768 to +32767
(without sign: 0 to 65535)
Display Formats:
+2
1
+2
2
+2
4 6 x 16
0
= 6
9 x 16
1
=144
2 x 16
2
= 512
662
+2
7
+2
9
+2
5
+2
6
+2
8
Arithmetic
operations: such as +I, * I, <I, ==I
+2
10
+2
11
+2
12
+2
13
+2
14
-2
15
- 662
Sign
positive
numbers
Sign
negative
numbers
Representation as
Twos complement
+2
3
+2
1
+662
10 x 16
0
=16
6 x 16
1
= 96
13 x 16
2
= 3328
64874
15 x 16
3
= 61440
BIN.: 2# 1 1 1 1 0 1 0 1 1 0 1 0 1 0 1 1
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
HEX: W#16 9 6 2 #0
HEX: W#16# 6 A D F
without
sign
without
sign
DEC: L#+540809
Double Integer (DINT, 32-Bit Integer) Data Type
Value range L#-2147483648 to L#+2147483647
(without sign: 0 to 4294967295)
Display Formats:
Operations: such as +D, * D, <D, ==D
(without sign)
0 0 0 8 4 0 8 9 HEX: DW#16#
0 0 0 0 0 0 1 0 0 0 1 0 0 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 BIN.: 2#
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Representation as
Twos complement
(without sign)
F F F 7 B F 7 7 HEX: DW#16#
1 1 1 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 BIN.: 2#
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
DEC: L#-540809
Sign
negative
numbers
Sign
positive
numbers
REAL (Floating-point Number, 32 Bit) Data Type
General format of a Real number =(Sign) (1.f) (2
e-127
)
Real no. =+1.5 * 2
126-127
=0.75
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 1 1 1 1 1 1 0 1 0 0 0 0 0
Sign of
Real no.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
e =Exponent (8 Bit)
f =Mantissa (23 Bit)
2
0
2
1
2
2
2
3
2
4
2
5
2
6
2
7
2
-23
2
-1
2
-2
2-
4
..... 2
-3
Operations: such as +R, * R, <R, ==R
sin, acos, ln, exp, SQR
Example: 0.75
Value range -3.40282310
+38
to -1.17549510
-38
, 0.0, +1.17549510
-38
to +3.40282310
+38
The BCD Code for Inputting and Outputting Integers
6 9 2 0
Value range 16 Bit: - 999 to +999
32 Bit: -9999999 to +9999999
Conversion
operations: BTI, BTD, ITB, DTB
(no arithmetic!)
0 0 0 0 1 0 1 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 x x x 0 BIN.: 2#
BIN.: 2# 0 0 0 0 1 0 1 0 0 1 0 1 1 0 0 0
Sign (+) 9 2
16 Bit:
32 Bit:
Sign (+)
6
6 9 2 0 0 0 0
DEC: +662 HEX: W#16# 2 9 6 0
DEC: +662 HEX: DW#16# 0 0 0 0 2 9 6
Conversion Operations BCD <-> Integer
0 8 1 5
Number
Entered in BCD
Number
displayed
in BCD
Conversion
BCD->Integer
IN
BCD_I
EN
ENO
OUT
IN IW4
MW20
IN
I_BCD
EN
ENO
OUT
IN MW10
QW12
FBD
L IW4
BTI
T MW20
L MW10
ITB
T QW12
STL
Task
Conversion
BCD<-Integer
User program
with Integer
math operations
0 2 4 8
IN
BCD_I
EN ENO
OUT
IN IW4 MW20
I_BCD
IN
EN ENO
OUT
MW10 QW12
LAD
Comparison Operations
STL
A M 3.4
A (
L IW 0
L IW 2
>=I
)
= Q 9.7
FBD
M 3.4
IW0
IW2 =
Q9.7
&
CMP >=I
IN1
IN2
LAD
IW 0
IW 2
M 3.4
Q 9.7
CMP >=I
IN1
IN2
LAD FBD STL
Basi c Mathemati cal Functions
Addition
L MW4
L MW10
+I
T MW6
MW10
ADD_I
IN2
EN
ENO
OUT
IN1
MW4
MW6
MW10
ADD_I
IN2
EN ENO
OUT
IN1
MW4
MW6
Subtrac-
tion
MW12
SUB_I
IN2
EN
ENO
OUT
IN1
MW8
MW6
L MW8
L MW12
- I
T MW6
SUB_I
IN2
EN ENO
IN1
MW8
MW12
MW6
OUT
Multipli-
cation
MD12
MUL_DI
IN2
EN
ENO
OUT
IN1
MD6
MD66
L MD6
L MD12
* D
T MD66
MD6
MD12
MUL_DI
EN ENO
IN1
MD66 IN2
Division
MD4
DIV_R
IN2
EN
ENO
OUT
IN1
MD40
MD32
L MD40
L MD4
/ R
T MD32
MD40
MD4
EN ENO
IN1
IN2
MD32 OUT
DIV_R
Storing Process Data in Data Blocks
Storage Areas for Data
Data Blocks (DBs)
Function
FC10
Function
FC20
Function
Block
FB1
OB1
Global (shared)
data
DB20
Accessible to all blocks
Instance Data
DB5
Instance DB for FB1
Overview of Data Types in STEP 7
Elementary
data types
(up to 32 bits)
Complex
data types
(longer than 32 bits)
User-defined data types
(longer than 32 bits)
Bit data types (BOOL, BYTE, WORD, DWORD, CHAR)
Mathematical data types (INT, DINT, REAL)
Time types (S5TIME, TIME, DATE, TIME_OF_DAY)
Time type (DATE_AND_TIME)
Array (ARRAY)
Structure (STRUCT)
Character chain (STRING)
Data type UDT (User Defined
Data-Type)
Elementary Data Types in STEP 7
Keyword Length (in bits)
Examples
Variables
BOOL 1 True or false I 1.0
BYTE 8 B#16#A9 MB70
WORD 16 W#16#12AF MW72
DWORD 32 DW#16#ADAC1EF5 QD40
CHAR 8 ' w ' DBB4
S5TIME 16 S5T#5s_200ms MW30
INT 16 123 #Value
DINT 32 L#65539 MD80
REAL 32 1.2 or 3.45E-11 DBD60
TIME 32 T#2D_1H_3M_45S_12MS QD44
DATE 16 D#1993-01-20 MW32
TIME_OF_DAY 32 TOD#12:23:45.12 #Time
Complex Data Types
Keyword Length (in bits) Example
DATE_AND_TIME 64 DT#01-08-24-12:14:55:234-1
STRING 8 * (number of This is a string
(character string with characters +2) SIEMENS
max. 254 characters)
ARRAY user- Measured values: ARRAY[1..20]
(Group of elements defined INT
of the same data type)
STRUCT user- Motor: STRUCT
(Group of elements defined Speed : INT
of different data types) Current : REAL
END_STRUCT
UDT UDT as block UDT as array
element
(User Defined Data Type = user- STRUCT
"Template" consisting of defined Speed : INT Drive: ARRAY[1..4]
elementary or complex Current : REAL UDT1
data types END_STRUCT
0.0 Start BOOL
0.1 Stop BOOL
2.0 Motor_on BOOL
4.0 Speed INT
DB 5
FB 5
in Start BOOL
in Stop BOOL
out Motor_On BOOL
out Speed INT
stat ...
Temp...
...
A #Start
AN #Stop
= #Motor_on
...
Drive
Function FC10
in On_1 BOOL
in On_2 BOOL
out Off BOOL
...
...
A #On_1
A #On_2
= #Off
...
CALL FB5, DB5
Start :=I 0.0
Stop :=I 0.1
Motor_on:=Q8.0
Speed :=QW12
Program
execution
CALL FC 10
On_1 := I 0.1
On_2 := I 0.2
Off := Q8.0
Functions and Function Blocks (1)
Exercise X of day 7
Summary of day 7

Das könnte Ihnen auch gefallen