Lenze PLC Designer PLC Designer (R2-x) CANopen for Runtime Systems User Manual

Page 23

Advertising
background image

L-force | PLC Designer - CANopen for Runtime Systems

CANopen-Master library

22

DMS 2.0 EN 05/2009 TD29

Receive SDO:

Like Sending SDO, except that 4 x 0 data Bytes are passed and mode 16#40.

Each other input value for „Mode“ will lead to an undefined behaviour of the module.

Thus the call of the module e.g. could look as follows:

sdo(
Enable:=

TRUE,

wDrvNr:=

0,

ucNodeId:=

2,

wIndex:=

16#4001,

bySubIndex:=

0,

ucModus:=

16#40,

aAbortCode:=aAbort);

IF sdo.bAnswerRec AND NOT sdo.bAbortRec THEN

dwRead

:=

SHL(BYTE_TO_DWORD(sdo.ucAnswerBytes[7]),24);

dwRead := dwRead + SHL(BYTE_TO_DWORD(sdo.ucAnswerBytes[6]),16);

dwRead := dwRead + SHL(BYTE_TO_DWORD(sdo.ucAnswerBytes[5]),8);

dwRead := dwRead + BYTE_TO_DWORD(sdo.ucAnswerBytes[4]);

END_IF

It is proceeded on the assumption that in index 4001, Sub0 there is a 4-byte value which always can
be read with an “expedited” transfer.

If it is unknown whether the value is transmitted by the SDO server via expedited transfer or not,
always a data buffer must be defined. In this case, after the transfer has been done, it can be
determined via the flag bExpedited whether the data will appear in ucAnswerBytes[4..7] or in the
buffer.

The input parameter aAbortCode serves to inform the module about the abort code which should be
sent in case the communication is aborted by the application per deleting the enable input. (Always
when a rising edge is detected at the Enable input of the module during a running transfer, an abort
will be generated.)

The module itself does not watch timeouts. Thus the application must watch the SDO transfer and e.g.
via call

Sdo(Enable := FALSE, aAbortCode[0]:=0,aAbortCode[1] := 0,aAbortCode[2] := 4,aAbortCode[3] :=
5);

must pass the abort code „SDO Protocol timed out“. This will be sent at a falling edge at Enable if the
protocol has not yet finished the transfer.

If more than 4 bytes should be read, the address of a buffer and a maximum size of this buffer can be
passed to the module:

sdo(
Enable:=

bReadString,

wDrvNr:=

0,

ucNodeId:=

2,

wIndex:=

16#4000,

bySubIndex:=

2,

ucModus:=

16#40,

aAbortCode:=aAbort,

dwDataBufferLength:= SIZEOF(str) ,

pDataBuffer:=

ADR(str));


In this example str is a string. The size of this string within the memory can be determined by means
of the SIZEOF operator. The corresponding number of characters will be maximum transferred by the
module. The actually read number of bytes appears after the transfer in dwDataOffset.

Advertising