FB_CUSTOM_SERVICE

FB_CUSTOM_SERVICE 1:

You can create almost any CIP service using the FB_CUSTOM_SERVICE function block.

FB_CUSTOM_SERVICE 2: Inputs

VAR_INPUT
    sNetId               : T_AmsNetID;
    sIPv4Addr            : T_IPv4Addr;
    bExecute             : BOOL;
    nServiceCode         : BYTE;
    nClass               : WORD;
    nInstance            : WORD;
    nAttribute           : WORD;
    pDst                 : POINTER TO BYTE;
    nMaxLen              : WORD;
    pSrc                 : POINTER TO BYTE;
    nSrcDataLen          : WORD;
    nSessionTimeoutMSec  : DWORD;
    nCmdTimeoutMSec      : DWORD;
    bRackComm            : BOOL;
    nPort                : BYTE;
    nSlot                : BYTE;
END_VAR

Name

Type

Description

sNetId

T_AmsNetID

AMSNetId of the TwinCAT EtherNet/IP™ scanner via which the command is to run

sIPv4Addr

T_IPv4Addr

IP address of the target CPU.

bExecute

BOOL

A positive edge starts the command.

nServiceCode

BYTE

Service code of the CIP service.

nClasss

WORD

Class number of the CIP service.

nInstance

WORD

Instance number of the CIP service.

nAttribute

WORD

Attribute number of CIP service.

pDst

POINTER TO BYTE

Pointer to the variable into which the value is to be copied (get the pointer with ADR).

nMaxLen

WORD

Size of the variable to which the pointer pDst points (get with SizeOf).

pSrc

POINTER TO BYTE

Pointer to the variable containing the value for sending the service (get the pointer with ADR).

nSrcDataLen

WORD

Size of the variable to which the pointer pSrc points (get with SizeOf), or number of bytes to be sent. This is usually the size of the variable.

nSessionTimeoutMSec

DWORD

Timeout for the session; the default is 30 seconds.

nCmdTimeoutMSec

DWORD

Timeout for the command; the default is 7.5 seconds.

bRackComm

BOOL

TRUE if the CPU is modular, i.e. a CPU with a rack design, for example a CompactLogix.

nPort

BYTE

Port number of the CPU (the TF6281 currently only supports port 1).

nSlot

BYTE

Slot number if the CPU is not plugged into slot 0.

FB_CUSTOM_SERVICE 3: Outputs

VAR_OUTPUT
    bBusy     : BOOL;
    bError    : BOOL;
    nErrId    : UDINT;
    nDataLen  : WORD;
END_VAR

Name

Type

Description

bBusy

BOOL

When the function block is enabled, this output is set and remains set until a feedback is received. While Busy = TRUE, no new command will be accepted at the inputs.

bError

BOOL

If an error occurs during the transfer of the command, then this output is set once the bBusy output was reset.

nErrId

UDINT

If an bError output is set, this parameter supplies an error number.

nDataLen

WORD

Returns the number of valid data (number of bytes).