FB_DBWrite
The FB_DBWrite function block can be used to write the values of individual variables into databases.
The table structure have to contain the columns "Timestamp", "Name" and "Value". see SQL Compact Database. To use the function block, you have to declare the required database and ADS device in the XML - configuration file.
VAR_INPUT
VAR_INPUT
sNetID : T_AmsNetID;
hDBID : UDINT;
hAdsID : UDINT;
sVarName : T_MaxString;
nIGroup : UDINT;
nIOffset : UDINT;
nVarSize : UDINT;
sVarType : T_MaxString;
sDBVarName : T_MaxString;
eDBWriteMode : E_DBWriteModes;
tRingBufferTime : TIME;
nRingBufferCount : UDINT;
bExecute : BOOL;
tTimeout : TIME;
END_VAR
sNetID : Is a string containing the AMS network identifier of the target device to which the ADS command is directed.
hDBID : Is the ID of the database to be used.
hAdsID : This is the ID of the ADS device to be used.
sVarName : Provides the name of the variable.
nIGroup : Index group of the variable (optional, only on the BC9000).
nIOffset : Index offset of the variable (optional, only on the BC9000).
nVarSize : Size of the variable in bytes (optional, only on the BC9000).
sVarType : Data type of the variable (optional, only on the BC9000).
Possible variable data types: "BOOL" / "LREAL" / "REAL" / "INT16" / "DINT" / "USINT" / "BYTE" / "UDINT" / "DWORD" / "UINT16" / "WORD" / "SINT"
sDBVarName : Variable name to be used in the database.
eDBWriteMode : Determines if the new records will be added or if the existing records will be updated.
tRingBufferTime : Contains the maximum age of datasets in a table. (only at Ringbuffer_WriteMode)
nRingBufferCount : Contains the maximum count of datasets in a table. (only at Ringbuffer_WriteMode)
bExecute : The command is executed with the rising edge.
tTimeout; : States the time before the function is cancelled.
VAR_OUTPUT
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
nErrID : UDINT;
sSQLState : ST_DBSQLError;
END_VAR
bBusy : The command is in the process of being transmitted by ADS. No new command will be accepted as long as "bBusy" remains TRUE.
bError : Becomes TRUE, as soon as an error occurs.
nErrID : Supplies the ADS Error Code or the TcDatabaseSrv_Error_Codes when the bError output is set.
sSQLState : Supplies the SQL error code of the specified database type.
Logging of values from an ADS-device (not for BC9000) | Logging of values from a BC9000 |
---|---|
FB_DBWrite1( | FB_DBWrite1( |
Requirements
Development environment | Target system type | PLC libraries to be linked |
---|---|---|
TwinCAT v2.10.0 | PC or CX (x86) | TcDatabase.Lib |
TwinCAT v2.10.0 | CX (ARM) |