Setting PROFIBUS address via the PLC
The PROFIBUS address is used to assign a unique identification to the devices in a PROFIBUS network in order to enable communication between the controller and the connected devices. In addition to the setting options in TwinCAT, the PROFIBUS address can also be set via the PLC.
Proceed as follows:
- 1. Activate the option Get Station No. from PLC in TwinCAT and activate the project.
- 2. The CX7031 initially starts without a PROFIBUS address and there is no PROFIBUS communication.
- 3. Assign a PROFIBUS address to the PROFIBUS slave using the function block ADSWRITE.
AMS Net ID //from CX7031 device
Port := 200
IDXGRP:= 16#F480
IDXOFFS:= 0..3 //(if you have configured up to 4 slaves)
LEN:=1
- 4. The first byte of data then contains the PROFIBUS address of the slave. When working with several slaves on the CX7031, make sure that when writing a new PROFIBUS address, the PROFIBUS slaves already in communication are temporarily disconnected from the data exchange.
- The address is stored in the CX7031, i.e. the written addresses remain valid for the slaves in the event of a TwinCAT restart or Power-ON. Reading back via the function block ADSREAD is not possible.
If several slaves are used in the CX7031, only one slave can be switched active or inactive at a time. If, for example, all of the maximum possible 4 slaves are to receive a PROFIBUS address from the PLC, this must be done one after the other and cannot be done simultaneously. It should also be noted that every change of state results in the other devices briefly leaving the data exchange; technically, this cannot be solved in any other way. Even if you disable one of the slaves that is in data exchange, the other slaves will also briefly fail, but will immediately re-establish the connection. You must take this into account in your application. If your application cannot handle it, you cannot use the feature.
Further application scenarios
The description of further application scenarios is intended as a suggestion and does not claim to be exhaustive.
1. Use Hot-Connect:
This feature can be used to activate slaves when the CX7031 detects a specific configuration via EtherCAT, for example. Such a configuration could be a Hot-Connect group, for example.
If a specific Hot-Connect group is detected, the corresponding PROFIBUS address is set and the slave is activated. If the Hot-Connect group does not exist, the PROFIBUS address is set to "0". This can also be done during operation if the Hot-Connect group is connected via EtherCAT. As up to four slaves can be created, it is recommended to use a maximum of three Hot-Connect groups.
2. Send diagnostic data:
The PROFIBUS diagnostic data can be sent via ADSWRITE. The manufacturer-specific diagnostics starts from the 6th byte with the length of the following diagnostic data. The first byte of the diagnostic data must always be 0x08 so that manufacturer-specific diagnostics are sent; bytes 2...6 are set by the driver and cannot be changed by your application.
Example for 10 bytes diagnostic data for slave no. 2:
DiagArray[0]:=16#08; // Must be set to trigger manufacturer-specific diagnostics
DiagArray[1..5]:=16#00; // Described by the CX
DiagArray[6]:=10; // 10 bytes of diagnostic data including length information
DiagArray[7..15]:=Value; // Your diagnostic data
ADS Write:
AMD Net ID := CX7031 Interface
Port := 1002; // 1000dec + Slave Address
IDXGRP:= 16#F481;
IDXOFFS:= 0;
LEN:=16; // 6 bytes + manufacturer-specific diagnostics
If you also want to use alarm or error modules from your higher-level control system, this is another application scenario that you can use. Such alarm or error function blocks are usually processed and called differently in the master controller than the standard I/O data.
If, for example, the CX has an error and the EtherCAT master has detected a problem, the normal I/O data for the PROFIBUS initially continues to run independently of this. To indicate to the PROFIBUS master that the slave has detected an error, the slave can send a diagnosis message. The advantage of a diagnosis message is that it is event-driven and, depending on the PROFIBUS master, is also processed in special function blocks and/or displayed visually.
In addition, minimum and maximum values can be set via the diagnostics, e.g. if a fill level is exceeded or not reached. This diagnostic data is recorded and stored in special fault loggers, especially in process engineering systems.