LGF_ActDeactDevice (FB / V1.0.0)

Overview

Author: Siemens Industry Support

Short description

LGF_ActDeactDevice implements a compact state machine to activate and monitor or deactivate decentral devices.
The module monitors as well the device connection and error state after activation.
It works for PN (S7-1200 / S7-1500) and DP (S7-1500) devices.

Block Interface

LGF_ActDeactDevice (FB)
Bool  enable valid  Bool
    
Bool  activate busy  Bool
    
Bool  deactivate error  Bool
    
HW_DEVICE  hwId status  Word
    
LGF_typeActDeactDeviceParameter  parameter activating  Bool
    
   isActivated  Bool
    
   deactivating  Bool
    
   isDeactivated  Bool
    
   deviceStateOK  Bool
    
   diagnostics  LGF_typeDiagnostics
    
   

Input parameter

IdentifierData type Default value Description
enableBool FALSE TRUE: Enable functionality of FB
activateBool FALSE Rising edge: Activate device given by `hwId`
deactivateBool FALSE Rising edge: Deactivate device given by `hwId`
hwIdHW_DEVICE --- Hardware ID of the device which should be activated / deactivated (`Device~PnIf~IODevice`)
parameterLGF_typeActDeactDeviceParameter --- Parameter dataset for the function `LGF_ActDeactDevice`

Output parameter

IdentifierData type Description
validBool TRUE: Valid set of output values available at the FB
busyBool TRUE: FB is not finished and new output values can be expected
errorBool TRUE: An error occurred during the execution of the FB
statusWord 16#0000 - 16#7FFF: Status of the FB, 16#8000 - 16#FFFF: Error identification
activatingBool TRUE: Activation of device active
isActivatedBool TRUE: Device activated
deactivatingBool TRUE: Deactivating of device active
isDeactivatedBool TRUE: Device deactivated
deviceStateOKBool TRUE: Device is activated and connected to IO-System
FALSE: Device is faulty or not connected, depends on `isActivated`
diagnosticsLGF_typeDiagnostics Diagnostic structure to store and transfer diagnostic information from blocks trough the interface.

Status & Error codes

Code / ValueIdentifier / Description
16#7000STATUS_NO_CALL
No job being currently processed
16#7001STATUS_FIRST_CALL
First call after incoming new job (rising edge 'enable')
16#7002STATUS_SUBSEQUENT_CALL
Subsequent call during active processing without further details
16#8600ERR_UNDEFINED_STATE
Error: Due to an undefined state in state machine
16#8601ERR_LOG2GEO
Error: Log2Geo, may the HW ID for the device is wrong, please see `diagnostics.subFunctionStatus` for more detailed information
16#8601ERR_GEO2LOG
Error: Geo2Log, may the HW ID for the device is wrong, please see `diagnostics.subFunctionStatus` for more detailed information
16#8640ERR_DEVICE_DEACTIVATING
Error: Deactivation (D_ACT_DP) of device, please see `diagnostics.subFunctionStatus` for more detailed information
16#8641ERR_DEVICE_DEACTIVATING_TIME_OUT
Error: Deactivation of device - watchdog time expired
16#8650ERR_READ_ACTIVATION_STATE_WHILE_DEACTIVATED
Error: Deactivation state (D_ACT_DP) of device is wrong, desired is `16#0000` or `16#0002`, please see `diagnostics.subFunctionStatus` for more detailed information
16#8660ERR_DEVICE_ACTIVATING
Error: Activation (D_ACT_DP) of device, please see `diagnostics.subFunctionStatus` for more detailed information
16#8661ERR_DEVICE_ACTIVATING_TIME_OUT
Error: Activation of device cause watchdog time expired. Can be a broken device connection
16#8662ERR_READ_DEVICES_STATES_DURING_ACTIVATION
Error: Read Device states (DeviceStates) during device activation, please see `diagnostics.subFunctionStatus` for more detailed information
16#8670ERR_READ_DEVICES_STATES_WHILE_ACTIVE
Error: Read Device states (DeviceStates) while device active, please see `diagnostics.subFunctionStatus` for more detailed information
16#8671ERR_DEVICE_STATE_WHILE_ACTIVE
Error: Device states present error and is unreachable, faulty Device or IO-System
16#8672ERR_READ_ACTIVATION_STATE_WHILE_ACTIVE
Error: Activation state (D_ACT_DP) of device is wrong, desired is `16#0000` or `16#0001`, please see `diagnostics.subFunctionStatus` for more detailed information
16#8690ERR_DISABLING_DEACT_DEVICE
Error: Deactivation (D_ACT_DP) of device throws an error while disabling, please see `diagnostics.subFunctionStatus` for more detailed information
16#8691ERR_DISABLING_WATCHDOG
Error: Watchdog timer expired while disabling

User defined datatype(s)

LGF_typeActDeactDeviceParameter (UDT / V1.0.0)

This UDT belongs to the Module LGF_ActDeactDevice and lists all possible parameter to configure its behavior.

Identifier Data type Default value Description
timeOutActDeact Time T#2500ms Time to monitor the commands `activate` and `deactivate`
should be greater than the configured `configuration time` in the PLC hardware configuration section `Startup`
timeOutStateMonitoring Time T#100ms Time to monitor the device state while the device is activated
After time has expired an error is present as long as the state is faulty.
enableAndDeactivate Bool TRUE TRUE: Disable / Deactivate device during startup / enabling
(prior to `enableAndActive`)
FALSE: Keep actual state or `enableAndActivate`
enableAndActivate Bool FALSE TRUE: Enable / Activate device during startup / enabling
FALSE: Keep actual state or `enableAndDeactivate`
disableAndDeactivate Bool TRUE TRUE: Disable / Deactivate device during disabling of the module
FALSE: Keep actual state

LGF_typeDiagnostics (UDT / V1.0.0)

Diagnostic structure to store and transfer diagnostic information from blocks trough the interface.

Identifier Data type Default value Description
status Word 16#0000 Status of the Block or error identification when error occurred
subfunctionStatus Word 16#0000 Status or return value of called FB's, FC's and system blocks
stateNumber DInt 0 State in the state machine of the block where the error occurred

Functional description

The module provides the procedure for activating and deactivating remote IO-Devices in the Profinet (PN, S7-1500 & S7-1200) and Profibus (DP, S7-1500) network.

The activation of the device (defined at hwId) is initiated by a rising edge at activate, after complete activation this is indicated at the output isActivated and deviceStateOK. After that the connection status is displayed at the deviceStateOK output.
The connection is monitored and in case of a failure of this of more than the set monitoring time timeOutStateMonitoring at the output and reported as an error. After successful recovery of the connection by the system, the configured time is also waited until the error is reset to ensure stability.


Note
The connection status of the decentralized device can also be displayed in the TIA Portal project navigation in the PLC, which is the controller, under the item 'Distributed I/O', if they are online with the engineering system.

Deactivation of the device (defined at hwId) is initiated by a rising edge at deactivate, after complete activation this is indicated at the output isDeactivated.

It is possible to define the states for switching on and off, as well as the monitoring times for activating and deactivating and the connection monitoring.

All errors are automatically reset as soon as the faulty state is eliminated.
The exception to this are errors that can only be corrected by an intervention in the software, such as an incorrect or non-existent hardware ID of a non-existent decentralized IO device.


Note
The parameter timeOutActDeact for monitoring the activation and deactivation sequence should always be set higher than the parameterized value in the Device configuration / Startup / Configuration time.

Parameterization PLC

Change log

Version & DateChange description
01.00.00Simatic Systems Support
06.04.2023First released version