PLC Program Examples
11--1
1070 072 196-101 (00.06) GB
11 PLC Program Examples
11.1 Function Module
Below you find an example of a function module for reading out via Ethernet
a data module from another controller. The parameters are generated dy-
namically in a DM. All auxiliary variables are located in this DM as well. After
the DM has been read in, a counter variable is incremented and a new read-
ing job is started.
; --------------------------------------------------------------------------------
; Reading a DM via Ethernet
; Parameter handling in a work DM
; --------------------------------------------------------------------------------
; Call parameters of the module
;P0 RssNr WORD VAR_INPUT RSSNo. (RSS No. in the high byte)
;P1 DB_NR WORD VAR_INPUT Data module to command handling (min. 60 words)
;P2 STATUSWORD VAR_IN_OUT Statuses of the command (0:New 1:Run 2:O.K.
; otherwise error)
;P3 DBNrPSTWORD VAR_INPUT DM number on the PST
;P4 BlkAdrPSTWORD VAR_INPUT Block address PST
;P5 DBNrASTWORD VAR_INPUT DM number on the AST
;P6 BlkAdrASTWORD VAR_INPUT Block address AST
;P7 Anzahl WORD VAR_INPUT Amount of data to be read (in words)
;P8 Offset WORD VAR_INPUT Offset in the DMs
;P9 IPAdr_LWORD VAR_INPUT Low part Internet address
;P10 IPAdr_HWORD VAR_INPUT High part Internet address
;P11 CNT WORD VAR_IN_OUT Command counter
;Usage of the scratch DM
;DM 0 to 31 CommandParameter
;DM 32 to 37 Error
DEF D38,-ErgMerk ;Marker for module result
DEF D40,-ErrMerk ;Marker for module error
DEF D42,-DBnr
DEF D44,-Para1 ;Call parameters Req and Con
DEF D46,-Para2
DEF D48,-Para3
L W -DB_Nr,A ;Activating the work data module
CM [A]
T W A,-DBnr
L W -Status,A ;Evaluation of current command status
CPLA W 0,A
JPZ initdata ;At 0: new command
CPLA W 1,A
JPZ execute ;At 1: poll command
CPLA W 2,A
JPZ vonvorn ;At 2: trigger new command
fehler: ;otherwise: error
EM