Plc programming – Lenze ETC Motion Control User Manual

Page 413

Advertising
background image

PLC programming

Library

CAN functions (only ETCxM)

8

8.8

8.8.6

l

413

EDSTCXN EN 2.0

handle_pr

: DINT;

received_bit

: BOOL;

msg_st

: CAN_MSG_TR;

handle_pr = DefineCanMsg(1, 1014, 1114, 32);

handle_pr = DefineCanMsg(1, 1014, 1114, 32);

8.8.6.7

WriteCanMsg (only ETCxM)

FUNCTION WriteCanMsg: INT

VAR_INPUT

handle_pr

: DINT;

(* Handle on the management structure *)

dest_pr

: DINT;

(* Address to the data structure *)

END_VAR

This function allows for a CAN message to be written into the send buffer.
The send buffer is implemented as FIFO. The data structure is as follows:

TYPE CAN_MSG_TR

STRUCT

cobid_w

: WORD;

size_b

: BYTE;

rtr_bit

: BOOL;

data_from

: ARRAY [0..7] OF BYTE;

END_STRUCT

END_TYPE

The variables source_pr must always be given the address of a variable of
type CAN_MSG_TR (see example). This function will provide an immediate
return in any case, even if the FIFO is full. The meaning of the return values
can be found in the following table.

Return value

Meaning

−3

Undefined CobId in data structure

−2

Invalid handle or no memory location available for message

−1

FIFO full

0

Message entered into FIFO

handle_pr

: DINT;

ret_bit

: BOOL;

src_st

: CAN_MSG_TR;

handle_pr = DefineCanMsg(1, 1014, 1114, 32);

src_st.cobid_w := 1014;

src_st.size_b := 1;

src_st.rtr_bit := FALSE;

src_st.data_from[0] := 27;

ret_bit = WriteCanMsg(handle_pr, ADR(src_st));

Example

Declaration

Description

Example

Advertising