Navigation:  Equipments (Devices) > SCA06 > Ladder > Communication Network > CANopen >

CO_SDOWrite

Previous pageReturn to chapter overviewNext page

Block that performs a writing of data via SDO from a remote slave in CANopen network.

 

Ladder Representation

 

CO_SDOWRITE_block

 

Block Structure

 

Variable Type

Name

Data Type

Description

VAR_INPUT

Execute

BOOL

Block enabling

NodeID#

BYTE

Slave address

Index#

WORD

Index of the object to be accessed in slave

SubIndex#

BYTE

Sub-index of the object

Size#

BYTE

Size of data accessed, in bytes

Timeout#

WORD

Maximum waiting time for arrival of data, from the beginning of the request [ms]

Value

BYTE USINT

Variable that has the data to be written

VAR_OUTPUT

Done

BOOL

Output enabling

Active

BOOL

Awaiting response flag

Busy

BOOL

Flag of the SDO client is busy with another request

Error

BOOL

Error in the execution flag

ErrorID

BYTE USINT

Identifier of the occurred error

VAR

CO_SDOWRITE_INST_0

CO_SDOWRITE

Instance of access to block structure

 

Operation

 

When this block detects a leading edge on Execute it checks whether the SDO client in the specified NodeID # address is free to send data (Busy variable at FALSE level). If so, it sends the writing request to the object of Size# size located in Index# and SubIndex# and sets the Active output, resetting it when receiving the response from the slave. If the slave is not free, the block waits Busy go to FALSE level to resubmit the request.

 

wpshelp_common_fig_note

NOTE!

If Execute goes to FALSE level and Busy is still at TRUE level, the request is canceled.

 

wpshelp_common_fig_note

NOTE!

Value is an array of size equal to Size#. It is important to check this compatibility not to generate errors in the block.

 

wpshelp_common_fig_note

NOTE!

It is only possible to read one object (BYTE, WORD, DWORD) per block. It is not possible to read an array of objects.

 

When Execute has FALSE value, Done remains FALSE. The Done output is only activated when the block finishes executing successfully, remaining at TRUE level until Execute receives FALSE.

 

If there is any error in the execution, the Error output is enabled and ErrorID displays an error code according to the table below.

 

Code

Description

0

Executed successfully

1

Card cannot execute the function

2

Timeout in slave response

3

Slave returned error

 

Block Flowchart

 

CO_SDOWRITE_flowchart

 

Example in Ladder

 

CO_SDOWRITE_example01

 

The example above requests writing of the data size VALUE, located in INDEX - SUBINDEX, of the NODEID device. The block ends successfully, Done output is activated.

 

Example in ST

 

 The example below displays the instructions for applying the example above in the ST language.

 

 

VAR

   ERROR : BOOL;

   INDEX, TIMEOUT : WORD;

   NODEID, SUBINDEX : BYTE;

   VALUE : UDINT;

   CO_SDOWRITE_INST_0 : FB_CO_SDOWrite;

END_VAR

 

CO_SDOWRITE_INST_0.Execute := DI1;

CO_SDOWRITE_INST_0(

NodeId:=NODEID,

   Index:=INDEX,

   SubIndex:=SUBINDEX,

   Size:=4,

   Timeout:=TIMEOUT,

   Value:=VALUE);

ERROR := CO_SDOWRITE_INST_0.Error;

DO1 := CO_SDOWRITE_INST_0.Done;