PLC API 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 [ } 40] . 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 [ } 132] or the TcDatabaseSrv_Error_Codes [ } 135] when the bError output is set. TS6420 73 Version: 1.2