Function BlockECATWriteSDOPLCopen motion iconPipe Network motion icon

Description

This function block writes a 32-bit word to I/O nodes using a CANopen SDO write command.

See EtherCAT Library - SDO for some stats about the execution time .

ECATWriteSdo.png

Figure 7-184: ECATWriteSdo

Manufacturer specific SDOs, CANopen Object Dictionary

State Diagram

ECATWriteSdo State diagram

Figure 7-185: ECATWriteSdo State Diagram

Arguments

Input

Execute Description On the rising edgeClosedA rising edge is the transition of a digital signal from low to high. It is also called positive edge of Execute, an SDO write command will be issued. The function block will only handle one SDO command at a time. If Execute is toggled quickly so that another rising edge occurs before the SDO command has completed, the function block will not issue a second SDO command.
  Data type BOOL
  Range 0, 1
  Unit n/a
  Default
Index Description

The object directory index of the data to be written to.

For more details, refer to:

  • Communication SDOs
  • Manufacturer specific SDOs
  • Profile specific SDOs

To read/write an SDO object with an index greater than 16#7FFF (32767), the value must be entered in the form any_to_int(index # in hex format). For example any_to_int(16#8321).

  Data type INT
  Range
  Unit n/a
  Default
Subindex Description

The sub-index of the object directory variable to be written to.

For more details, refer to:

  • Communication SDOs
  • Manufacturer specific SDOs
  • Profile specific SDOs

To read/write an SDO object with an index greater than 16#7FFF (32767), the value must be entered in the form any_to_int(index # in hex format). For example any_to_int(16#8321).

  Data type SINT
  Range
  Unit n/a
  Default
Size Description The size (number of bytes) to write.
  Data type SINT
  Range 1 - 4
  Unit n/a
  Default
SlaveAddress Description

The EtherCAT address of the slave from which data will be written to.

The first node usually has the value '1001'. The second node usually has the value '1002'.

Alternately, you can use the members of the EtherCAT structure to specify a drive's address when you create the variable.


creating an EtherCAT variable

  Data type INT
  Range
  Unit n/a
  Default
Value Description The value to write to the object directory variable.
  Data type DINT
  Range [-2147483648, 2147483648]
  Unit n/a
  Default

Output

Done Description Indicates whether the SDO call has completed without error.
  Data type BOOL
  Unit n/a
Error Description Indicates whether the SDO call has completed with error:
  Data type BOOL
  Unit n/a
ErrorID Description The SDO call error result, if Error is TRUE (see list of Error Codes in table below). Upon success, Error is set to zero.
  Data type DINT
  Unit n/a
Error Code Value, dec (hex) Description
ECERR_OK 0 The SDO call succeeded
ECERR_DEVICE_INVALIDINDEX 1795 (0x703) An invalid value for the Index input was specified
ECERR_DEVICE_INVALIDACCESS 1796 (0x704) Reading of the variable is not permitted
ECERR_DEVICE_INVALIDSIZE 1797 (0x705) An invalid size for the parameter was specified
ECERR_DEVICE_INVALIDDATA 1798 (0x706) Invalid parameter value(s) in SDO index and/or sub-index
ECERR_DEVICE_NOTREADY 1799 (0x707) device is not in a ready state, network is not in operational
ECERR_DEVICE_NOTFOUND 1804 (0x70C) EtherCAT device not found
ECERR_DEVICE_SYNTAX 1805 (0x70D) An unexpected error occurred
ECERR_DEVICE_INVALIDSTATE 1810 (0x712) The EtherCAT device is in an invalid state
ECERR_DEVICE_TIMEOUT 1817 (0x719) The EtherCAT device failed to respond, timing out
ECERR_DEVICE_INSERTMAILBOX 1826 (0x722) Error while inserting the mailbox command into internal FIFO
ECERR_DEVICE_INVALIDOFFSET 1827 (0x723) An invalid value for the SubIndex input was specified
ECERR_DEVICE_UNKNOWNMAILBOXCMD 1828 (0x724) The master sent an unknown mailbox command to the slave
ECERR_DEVICE_INVALIDADDR 1832 (0x728) Can’t send a mailbox command to the specified slave
ECERR_DEVICE_PARAM_ACCESS_ERROR 1920 (0x780) Unknown error occurred while accessing parameter
ECERR_DEVICE_PARAM_NOT_FOUND 1921 (0x781) Parameter was not found
ECERR_DEVICE_PARAM_NOT_INTEGER 1922 (0x782) Parameter is a floating-point value. Integer value required.
ECERR_DEVICE_VALUE_IS_NEGATIVE 1923 (0x783) No negative values allowed. Value specified was negative.
ECERR_DEVICE_VALUE_OUT_OF_RANGE 1924 (0x784) Value is out of data-range
ECERR_DEVICE_VALUE_GREATER_THAN_MAX 1925 (0x785) Value bigger than maximum
ECERR_DEVICE_VALUE_LOWER_THAN_MIN 1926 (0x786) Value lower than minimum
ECERR_CLIENT_ERROR 2048 (0x800) Error in Mailbox response to a previously sent mailbox command
ECERR_CLIENT_TIMEOUT 2049 (0x801) The SDO command timed out
ECERR_CLIENT_ INVALIDPARM 2050 (0x802) An invalid value was specified
ECERR_CLIENT_ INVALIDSIZE 2051 (0x803) An invalid value for the size input was specified

Table 7-48: List of EtherCAT Error Codes

Related Functions

ECATReadSDO

Example

Structured Text

      (* Write 58.000 to PL.KP of first AKD D
      rive on Ethe
      rCAT network *)
Inst_ECATWriteSdo( TRUE, 16#3542, 0, 4, 1001, 58000 );

 

      (* Write a value of 246 to the 4 byte data in SDO index 8321h (33569 decimal), sub-index 1 on the first AKD Drive *)
Inst_ECATWriteSdo( TRUE, any_to_int(16#8321), 1, 4, 1001, 246 );

FBD

FFLD

See also the FAQ to set the update rate for SDO communication.

Go back to the top of the page [Top]