Start / stop of cyclic logging with FB_DBCyclicRdWrt

Download "Example Start / Stop of the cyclic log" sample2.zip

In this example the start and stop of the cyclic log out of the PLC will be shown.

Start / stop of cyclic logging with FB_DBCyclicRdWrt 1:

Used database type

MS Compact SQL

Compatible databse type

ASCII, MS SQL, MS Compact SQL, MS Access, MySQL, PostgreSQL, DB2, Oracle, InterBase/Firebird

Used function blocks

FB_DBCyclicRdWrt

Integrated libraries

"TcDatabase.lib", "TcSystem.lib","TcBase.lib","TcStandard.lib"

Download data list

FB_DBCyclicRdWrt_Sample.pro, CurrentConfigDataBase.xml, TestDB_Cyclic.sdf

In this example the cyclic log function will be started or stopped by toggling of the bStartStop variable.

At a positive edge at the bExecute input the cyclic log operation starts. At a negative edge this will be stoped.

Variable declaration (PRG DataTypes)

PROGRAM DataTypes
VAR
    DBSrv_DT_INT        : INT;
    DBSrv_DT_UINT       : UINT;
    DBSrv_DT_DINT       : DINT;
    DBSrv_DT_UDINT      : UDINT;
    DBSrv_DT_REAL       : REAL;
    DBSrv_DT_LREAL      : LREAL;
    DBSrv_DT_BYTE       : BYTE := 16#A1;
    DBSrv_DT_BOOL       : BOOL;
    DBSrv_DT_MYSTRUCT   : ST_MyStruct;
    DBSrv_DT_ARRAY      : ARRAY [0..19] OF UDINT;
    DBSrv_DT_WORD       : WORD;
    DBSrv_DT_DWORD      : DWORD;
END_VAR

Structure ST_MyStruct

TYPE ST_MyStruct :
STRUCT
    iValue1 : INT;
    iValue2 : UINT;
    iValue3 : BOOL;
    iValue4 : REAL;
END_STRUCTEND_TYPE

Variable declaration

PROGRAM MAIN
VAR
    fbDBCyclicRdWrt1: FB_DBCyclicRdWrt;
    
    bCyclic     : BOOL    :=TRUE;
    
    bBusy_Cyclic    : BOOL;
    bErr        : BOOL;
    nErrID      : UDINT;
    sSQLState           : ST_DBSQLError;
END_VAR

PLC Program

DataTypes;

fbDBCyclicRdWrt(
    sNetID := ,
    bExecute := bCyclic,
    tTimeout := t#15s,
    bBusy => bBusy_Cyclic,
    bError => bErr,
    nErrID => nErrID,
    sSQLState => sSQLState);

To use this example, you need to pass over the NetID of the ADS device (on which the TwinCAT Database Server is installed) to the input sNetID. 
If you start the program and set the bCyclic variable to TRUE, all variables will be logged, that are declared in the symbol group of the XML-configuration data.

Start / stop of cyclic logging with FB_DBCyclicRdWrt 2:

All the Microsoft SQL Compact databases that are declared in the XML configuration file must exist. They are not generated automatically.
The declared ASCII files, on the other hand, are generated automatically if they do not exist.