ADSRDSTATE
The function block requests the state of an ADS device.
Inputs
VAR_INPUT
NETID : T_AmsNetId;
PORT : T_AmsPort;
RDSTATE : BOOL;
TMOUT : TIME := DEFAULT_ADS_TIMEOUT;
END_VAR
Name | Type | Description |
---|---|---|
NETID | T_AmsNetId | String containing the AMS network ID of the target device to which the ADS command is addressed (type: T_AmsNetId). |
PORT | T_AmsPort | Port number of the ADS device (type: T_AmsPort). |
RDSTATE | BOOL | The ADS command is triggered by a rising edge at this input. |
TMOUT | TIME | Indicates the time before the function is canceled. |
Outputs
VAR_OUTPUT
BUSY : BOOL;
ERR : BOOL;
ERRID : UDINT;
ADSSTATE : UINT;
DEVSTATE : UINT;
END_VAR
Name | Type | Description |
---|---|---|
BUSY | BOOL | This output remains TRUE until the function block has executed a command, but at the longest for the duration supplied to the Timeout input. While BUSY = TRUE, no new command will be accepted at the inputs. Note that it is not the execution of the service but its acceptance whose time is monitored. |
ERR | BOOL | This output is switched to TRUE as soon as an error occurs during the execution of a command. The command-specific error code is contained in ERRID. If the function block has a timeout error, ERR is TRUE and ERRID is 1861 (hexadecimal 0x745). Is reset to FALSE by the execution of a command at the inputs. |
ERRID | UDINT | ADS error code or command-specific error code of the last executed command. Is reset to 0 by the execution of a command at the inputs. |
ADSSTATE | UDINT | Contains the state identification code of the ADS target device. |
DEVSTATE | UDINT | Contains the specific state identification code of the ADS target device. The codes returned here are supplementary information specific to the ADS device. |
State identification code of the ADS target device
The codes returned here are specified for all ADS servers:
- ADSSTATE_INVALID = 0;
- ADSSTATE_IDLE = 1;
- ADSSTATE_RESET = 2;
- ADSSTATE_INIT = 3;
- ADSSTATE_START = 4;
- ADSSTATE_RUN = 5;
- ADSSTATE_STOP = 6;
- ADSSTATE_SAVECFG = 7;
- ADSSTATE_LOADCFG = 8;
- ADSSTATE_POWERFAILURE = 9;
- ADSSTATE_POWERGOOD = 10;
- ADSSTATE_ERROR = 11;
- ADSSTATE_SHUTDOWN = 12;
- ADSSTATE_SUSPEND = 13;
- ADSSTATE_RESUME = 14;
- ADSSTATE_CONFIG = 15;
- ADSSTATE_RECONFIG = 16;
- ADSSTATE_STOPPING = 17;
- ADSSTATE_INCOMPATIBLE = 18;
- ADSSTATE_EXCEPTION = 19;
Sample of calling the function block in FBD:
In this sample the PLC runtime system 1 (port no. 801) on the computer with network address 1.1.1.2.7.1 is asked about its state. The answer is adsState = 1 (IDLE) without supplementary code devState=0.
Requirements
Development environment |
Target system type |
PLC libraries to include (Category group) |
---|---|---|
TwinCAT v3.1.0 |
PC or CX (x86, x64, ARM) |
Tc2_System (System) |