Sie sind auf Seite 1von 60

SPS-Programmierung

fr Fortgeschrittene
1

Harald Brck, SDT-TS


August 2000

Themenbersicht
Adressbereiche

Adressbereiche
C-Serien-SPS

Adressbereiche
CS1

14

CS1- E/A- Adresszuordnung

23

CS1-E/A-Tabelle

30

Skalierung
Fliekomma

32

36

Sprnge
Unterprogramme
Schrittketten
SET / RSET
STEP / SNXT

41

45

49

50

53

Hinweis: Mausklick auf OMRON fhrt zu diesem Bildschirm zurck.

Indirekte
Adressierung

57

Adressbereiche
mit CX-Programmer anzeigen

Adressbereiche C__-SPSen

Ein-/Ausgnge,
Arbeitsmerker
Systemmerker
Linkmerker
remanent

Zustzliche
Systemmerker

Timer, Zhler
CNT-remanent

Haftmerker
remanent

Datenworte,
remanent

IR-Speicherbereich - C-Serie
Eingnge
Ausgnge
Arbeitsmerker

Ein-/Ausgnge, Arbeitsmerker
Wort- z.B.001 oder Bitadresse z.B.001.12

Arbeitsmerker

SR-Speicherbereich - C-Serie
Systemmerker-Bereich SR:
enthlt Sekunden-P_1s, Minutentaktbits P_1min, Immer-Ein-Merker P_On .
Wort- z.B.240 oder Bitadresse z.B.252.02
mit spez. Funktionen nicht belegte Adressen als Arbeitsmerker benutzbar

AR-Speicherbereich - C-Serie
zustzlicher Systemmerker-Bereich AR:
Systemmerkerbereich enthlt Merker zur berwachung und Steuerung des SPS-Betriebs:
Fehlermerker, Zykluszeit-Merker, Echtzeit-Merker .
Wort- z.B.AR15 oder Bitadresse z.B.AR12.15

Systemmerker mit CX-Programmer


anzeigen
Globale
Symbole

HR-Speicherbereich - C-Serie
Haftmerker-Bereich HR:
enthlt remanente (spannungsausfallsichere) Arbeitsmerker
Wort- z.B.HR15 oder Bitadresse z.B.HR15.15

LR-Speicherbereich - C-Serie
Schnittstellenbereich LR fr 1:1-SPS-Kommunikation:
enthlt remanente (spannungsausfallsichere) Merker
Wort- z.B.LR15 oder Bitadresse z.B.LR15.05
mit spez. Funktionen nicht belegte Adressen als Arbeitsmerker benutzbar

10

TC-Speicherbereich - C-Serie
Zeitgeber/Zhler-Bereich TC:
bei C__-Steuerungen mssen Zeitgeber und Zhler unterschiedliche Nummern
haben, da sie im gleichen Bereich TC liegen, bei CS1 sind gleiche Nr. zulssig
Timeristwert- z.B. Wort TC254, Zeit abgelaufen-Bitadresse TIM254
Zhleristwert- z.B. Wort CNT255, Zhler abgelaufen-Bitadresse CNT255
Zhler-Istwerte sind remanent (spannungsausfallsicher)

11

DM-Speicherbereich - C-Serie
Datenmerker-Bereich DM fr Daten, Parameter, Werte:
nur wortweiser Datenzugriff, z.B. DM2047
Schreib/Lese-Bereich (DM0000-),
nur Lese-Bereich (DM6144-DM6599), Daten vom Programm nur lesbar
SPS-Setup -Bereich (DM6600-DM6655) speichert Steuerparameter des SPS-Betrieb
DM sind remanent (spannungsausfallsicher)

12

Erweiterter Datenmerker-Speicherbereich - CSerie C200HX vorhanden:


Bereich EM ist nur bei CQM1H-CPU61, C200HG,
Bereich EM fr Daten, Parameter, Werte
nur wortweiser Datenzugriff, z.B. EM6143 fr die Bank EM0
EM sind remanent (spannungsausfallsicher)

13

Adressbereiche CS1

Timer
Zhler
remanent

Systemmerker
Index-Register

Datenregister

Task-Merker

Datenworte,
remanent

Haftmerker

ErweiterungsDatenworte,
remanent

14

Ein-/Ausgnge,
Arbeitsmerker

Arbeitsmerker

Systemmerker-Speicherbereich
CS1

Systemmerkerbereich A enthlt Merker zur berwachung und Steuerung des SPS-Betriebs:


Fehlermerker, Zykluszeit-Merker, Echtzeit-Merker .
Wort- z.B.A264 oder Bitadresse z.B.A200.11
nur lesbar A000 bis A447, lesbar/schreibbar A448 bis A959

15

Haftmerker H und Arbeitsmerker W CS1


Arbeitsbereich W:
Wort- z.B.W511 oder Bitadresse z.B.W511.11
Haftmerker-Bereich H:
enthlt remanente (spannungsausfallsichere) Arbeitsmerker
Wort- z.B.H511 oder Bitadresse z.B.H511.15

16

Zeitgeber T und Zhler C - CS1


Zeitgeber-Bereich T:
empfehlenswert ist, unterschiedliche Nummern unterschiedlichen Zeitgeberarten zu geben
Timeristwert- z.B. Wort T4095 , Zeit abgelaufen-Bitadresse T4095
Zhler-Bereich C:
empfehlenswert ist, unterschiedliche Nummern unterschiedlichen Zhlerarten zu geben
Zhleristwert- z.B. Wort C4095 , Zhler abgelaufen-Bitadresse C4095
Zhler-Istwerte sind remanent (spannungsausfallsicher)

17

Datenmerker D und Erweiterte Datenmerker ECS1

Datenmerker-Bereich D fr Daten, Parameter, Werte:


nur wortweiser Datenzugriff, z.B. D32767
D sind remanent (spannungsausfallsicher)

Bereich EM ist nur bei CS1G-CPU44, -CPU45, CS1H-CPU64 und hher vorhanden:
Bereich EM fr Daten, Parameter, Werte
nur wortweiser Datenzugriff, z.B. E2_32767 fr die Bank E2
EM sind remanent (spannungsausfallsicher)

18

Index-Register IR und Daten(Offset)Register


DR
mit IR werden Ein-/Ausgangsworte indirekt adressiert, IR stellt den Zeiger dar
nur wortweiser Datenzugriff, z.B. IR14
mit DR werden Ein-/Ausgangsworte indirekt adressiert, DR-stellt den Versatz dar (IR +DR)
nur wortweiser Datenzugriff, z.B. DR15

19

Taskmerker-Speicherbereich CS1

Taskmerker-Bereich TK:
Taskmerker aktivieren/deaktivieren Tasks -Programmteile
Taskmerker benutzen Konstanten #00 bis #31, z.B. TK31

20

CIO-Speicherbereich - CS1
Ein-/Ausgnge, Arbeitsmerker
Wort- z.B.139 oder Bitadresse z.B.139.11

21

CIO-Speicherbereich - CS1
0000-0399ch

Io area

0400-0999ch
frei
1000-1199ch
1200-1499ch
1500-1999ch
2000-2959ch

22

Data Link

frei
CPU-Bus-Baugr.
Spezial-Baugr.
+DM20,000 to DM29599

3000-3049ch
3100-3131ch

Sysmac Bus
E/A-Terminal
frei

3200-3599ch

Compobus/D
CS1

3600-6143ch
frei

CS1 - E/A - Adresszuordnung


(Siehe Handbuch W339 S. 268)

3 Typen von Baugruppen bei der CS1 .


CS1 - CPUbus - Baugruppen
Spezial - E/A - Baugruppen
Basis - E/A - Baugruppen

23

CS1 - E/A - Adresszuordnung


CS1 - CPUbus Baugruppen
CIO1500-1899
(W339 S. 66)

24

CS1 - E/A - Adresszuordnung


Spezial-E/ABaugruppen
CIO2000-2959
(D20000-D29599)

25

(W339 S. 136)

CS1 - E/A - Adresszuordnung


Basis - E/A Baugruppen
CIO0000-0319
( W339 S. 120)

26

Io allocation
ZuordnungsMethode

(W339 S. 268)

27

Dalje adresiranje-vidi user manual


Zuordnung bei
CS1 ErweiterungsBaugruppentrger

CPU Rack

Words allocated
in order from rack
nearest CPU rack.

(W339 S. 273)

Anfangsadresse des
Baugruppentrgers
whlbar, z.B.:

CS1 Expansion
Rack

#1=Adresse 20
#2=Adresse 100
CS1 Expansion
Rack

28

Eack start adres u io table


0000-0019ch

Baugr.-Tr. #1

0020-0049ch

Baugr.-Tr. #2

0050-0099ch

Ausgnge
Compobus/D

0100-0349ch

Baugruppentrger #3
.
.
#7
Eingnge
Compobus/D

0350-0399ch
29

E/A-Tabelle ffnen
When CS1, it is necessary to create the registered I / O table
I / O table represents the mapping of the Konfiguratuon in CIO Area
Open the I / O table with double click in the 'I / O table' Project

30

E/A-Tabelle erstellen
CX-Programmer, displays the address assignment of the modules in the PLC configuration
after the I / O table in the program-stop online mode was created.

High-speed counter module:


Slot 02,
Start address 2050

31

Skaliranje
SCL converted
Binary data of the source term Q
BCD data in the result word E
through the points (As, Ad) and (Bs, Bd)
linear function defined.

32

Primjer skaliranja
Let us assume that a pressure sensor on analog input
connected, and which measures a pressure of 500 mbar to 2500.
The following values must be set:
(As, Ad) and (Bs, Bd)
(0.500) and (FA0 hex = 4000 BCD, 2500).

33

Parameter Adresse

Wert

Ad, BCD

D00100

0500

As, Hex

D00101

0000

Bd, BCD

D00102

2500

Bs, Hex

D00103

0FA0

Primejr skaliranja
The measured voltage at the analog input 0 to 10V is correct
be displayed in hundredths of volts. Values range 0000 to 1000
Insert the values:
(As, Ad) and (Bs, Bd)
Use CIO0005 address as the display of the voltage.
In order for the assembly MAD44 (Unit # 0)
D20000 and D20001 00FF = must = be 5500 (0 to 10 V)

10V

4000

34

Parameter Adresse

Wert

Ad, BCD

D00100

0000

As, Hex

D00101

0000

Bd, BCD

D00102

0000

Bs, Hex

D00103

0000

Scaling exercise resolution


In order for the assembly MAD44 (Unit # 0)
D20000 and D20001 00FF = must = be 5500 (0 to 10 V)
If you want to see the correct voltage 0 to 10V as 0000-1000
one must specify the following values:
(Ad, As) and (Bd, Bs)
(0.0) and (1000, FA0 hex = 4000 BCD).

35

Parameter Adresse

Wert

Ad, BCD

D00100

0000

As, Hex

D00101

0000

Bd, BCD

D00102

1000

Bs, Hex

D00103

0FA0

Floating-point arithmetic

Wertebereich

Befehle

36

FIX
+F
SQRT
RAD
SIN
ASIN

FIXL
-F
PWR (x^y)
DEG
COS
ACOS

FLT
FLTL
/F
*F
EXP (e^x) LOG (e)

Konvertierung
Arithmetik
Trigonometrie

TAN
ATAN

Convert floating-point value


Conversion to floating point BIN
FLT

Calculation e.g.: / F 4.0


Determining the decades to be displayed
for example: * F 10000
Round up + F 0.5
Conversion into a BCD word FIX

BCD

37

Floating point - Arithmetic


Addition, Subtraktion, Multiplikation, Division ( 2 Worte pro Fliekommawert)

38

Exercise - floating point


The measured voltage at the analog input 0 to 10V
(Range 0 ... 4000)
to using floating-point arithmetic commands
be correctly displayed in hundredths of a volt.
Values range 0000 to 1000
All you need is essentially a division by 4
Use CIO0004 address as the display of the voltage.
For the calculation of intermediate results, you can
Data memory words from D00040 to D00049 use.
(In order for the assembly MAD44 (Unit # 0)
D20000 and D20001 00FF = must = be 5500 (0 to 10 V))

39

Fliekomma - bungsauflsung
Conversion to floating point FLT

Calculation e.g.: / F +4

Round up + F 0,5 = +5 E-1

Conversion into a BCD word FIX


BCD

40

Jump
berspringt den Programmabschnitt,
wenn die Ausfhrungsbedingung AUS
ist, bis zum JME mit der gleichen
Sprungnummer. (Bei EIN wird der
Programmabschnitt ausgefhrt).

41

Anwendung fr Sprnge
Optional equipment or plant parts:
It can be a complete program for
all possible plant parts written
be. The parts that the end customer is not
mitkauft be in the program only
switched off so that when retrofitting
again only the relevant part
must be unlocked.

42

bung mit Sprngen


Make the calculation of the
previous example can be switched off
with JMP commands.
Please use the entrance at 2:00 ATurning the calculation.
Watch the values in the display.

43

Jumps - Exercise solution


Switch the input to the A-2:00
Turning the calculation.
If the calculation off
is, the display remains frozen.
This is usually undesirable.
Please note that!
It can for example be that even outputs
can not be reset.
(Missing in this example, the programpart of the switch position Switch1 = OFF)
The cycle time improvement is usually
irrelevant, and the calculation can also
off contact with the front of the command
are, therefore, that jumps in
Case hardly needed at Omron.

44

Subroutine
Calls the subroutine with the
specified subroutine
number of leads and the
Program.
After the return (RET)
the command is executed behind SBS.

Poeljnoje pri kraju prg. Ugraditi subrouotine prg.

45

Anwendung von Unterprogrammen


First Calculations or machine
divide the number of times with different
Data is to be executed
in subroutines
programmed.
It must to data areas
Data transfer can be defined.
Second Build a program structure.

46

bung - Unterprogramme
Set the floating-point calculation of the exercise in
a subroutine and run it once for input 1, from one
display, and once for input 2, display 2.
It must to data areas
Data transfer can be defined.
The subroutine is its input data
get word in D00060, D00061, and return the
result.
It is the value of analog input 1 (CIO2001) and 2
(CIO2002) are changed.
Should CIO0004 on the display of
Voltage value to 1 and the second CIO0005 Value
are displayed.

47

Subprograms - Exercise solution


Glavni

48

Sub

Sequencer, moe i step instrukcija


Step chains are in
all automatic
Processes required.
They consist of:
steps and
Transitions.
As an example, the
program control
a washing machine
: serve
steps:
prewash
main wash
rinse
Tansitionen:
Terms of the programmable controller

49

Step sa set resetima


The sequencer is in reverse
Programmed sequence.
This is the processing
only a new step in
next cycle started.
There is no saving cycle time.
There is no restriction in
of use.

50

Exercise - Step chain with SET / RSET


Program a traffic light with the steps:
RED
RED / YELLOW
GREEN
YELLOW
The Transform functions:
8 seconds is up, RED / YELLOW
2 s to come GREEN
5 sec to come YELLOW
3 sec until RED comes
Light red = 6.00
Light yellow = 6.01
Light green = 6.02
Timer 1-4
Step flag W0.00 to W0.03 (automatic)

51

Exercise solution sequencer with SET /


RSET

52

STEP und SNXT

53

Schrittkette mit STEP/SNXT

54

Exercise - Step sequence with


STEP / SNXT
Program a traffic light with the steps:
RED
RED / YELLOW
GREEN
YELLOW
The Transform functions:
8 seconds is up, RED / YELLOW
2 s to come GREEN
5 sec to come YELLOW
3 sec until RED comes
Light red = 6.00
Light yellow = 6.01
Light green = 6.02
Timer 1-4
Step flag W0.00 to W0.03 (automatic)

55

Exercise solution - STEP sequencer /


SNXT

56

indirect addressing
Commands will usually work with fixed addresses.
If you use tables (eg recipes) would for any address in the
Table and a command to be present, which processes the address in the table.
It is simpler, all
Table entries with a
Command to edit.
Then have an
Pointer to the
edit tables
address shows.
PLC kupi vrijed iz dm1, ako je vrijednost 1111, onda ce uzeti vrijednosti iz DM1111, i
prenijeti je u LR00

57

Example: recipe management


Table with bread recipes in the PLC:
Nr. Wasser
D100
0
100
D110
1
80
D120
2
120
D130
3
90

Roggen
D101
200
D111
100
D121
300
D131
0

Weizen
D102
100
D112
200
D122
0
D132
300

Temp.
D103
190
D113
200
D123
240
D133
180

Input screen on the HMI device:

Backzeit
D104
90
D114
100
D124
120
D134
90

Name
D105...109
Oberlnder
D115119
Berliner
D125D129
Eifeler
D135D139
Schweizer

40.00

D0
D10
D13

58

D12
D11
D14

Exercise: Indirect addressing


Expand your existing
Program with a measured
value display.
Depending on the input
value in
Address 0 is to be displayed
in the display (address 4 and
5) either reading 1, 2, 3 or 4.
The measured values are to
take two words, and the
table is to begin in D20.

59

Exercise solution: Indirect addressing

60

Das könnte Ihnen auch gefallen