1 sdo transfer via function block „canopensendsdo – Lenze PLC Designer PLC Designer (R2-x) CANopen for Runtime Systems User Manual

Page 21

Advertising
background image

L-force | PLC Designer - CANopen for Runtime Systems

CANopen-Master library

20

DMS 2.0 EN 05/2009 TD29

2.4.4 Examples for application-controlled actions of the libraries

In the following some standard actions are described, which often have to be done by applications.

2.4.4.1 SDO Transfer via function block „CanOpenSendSDO“
In order to control the initiation of a SDO transfer by the application, use module CanOpenSendSDO
of the CanOpenManager library.

Interface of the module:

VAR_INPUT

Enable : BOOL;

(* Rising edge at this flag starts SDO transfer.*)

wDrvNr : WORD;

(* Index of the CAN controller to be used for the SDO transfer. 0 for the

first one, etc.*)

ucNodeId : BYTE;

(* NodeId of the SDO server (receiver of the SDO).*)

wIndex : WORD;

(* Index of the object dictionary entry.*)

bySubIndex : BYTE; (* SubIndex*)

ucModus: BYTE; (* SDO-mode, 16#40 for read-request,

use 16#23 for 4-byte-write-request.
use 16#27 for 3-byte...
use 16#2B for 2-byte...
use 16#2F for 1-byte...
use 16#21 for a download with more than 4 Bytes.*)

ucByte0 : BYTE;

(* The 4 possible data bytes in the expedited transfer. *)

ucByte1 : BYTE;

ucByte2 : BYTE;

ucByte3 : BYTE;

aAbortCode : ARRAY[0..3] OF BYTE;


(* Additional input parameters in case of a segmented transfer. *)

(* For modes 16#41 and 16#40 for segmented reading and 16#21 for segmented writing. In
these cases a buffer must be defined for the data.*)

dwDataBufferLength : DWORD;

pDataBuffer : POINTER TO BYTE;

END_VAR

VAR_OUTPUT

bWaitForAnswer : BOOL; (* During transmission this flag is set TRUE at least for the

duration of one cycle and after the transmission it is set FALSE.*)

bAnswerRec : BOOL;

(* Only in case of an error-free transmission this flag is set TRUE.*)

ucAnswerBytes : ARRAY[0..7] OF BYTE;

iAnswerLength : INT;

bToggleUnequal:

BOOL;

bAbortRec:BOOL;

(* If an there was an abort, this variable will be set TRUE; the abort

code appears in aAbortRec.*)

aAbortRec : ARRAY[0..3] OF BYTE;

END_VAR

VAR

EnableOld : BOOL;

bAnswer : BOOL;

n:

INT;

dwActiveCOBId : DWORD;

dwAnswerId : DWORD;
Buffer : CAN_Message;
bExpedited : BOOL;

(* Here the module shows whether the reading has been

done via an expedited or a segmented transfer.*)

bWriteActive : BOOL;

bReadActive : BOOL;

Advertising