Supported platforms: CODESYS 3.5 SAFETY, CODESYS 3.5
Required:
|
Limitations:
|
The following example describes a time triggered CAN message (COB-ID 100h) that is triggered with 10 ms interval.
CAN bus init is not required if MultiTool Creator code template is used.
Definitions: |
|
canChannel:EPEC_CANL2.Channel; (*not required with MT code template*) timeTrgSending:EPEC_HWD.CanApiTimeTriggeredMsg; |
Init: |
|
(*If using MultiTool, CAN channel init is already included in code template*) canChannel.InitCAN(0,250,0); (* Init channel 0 for 250 kbit/s*)
timeTrgSending.i_Enable := FALSE; timeTrgSending.i_Dlc := 8; timeTrgSending.InitCobId(0,16#100,T#10MS); (* Init message, COB-ID 100h, 10ms interval *) |
|
|
|
|
Code: |
|
(*Update message data*) timeTrgSending.i_Data[0] : = 1; timeTrgSending.i_Data[1] : = 2; timeTrgSending.i_Data[2] : = 3; timeTrgSending.i_Data[3] : = 4; timeTrgSending.i_Data[4] : = 5; timeTrgSending.i_Data[5] : = 6; timeTrgSending.i_Data[6] : = 7; timeTrgSending.i_Data[7] : = 8; (*Update data for message handler*) timeTrgSending.UpdateData(); (*Call handler periodically*) timeTrgSending(i_Enable := TRUE);
|
Source file topic100365.htm
Last updated 19-Dec-2024