Supported platforms: CODESYS 3.5

 

CanApiTimeTriggeredMsg (FB)

 

Function block is used to define time triggered CAN message.

Limitations

  • Maximum number of the send messages is 10.

  • Accuracy of the time is +- 2ms

  • Minimum time interval for sending is 2 ms, but it is recommended to use intervals > 10ms.

  • Used CAN channel must be initialized before initialization of the time triggered messages.

  • Function block instance must be called at least every 100 ms, otherwise message sending is stopped.

  • Function block must be called every 100 ms, otherwise the firmware stops sending of the message. Data can be kept same between calls.

 

 

 

Inputs

Input variable name

Data type

Default Value

Description

i_Enable

BOOL

FALSE

Message is send only if this flag is set TRUE.

i_Dlc

BYTE

0

Set true if AI is used in mA mode

i_Data

BOOL

{0,0,0,0,0,0,0,0}

Flag can be used to disable control of the mode according error state

 

Outputs

Output variable name

Data type

Default Value

Description

o_UsedCanChannel

BYTE

16#FF

Configured channel (= input for method InitCobid)

o_InitializedCobId

COBID

16#FFFFFFFF

Configured COBID (= input for method InitCobid)

o_UsedTimeInterval

TIME

T#0MS

Configured time interval (= input for method InitCobid)

o_Error

EPEC_5000TYPES.SysErrorCodes

FAILURE

Output status

 

 

 

 

Methods

InitCobId

Method is used to init channel, COB-ID and time interval for send message

Before sending is started, the i_Enable flag must be set for the function block.

 

Inputs

Name

Data type

Range

Default value

Description

i_CanChannel

BYTE

-

16#FF

Used CAN channel

i_CobId

DWORD

-

0

Used COBID.

RMT and extended CAN messages can be defined with flags with (OR)

EPEC_CANVXD.MASK_29BIT

EPEC_CANVXD.MASK_REMOTE

 i_TimeInterval

TIME

-

T#0ms

Time interval for sending

 

Outputs

Name

Data type

Range

Default value

Description

o_Error

EPEC_5000TYPES.SysErrorCodes

-

FAILURE

Execution status

 

 

RemoveCobId

Method removes added CobID (method InitCobId) from sending list.

 

Inputs

Name

Data type

Range

Default value

Description

No inputs

 

 

 

 

 

Outputs

Name

Data type

Range

Default value

Description

o_Error

EPEC_5000TYPES.SysErrorCodes

-

FAILURE

Execution status

 

Example code

Definitions:

 

timeTrgSending:CanApiTimeTriggeredMsg;

canChannel:EPEC_CANL2.Channel;

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

 

 

Init:

 

canChannel.InitCAN(0,250,0);                    (* Init channel 0 for 250 kbit/s*)

timeTrgSending.InitCobId(0,16#100,T#10MS);      (* Init send mesages , 10ms interval *)

 

 

Code:

 

timeTrgSending(i_Enable := TRUE, i_Dlc := 8, i_Data := myData);    (* Update data and data length *)

 

 

 

 

See also

 

 

 

Source file topic100345.htm

Last updated 21-Feb-2025