16.5 System blocks for distributed I/O
16.5.1 System blocks for PROFIBUS DP
The following system blocks can be used together with PROFIBUS DP:
b DP_PRAL Trigger hardware interrupt with DP master (SFC 7) b DPSYC_FR Send SYNC/FREEZE commands (SFC 11)
b DPNRM_DG Read diagnostic data from a DP standard slave (SFC 13) b DP_TOPOL Determine bus topology (SFC 103)
Fig. 16.19 shows the graphic representation of the system block calls for PROFIBUS DP.
In addition to the blocks listed above, you can use the following blocks with PROFIBUS DP and also with PROFINET IO:
b GETIO Read all inputs of a station (FB 20) b SETIO Write to all outputs of a station (FB 21) b GETIO_PART Read some inputs of a station (FB 22) b SETIO_PART Write to some outputs of a station (FB 23) b D_ACT_DP Activate/deactivate distributed station (SFC 12) b DPRD_DAT Read user data (SFC 14)
b DPWR_DAT Write user data (SFC 15)
Fig. 16.18 Activation of isochronous mode in a DP slave
These blocks are described in Chapter 16.5.2 “System blocks for PROFIBUS DP and PROFINET IO” on page 668.
DP_PRAL Trigger hardware interrupt at DP master
DP_PRAL triggers a hardware interrupt from the user program of an intelligent slave for the corresponding DP master. This results in starting of organization block OB 40 in the program of the master CPU.
You can use the AL_INFO parameter for a self-defined interrupt ID which is trans- ferred to the start information of the interrupt OB called in the DP master (OB40_POINT_ADDR tag). REQ = “1” triggers the interrupt request; the RET_VAL and BUSY parameters show the job status. The job is completed when processing of the interrupt OB has been finished in the master CPU.
The user data interface between DP master and intelligent DP slave can be divided into individual transfer areas which represent individual “modules” from the view- point of the master CPU. The lowest address of a transfer area is the module start address. You can trigger a hardware interrupt in the master CPU for each of these
“virtual” slots.
You specify a transfer area using the IOID and LADDR parameters from the view- point of the slave CPU. The start information of the interrupt OB then contains the addresses of the interrupt-triggering “module” from the viewpoint of the master CPU.
Fig. 16.19 Graphic representation of system blocks for PROFIBUS DP
DPNRM_DG DP_TOPOL
SFC 13
Read diagnostics data
SFC 103
Determine bus topology System blocks for PROFIBUS DP
REQ REQ
LADDR R
DP_ID
RET_VAL RET_VAL
BUSY DPR
DPSYN_FR DP_PRAL
SFC 11
Send SYNC/FREEZE command SFC 7
Trigger hardware interrupt
REQ REQ
IOID LADDR AL_INFO
LADDR GROUP MODE
RET_VAL RET_VAL
BUSY BUSY
RECORD BUSY
DPRI
DPSYC_FR Send SYNC/FREEZE commands
DPSYC_FR sends the SYNC, UNSYNC, FREEZE, and UNFREEZE commands to a SYNC/FREEZE group which you have configured with the hardware configuration.
The send procedure is triggered by REQ = “1” and is finished when BUSY signals “0”.
In the GROUP parameter, each group occupies one bit (from bit 0 = group 1 to bit 7 = group 8). The commands in the MODE parameter are also organized in bits:
b UNFREEZE if bit 2 = “1”
b FREEZE if bit 3 = “1”
b UNSYNC if bit 4 = “1”
b SYNC if bit 5 = “1”
SYNC and UNSYNC commands or FREEZE and UNFREEZE commands must not be triggered simultaneously in a call.
Following a startup, SYNC mode and FREEZE mode on the DP slaves are initially switched off. The inputs of the DP slaves are scanned in sequence by the DP master and the outputs of the DP slaves are controlled; the DP slaves immediately output the received output signals at the output terminals.
If you wish to “freeze” the input signals of several DP slaves at a certain time, output the FREEZE command to the associated group. The input signals read by the DP master in succession have the signal states which they had when “freezing”. These input signals retain their values until you use a further FREEZE command to re- quest the DP slaves to read in and freeze updated input signals, or until you switch the DP slaves back to “normal” mode using the UNFREEZE command.
If you wish to output the output signals of several DP slaves synchronously at a cer- tain time, first output the SYNC command to the associated group. The addressed DP slaves then retain the current signals at the output terminals. You can then transfer the desired signal states to the DP slaves. Output the SYNC command again following completion of transfer; in this manner you request the DP slaves to connect the received output signals simultaneously to the output terminals. The DP slaves retain the signals at the output terminals until you connect the new output signals using a further SYNC command, or until you switch the DP slaves back to
“normal” mode using the UNSYNC command.
Note that the SYNC and FREEZE commands are still valid following a cold restart or warm restart.
DPNRM_DG Read diagnostic data
DPNRM_DG reads the diagnostic data of a DP standard slave. The read procedure is triggered by REQ = “1” and is finished when BUSY signals “0”. The number of read bytes is then present in the function value RET_VAL. Depending on the slave, the di- agnostic data is at least 6 bytes and a maximum of 240 bytes long. The first 240 bytes are transferred if the diagnostic data is longer and then the corresponding overflow bit is set in the data.
The RECORD parameter describes the area in which the read data is saved. Tags with data types ARRAY and STRUCT, a PLC data type, or an ANY pointer with data type BYTE (e.g. P#DBzDBXy.x BYTE nnn) are permissible as actual parameters.
Note that DPMRM_DG is a system function which operates asynchronously. It must be processed until the BUSY parameter has signal state “0”. RALRM is a system block which makes the data available synchronously, i.e. immediately following the call.
DP_TOPOL Determine bus topology
DP_TOPOL uses a diagnostics repeater to determine the bus topology of the DP master system whose ID you specify in the DP_ID parameter. The determination is triggered by REQ = “1” and is finished when BUSY signals “0”. You can use R = “1”
to cancel determination of the topology.
If an error is signaled by a diagnostics repeater, determination of the bus topology is prevented and this is shown in the DPR and DPRI parameters. If several diagnos- tics repeaters signal errors, the error message of the first one is displayed and the complete diagnostic information can be read with DPNRM_DG or the programming device.
A distinction is made between temporary and permanent faults in the error infor- mation in the DPRI parameter. In certain circumstances it may not be possible to conclusively identify temporary faults such as a loose contact and these may disap- pear on their own. You must eliminate permanent faults before you call DP_TOPOL again to determine the topology.
Following processing of DP_TOPOL, the determined data is available on the diag- nostics repeater and can be read using RDREC. The data comprises the topology of the bus segment (stations and cable lengths), the contents of the segment diagnos- tic buffers (last ten events with fault information, location, and cause), and the sta- tistics data (information on the quality of the bus system).
The diagnostics repeater is described in Chapter 16.4.4 “Coupling modules for PROFIBUS DP” on page 659.