Example: Writing parameters

Parameters can be written using the WRITE SDO service. For this purpose, the index and subindex of the parameter to be written are required.

The SDO service is described in detail in an example. In the example, the service is carried out in an EtherCAT® master from Beckhoff Automation GmbH in the TwinCAT 3 engineering tool.

Proceed as follows:

  • You have integrated the required libraries and function blocks of the service for the EtherCAT® master in the TwinCAT project (see SDO services READ and WRITE).
  1. Open the MOVISUITE® engineering software and search for the parameter.
  2. Move the mouse pointer over the edit box or display field of the parameter and note the index of the parameter from the tooltip. The subindex is separated from the index number by a dot.
  3. Create an instance of the FB_EcCoeSdoWrite function block.
  4. Assign the inputs of the function block:

Input

Value

sNetID

Net ID of the EtherCAT® master.

nSlaveAddr

EtherCAT® address of the device to which data is to be written.

nIndex

Index of the parameter that is to be written.

When using a double-axis module, the index of the second axis is assigned with an offset of 0x1000 (4096 dec).

nSubIndex

Subindex of the parameter that is to be written.

pDstBuf

Pointer to the data range in which the values are located that are to be written.

cbBufLen

Maximum memory size in bytes occupied by the parameter to be written.

For inverters of the MOVI-C® modular automation system, the maximum parameter memory size is always 4 bytes.

bExecute

Positive edge that starts the write operation.

tTimeout

Timeout time of the function block.

  1. Scale the value to be written according to the parameter.
  2. To start the process, the bExecute input must detect a "Rising Edge" (positive edge).
    • In this example, the voltage limit has been written with a new value. The value was scaled with 1000 before running the service.
    • The bBusy and bError outputs signal the status of the service. If an error occurs when running the service and you have set the bError output, the nErrId output shows the error number.