eipWriteAttr

PLCopen motion icon

 Function Block - Sends an explicit message (UCMM) to an EtherNet/IP adapter to write a single CIP attribute.

Inputs

Input

Data Type

Range

Unit

Default

Description

Snd

BOOL

FALSE, TRUE

N/A

No default

A rising edge on this input starts the exchange.

The DONE output signals the end of exchange.

SrvIP

STRING

No range

N/A

No default

IP address of the server (adapter) (e.g., configured in the EtherNet/IP Scanner configuration).

Class

UINT

No range

N/A

No default

Class identifier of the CIP object.

Inst

UINT

1 to 65535

N/A

No default

Instance identifier of the CIP object.

Attr

UINT

No range

N/A

No default

Identifier of the CIP attribute.

Size

UINT

1 to 450

N/A

No default

Number of bytes to write.

Cannot exceed 450 bytes.

Data

USINT[ ]

Dimension: The number of bytes to write.

Data: No range

N/A

No default

Buffer containing the data to write.

Outputs

Output

Data Type

Range

Unit

Description

Done

BOOL

FALSE, TRUE

N/A

This output is TRUE during one cycle when the exchange is finished, whether the exchange succeeded or failed.

Warning: This output can be TRUE just after the call to block when starting a new exchange in case of invalid parameters.

Err

UINT

No range

N/A

Main error report.

Can be one of these values:
0 = No error.
1 = Invalid input arguments.
2 = System is busy (see remarks).
3 = Timeout waiting for the answer (the timeout value is 3 seconds).
4 = UCMM error was returned by the server others = internal errors (reserved for technical support).

EmErr

UINT

No range

N/A

In case of a UCMM error, this is the CIP general status error code.

EmErrExt

UINT

No range

N/A

In case of a UCMM error, this is the CIP extended status error code.

Remarks

  • The servers (adapters) accessed by this block must be configured in the EtherNet/IP Scanner fieldbus configuration.
  • Only one explicit message (read or write) can be sent at one time to the same server.
    • If another message is pending you receive the error report 3 (busy) after calling the block to start a new exchange.
  • Consider SerializeIn and SerializeOut functions for extracting data from the read buffer.

FBD Language Example

Not available.

FFLD Language Example

Not available.

IL Language Example

Not available.

ST Language Example

// used variables
// Inst_eipWriteAttr : eipWriteAttr ;
// bWrite : BOOL ; (* request for WRITE *)
// DataWrite : ARRAY [0 .. 15] OF USINT; (* written data *)
// uiSizeWrite : UINT := UINT#16 ; (* number of bytes to read *)
// Server identification and CIP things

#define SRVIP '192.168.33.21'
#define CLASSID UINT#100
#define INSTID_WRITE UINT#2
#define ATTRID UINT#3
/////////////////////////////////////////////////////////////////////////////////////////
// requested WRITE command

if bWrite then
Inst_eipWriteAttr (bWrite, SRVIP, CLASSID, INSTID_WRITE, ATTRID,
uiSizeWrite, DataWrite);
end_if;
// WRITE answer here ?
if Inst_eipWriteAttr.Done then
// check answer
if Inst_eipWriteAttr.Err = 0 then
printf ('WRITE ok');
else
printf ('WRITE Error %lu - (UCMM Error %lu, %lu)',
any_to_dint (Inst_eipWriteAttr.Err),
any_to_dint (Inst_eipWriteAttr.EmErr),
any_to_dint (Inst_eipWriteAttr.EmErrExt));
end_if;
// reset WRITE command and block input
Inst_eipWriteAttr (false, SRVIP, CLASSID, INSTID_WRITE, ATTRID,
uiSizeWrite, DataWrite);
bWrite := false;
end_if;

See Also