Reading And Writing Plc Variables - Siemens SINUMERIK 808D User Manual

Programming and operating manual (milling)
Hide thumbs Also See for SINUMERIK 808D:
Table of Contents

Advertisement

Each data type requires its own program line. However, several variables of the same type can be defined in one line.
Example:
DEF INT PVAR1, PVAR2, PVAR3=12, PVAR4
Example for STRING type with assignment:
DEF STRING[12] PVAR="Hello"
Fi elds
In addition to the individual variables, one or two-dimensional fields of variables of these data types can also be defined:
DEF INT PVAR5[n]
DEF INT PVAR6[n,m]
Example:
DEF INT PVAR7[3]
Within the program, the individual field elements can be reached via the field index and can be treated like individual
variables. The field index runs from 0 to a small number of the elements.
Example:
N10 PVAR7[2]=24
Value assignment for field with SET instruction:
N20 PVAR5[2]=SET(1,2,3)
Value assignment for field with REP instruction:
N20 PVAR7[4]=REP(2)
11.13.3

Reading and writing PLC variables

Fu n ctionality
To allow rapid data exchange between NC and PLC, a special data area exists in the PLC user interface with a length of 512
bytes. In this area, PLC data are compatible in data type and position offset. In the NC program, these compatible PLC
variables can be read or written.
To this end, special system variables are provided:
$A_DBB[n]
$A_DBW[n]
$A_DBD[n]
$A_DBR[n]
"n" stands here for the position offset (start of data area to start of variable) in bytes
Programming example
R1=$A_DBR[4]
N o te
The reading of variables generates a preprocessing stop (internal STOPRE).
N o te
Writing of PLC tags is generally limited to a maximum of three tags (elements).
Where PLC tags are to be written in rapid succession, one element will be required per write operation.
If more write operations are to be executed than there are elements available, then block transfer will be required (a
preprocessing stop may need to be triggered).
Example:
$A_DBB[1]=1 $A_DBB[2]=2 $A_DBB[3]=3
STOPRE
$A_DBB[4]=4
128
;One-dimensional field, type INT, n: integer
;Two-dimensional field, type INT, n, m: integer
;Field with 3 elements of the type INT
;The third field element (with index 2) is assigned the value
24.
;After the 3rd field element, different values are assigned.
;After field element [4] - all are assigned the same value,
here 2.
;Data byte (8-bit value)
;Data word (16-bit value)
;Data double-word (32-bit value)
;REAL data (32-bit value)
;Reading a REAL value, offset 4 (starts at byte 4 of range)
;4 type INT variables
; Define variable PVAR with a maximum of 12 char-
acters and assign string "Hello"
Programming and Operating Manual (Milling)
6FC5398-4DP10-0BA6, 09/2017

Advertisement

Table of Contents
loading

Table of Contents