Diagnostic functions in the user program

Một phần của tài liệu Hans berger automating with SIMATIC s7 1200 configuring programming (Trang 173 - 177)

The following functions are available to evaluate diagnostics alarms in the user program:

b LED Read status of an LED

b DeviceStates Read status of distributed I/O devices b ModuleStates Read status of a central I/O modules b GET_DIAG Read diagnostic information

LED Read status of an LED

LED reads the status of a module LED. The parameter LADDR specifies the module and the parameter LED specifies the LED. RET_VAL indicates the current status of the specified LED. Fig. 5.26 shows the function call.

Fig. 5.26 Read status of an LED

Declaration Name

EN ENO LADDR LED RET_VAL

– – INPUT INPUT RETURN

BOOL BOOL HW_IO UINT INT

Enabling input Enabling output Module ID LED number LED status Description Data type

LED

Parameter LED Parameter RET_VAL LED

EN LADDR LED

EN LADDR LED

ENO RET_VAL

RET_VAL ENO LAD

FBD

Read status of an LED

SCL #var_... := LED(LADDR := #var_... , LED := #var_... );

Value LED STOP/RUN

2 ERROR

1

3 MAINT

4 redundant

5 Link (green) 6 Rx/Tx (yellow)

Value LED status 0 LED does not exist 1 Permanently switched off 3

Color 1 flashes at 2 Hz 5

6 Colors 1 and 2 flash alternately at 2 Hz 7 LED is active, color 1

8 LED is active, color 2

9 LED exists, but no status information is available If the RET_VAL parameter displays the value 16#80xx, there is a parameterization error.

Color 2 flashes at 2 Hz

Color 1 permanently switched on (e.g. green for STOP/RUN LED) 4

2

Color 2 permanently switched on (e.g. orange for STOP/RUN LED)

The module ID can be found in the System constants tab in the default tag table or the module properties in the Properties tab in the inspector window under General in the Name field. At the LADDR parameter, enter this name or select it from the drop-down list. You can also specify the numerical value of the module ID, which is provided as a constant or variable in the System constants tab.

DeviceStates Read status of distributed I/O devices

DeviceStates reads the status of the I/O stations in a PROFINET IO system. At the LADDR parameter, you can enter the system ID of the PROFINET IO system. With the MODE parameter, you can select the type of status information that is displayed at the STATE parameter for all I/O stations. Fig. 5.27 shows the function call.

The system ID can be found either in the System constants tab in the default tag table or in the PROFINET IO system properties in the Properties tab in the inspector win- dow under General in the Name field. At the LADDR parameter, enter this name or select it from the drop-down list. You can also specify the numerical value of the system ID, which is provided as a constant or variable in the System constants tab.

Via the MODE parameter you select the type of status information to be output at the STATE parameter (Fig. 5.27). With a bit set to signal state “1”, the bit field at the STATE parameter shows that the selected status information applies to the affected station. Example: If you want to determine which stations are disrupted, assign the value 2 to the MODE parameter. Bit 0 at the STATE parameter has signal state “1” if

Fig. 5.27 Read status of distributed stations

Declaration Name

EN ENO LADDR MODE STATE RET_VAL

– – INPUT INPUT INOUT RETURN

BOOL BOOL HW_IOSYSTEM UINT VARIANT INT

Enabling input Enabling output System ID Type of information Status information Error information Description Data type

DeviceStates

DeviceStates EN

LADDR MODE STATE

EN LADDR MODE STATE

ENO RET_VAL

RET_VAL ENO LAD

FBD

Read status of distributed stations

SCL #var_... := DeviceStates(LADDR := #var_... , MODE := #var_... , STATE := #var_... );

Parameter MODE Parameter STATE

Value Description

1 Configuration not completed 2 Station faulty

3 Station deactivated 4 Station available 5 Station has a problem

The STATE parameter displays every station with a bit (1024 for PROFINET). The number of the bit corresponds to the station or device number.

If the respective bit has signal state “1”, the status indicated at the MODE parameter applies to the station.

The status is valid across all stations in bit 0:

If bit 0 has signal state “1”, the scanned status applies to at least one station."

at least one of the stations is disrupted. If bit 4 is set to signal state “1”, the station with device number 4 is disrupted.

The STATE parameter can be assigned to any tag or an operand area, for example, with P#DB10.DBX0.0 BYTE 128, i.e. 1024 bits in data block %DB10 from data byte

%DBB0. If the tag or the area is too small, the status information is entered in the available length and error number 16#8452 is output at parameter RET_VAL.

ModuleStates Read status of a module

ModuleStates reads the status of submodules in a module. At the LADDR param- eter, specify the module ID and use the MODE parameter to select the type of sta- tus information that is output at the parameter STATE for all submodules of the module. Fig. 5.28 shows the function call.

The module ID can be found in either the System constants tab in the default tag table or in the properties of the module in the Properties tab in the inspector win- dow. under General in the Name field. At the LADDR parameter, enter this name or select it from the drop-down list. You can also specify the numerical value of the module ID, which is provided as a constant or variable in the System constants tab.

Via the MODE parameter you select the type of status information to be output at the STATE parameter (Fig. 5.28). With a bit set to signal state “1”, the bit field at the

Fig. 5.28 Read status of a central module

Declaration Name

EN ENO LADDR MODE STATE RET_VAL

– – INPUT INPUT INOUT RETURN

BOOL BOOL HW_DEVICE UINT VARIANT INT

Enabling input Enabling output Block ID

Type of information Status information Error information Description Data type

ModuleStates

ModuleStates EN

LADDR MODE STATE

EN LADDR MODE STATE

ENO RET_VAL

RET_VAL ENO LAD

FBD

SCL #var_... := ModuleStates(LADDR := #var_... , MODE := #var_... , STATE := #var_... );

Parameter MODE Parameter STATE

Value Description

1 Configuration not completed 2 Submodule faulty

3 4 5

Submodule deactivated Submodule available Submodule has a problem

The STATE parameter displays every each submodule of a module with a bit (maximal 128). The number of the bit corresponds to the slot of the submodule in the module. If the respective bit has signal state “1”, the status indicated at the MODE parameter applies to the submodule. The status is valid across all submodules in bit 0: If bit 0 has signal state “1”, the scanned status applies to at least one submodule.

Read status of a central module

STATE parameter shows that the selected status information applies to a submod- ule of the affected module. Example: If you want to determine which submodules are disrupted, assign the value 2 to the MODE parameter. Bit 0 of the STATE param- eter has signal state “1” if at least one submodule is disrupted. If bit 2 is set to signal state “1”, the submodule at slot 2 is disrupted.

The STATE parameter can be assigned to any tag or an operand area, for example, with P#M512.0 BYTE 16, i.e. 128 bits from memory byte %MB512. If the tag or the area is too small, the status information is entered in the available length and error number 16#8452 is output at parameter RET_VAL.

GET_DIAG Read diagnostic information

GET_DIAG reads the diagnostic information of a hardware object. At the LADDR parameter, specify the ID of the hardware object. With the MODE parameter, select the type of diagnostic information that is output at the DIAG parameter. Fig. 5.29 shows the function call.

Fig. 5.29 Read diagnostic information Read diagnostic information

Declaration Name

EN ENO MODE LADDR DIAG DETAIL RET_VAL CNT_DIAG

– – INPUT INPUT INOUT INOUT RETURN OUTPUT

BOOL BOOL UINT HW_ANY VARIANT VARIANT INT INT

Enabling input Enabling output Type of diagnostic data Objekt-ID

Diagnostic information Diagnostic details Error information Number of diag. details Description

Data type GET_DIAG

GET_DIAG EN

MODE DIAG LADDR DETAIL

EN MODE DIAG LADDR DETAIL

ENO RET_VAL CNT_DIAG

CNT_DIAG RET_VAL ENO LAD

FBD

SCL #var_... := GET_DIAG(MODE := #var_... , LADDR := #var_... , CNT_DIAG := #var_... , DIAG := #var_... , DETAIL := #var_... );

Parameter MODE Value Description

0 Output of the diagnostic information supported by the hardware object to DIAG 1 Output of own diagnostic status to DIAG

2 Output of the diagnostic status of all subordinate modules to DIAG and output of the module status information to DETAIL

3 4

Output of the I/O status to DIAG, output of the number of additionally output details to CNT_DIAG, and output of the channel statuses to DETAIL

Output of the diagnostic data of all subordinate modules to DIAG

The diagnostic information output at the DIAG and DETAIL parameters depends on the selected hardware object (see operating instructions).

The object ID can be found either in the System constants tab in the default tag table or in the properties of the hardware object in the Properties tab in the inspector win- dow under General in the Name field. At the LADDR parameter, enter this name or select it from the drop-down list. You can also specify the numerical value of the object ID, which is provided as a constant or variable in the System constants tab.

Via the MODE parameter you select the type of information to be output at the DIAG parameter (Fig. 5.29). The value 0 is used to query what diagnostic informa- tion the hardware object supports. Each bit set to signal state “1” at the DIAG parameter corresponds to an assignment of the MODE parameter: If the bit 1 is set, MODE = 1 is supported. If the bit 2 is set, MODE = 2 is supported, etc. CNT_DIAG is set to value 0; DETAIL is not changed.

If MODE = 1, the diagnostic information of the selected hardware object is output at parameter DIAG. CNT_DIAG is set to value 0, DETAIL is not changed.

If MODE = 2, the diagnostic status of all the modules in the hardware object is out- put at parameter DIAG. CNT_DIAG is set to value 1, DETAIL contains module state information.

If MODE = 3, the state of the inputs and outputs of the selected hardware object is output at parameter DIAG. CNT_DIAG is set to the number of module channels whose status data is output at the parameter DETAIL.

If MODE = 4, the state of the inputs and outputs of all modules in the hardware object is output at parameter DIAG. CNT_DIAG is set to value 0, DETAIL is not changed.

Một phần của tài liệu Hans berger automating with SIMATIC s7 1200 configuring programming (Trang 173 - 177)

Tải bản đầy đủ (PDF)

(577 trang)