Supported platforms: CODESYS 3.5

 

Sending Time Triggered CAN message

 

Required:

 

 

Limitations:

  • Maximum number of the send messages is 10

  • Accuracy of the time is +-2 ms

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

  • Used CAN channel must be initalized before initializating the time triggered messages.

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

 

 

 

The following example describes a time triggered CAN message that is triggered with 10 ms interval.

Example code

Definitions:

 

canChannel:EPEC_CANL2.Channel; (*not required with MT code template*)

timeTrgSending:EPEC_5050INT.CanApiTimeTriggeredMsg;

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

 

 

Init:

 

(*If using MultiTool Creator, CAN channel init is already included in code template*)

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

 

timeTrgSending.InitCobId(0,16#100,T#10MS); (* Init sending 10ms interval , COB-ID 100h *)

 

 

Code:

 

timeTrgSending(i_Enable := TRUE, i_Dlc := 8, i_Data := sendData); (* Enable sending and update data *)

 

 

See also

 

 

Source file topic000991.htm

Last updated 21-Feb-2025