FB_GetDPRAMInfoEx 1:

The FB_GetDPRAMInfo function block determines the address pointer and the configured size of the NOV/DP-RAM of a fieldbus card. The address pointer can be used, for example, for direct write or read access of the NOV-RAM of the Fcxxx-0002 (Beckhoff) cards or the DPRAM of cards that are not supported by TwinCAT (third-party manufacturers). First, the card has to be configured as general NOV/DP-RAM within the TwinCAT system.

Along with the address (pCardAddress) and the size (iCardMemSize) of the NOV/DP-RAM the stInfo output also returns the type of access (eAccessType).

If the NOV/DP-RAM does not require special access (BYTE or WORD aligned), the MEMCPY, MEMSET or MEMCMP functions can be used in the PLC program to be able to have read/write access to a random memory offset. If the NOV/DP-RAM requires special access (BYTE or WORD aligned), then access is only possible with the appropriate data size. For this purpose use FB_NovRamReadWriteEx.


    nDevId      :    UDINT; (*Device id of the FCxxxx or other DPRAM card (Map the FC card as generic DPRAM/NOVRAM card im System Manager first)*)
    bExecute    :    BOOL; (*Rising edge starts function block execution*)
    tTimeOut    :    TIME; (*Max. timeout for this command*)

nDevId: The device ID of a NOV/DP-RAM card. The ID is used to specify the card from which information is to be read. The device IDs are specified by the TwinCAT system during the hardware configuration.

bExecute: The function block is activated via a rising edge at this input.

tTimeOut: States the length of the timeout that may not be exceeded during execution of the command/function.

    bBusy     :    BOOL;
    bError    :    BOOL;
    nErrid    :    UDINT;
    stInfo    :    ST_NovRamAddrInfoEx;

bBusy: This output is set when the function block is activated, and remains set until execution of the function has been completed.

bError: This output is set if an error occurs during the execution.

nErrId: Supplies the ADS error number when the bError output is set.

stInfo: A structure containing the address and size of the NOV/DP-RAM (type: ST_NovRamAddrInfoEx).



In MAIN a pointer to a BYTE is declared. This pointer is initialized with the address of the NOV/DP-RAM at the start of the program. Referencing the pointer makes read/write access to the NOV/DP-RAM possible.

    nDevId       : UDINT := 1; //device 1, see ID of NOV/DP-RAM device
    cbNOVRAM     : DWORD;
    fbGetInfo    : FB_GetDPRAMInfoEx;
    bInit        : BOOL := FALSE;
    eAccessType  : E_IOACCESSTYPE;
    bByteAccess  : BOOL;
    bWordAccess  : BOOL;
    bDWordAccess : BOOL;

        nDevId   := nDevId,
        bExecute := TRUE,
        tTimeOut := T#5S

    IF NOT fbGetInfo.bBusy THEN
        IF NOT fbGetInfo.bError THEN
            pNOVRAM     := fbGetInfo.stInfo.pCardAddress;
            cbNOVRAM    := fbGetInfo.stInfo.iCardMemSize;
            eAccessType := fbGetInfo.stInfo.eAccessType;

            bDWordAccess := FALSE;
            bByteAccess  := FALSE;
            bWordAccess  := FALSE;

            CASE eAccessType OF
                    bDWordAccess := TRUE;
                    //access via MEMCPY,  MEMSET,  MEMCMP possible
                    bByteAccess := TRUE;
                    //access via POINTER to BYTE possible
                    bWordAccess := TRUE;
                    //access via POINTER to WORD +
                    //swapping of high and low byte possible

            bInit := TRUE;
        fbGetInfo(bExecute := FALSE);


Development environment

Target platform

IO Hardware

PLC libraries to be integrated (category group)

TwinCAT v3.1.0

PC or CX (x86)

FCxxxx cards with NOVRAM (FCxxxx-0002)

Tc2_IoFunctions (IO)