beckhoff TS6420 — 8.5 Sample with FB_DBRecordInsert/FB_DBRecordSelect

Samples FB_DBWrite_Append(bExecute := FALSE); eState := eIdle; END_IF(*Add a new record to the table tbl_Update if it not exist else the existing record wi ll be updated*) eWriteUpdate : FB_DBWrite_Update( sNetID:= , hDBID:= 2, hAdsID:= 1, sVarName:= 'MAIN.lrTestValueVar', nIGroup:= , nIOffset:= , nVarSize:= , sVarType:= , sDBVarName:= 'lrTestValueVar', eDBWriteMode:= eDBWriteMode_Update, tRingBufferTime:= , nRingBufferCount:= , bExecute:= TRUE, tTimeout:= T#15s, bBusy=> bBusy, bError=> bErr, nErrID=> bErrid, sSQLState=> stSqlstate); IF NOT bBusy THEN FB_DBWrite_Update(bExecute := FALSE); eState := eIdle; END_IF(*Add a new record to the table tbl_RingBuffer.

If the maximum count is reached the re cords will be deleted in a FIFO process*) eWriteRingBuffer : FB_DBWrite_RingBuffer( sNetID:= , hDBID:= 3, hAdsID:= 1, sVarName:= 'MAIN.lrTestValueVar', nIGroup:= , nIOffset:= , nVarSize:= , sVarType:= , sDBVarName:= 'lrTestValueVar', eDBWriteMode:= eDBWriteMode_RingBuffer_Count, tRingBufferTime:= , nRingBufferCount:= 10, bExecute:= TRUE, tTimeout:= T#15s, bBusy=> bBusy, bError=> bErr, nErrID=> bErrid, sSQLState=> stSqlstate); IF NOT bBusy THEN FB_DBWrite_RingBuffer(bExecute := FALSE); eState := eIdle; END_IFEND_CASE 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. 8.5 Sample with FB_DBRecordInsert/FB_DBRecordSelect Download "Example to log with the FB_DBRecordInsert" https://infosys.beckhoff.com/content/1033/ tcdbserver/Resources/11407906187/.zip In this example the log of several values into a database out of a PLC with the function block FB_DBRecordInsert will be shown. Especially in this example several PLC variables will be logged in one data set. Furthermore a data set can be read out of the database with the function block FB_DBRecordSelect. TS6420 112 Version: 1.2