DBconfig

The RK512 function block has two operating modes. In passive mode it receives data and request telegrams from a communication partner who is addressing data blocks by means of its data block number. Numbered data blocks are not known to IEC-1131, and therefore initially also not to TwinCAT. In TwinCAT, data blocks are variables of various types such as arrays or data structures (STRUCT).

In order to define a numbered data block, the method DBconfig belonging to the RK512 function block as called with all the necessary parameters during the initialisation phase. The method is called once for each data block that is to be addressed by communication partners. This configuration is not needed for the active operating mode (send and fetch).

In the active operating mode variable contents can be sent to or fetched from communication partners, independently of this data block configuration. In active mode the data block number refers to the partner device, and only needs to be known there.

Parameters

DbAdr

DbAdr is the memory address of a PLC variable that is to be defined as a data block. The address is determined using the ADR function.

e.g.: DbAdr := ADR( PLCvar );

The PLC variable can be of any type. An ARRAY OF WORD, for example, or a STRUCT data structure would be suitable.

DbSize

DbSize is the size of the PLC variable at DbAdr in bytes, determined by the SIZEOF function.

e.g.: DbSize := SIZEOF( PLCvar );

RemoteDbNr

RemoteDbNr contains the number of the data block at the communication partner.

TxBuffer

The transmit data buffer TxBuffer is of type COMbuffer. This parameter is not needed by the configuration, but must however be passed as an IN_OUT parameter.

RxBuffer

The receive data buffer RxBuffer is of type COMbuffer. This parameter is not needed by the configuration but must however be passed as an IN_OUT parameter.

Example

VAR
(* declare some DB
(* the type of data doen't matter but the 
(* size shouldn't be larger than 128 bytes
(**)
    DB1 : ARRAY[1..64] OF WORD; (* exemplary type of db *)
    DB5 : ARRAY[1..64] OF WORD; (* exemplary type of db *)
    DB10 : ARRAY[1..64] OF WORD; (* exemplary type of db *)

(* input and ouput data for the RK512 function block *)
RK512com : RK512; 

    initialized : BOOL;
END_VAR

IF NOT initialized THEN
    RK512com.DBconfig( RemoteDbNr:=5, DbAdr:=ADR(DB5), DbSize:=SIZEOF(DB5), TxBuffer:=TxBuffer, RxBuffer:=RxBuffer );
    RK512com.DBconfig( RemoteDbNr:=10, DbAdr:=ADR(DB10), DbSize:=SIZEOF(DB10), TxBuffer:=TxBuffer, RxBuffer:=RxBuffer );
    initialized := TRUE;
END_IF

The initialization in this example has the effect that the communication partner may read or write data blocks 5 and 10. Any attempt to access another data block is considered as an error and is refused.