Set the CAN FD communication timing.
Ret = CanSetCanFdTiming ( Id , ChannelNo , ArbBitrate , ArbTSeg1 , ArbSJW , ArbTSeg2 , DataBitrate , DataSeg1 , DataSJW , DataSeg2 )
Id
[ VB.NET: Short ] [ C, C++: short ] [ C#: short ] [ Python: ctypes.c_short
]
Specify the device ID retrieved from CanInit.
ChannelNo
[ VB.NET: UShort ] [ C, C++: unsigned short ] [ C#: ushort ] [
Python: ctypes.c_ushort ]
Specify the channel number.
ArbBitrate
[ VB.NET: UInteger ] [ C, C++: unsigned long ] [ C#: uint ] [ Python:
ctypes.c_uint ]
Specify the arbitration bitrate.
The setting range is 60000 to 1000000. The unit is bps. (bit per second)
ArbTSeg1 [
VB.NET: UShort ] [ C, C++: unsigned short ] [ C#: ushort ] [ Python: ctypes.c_ushort
]
Specify the arbitration time segment 1.
The setting range is 2 to 513. The unit is TQ.
ArbSJW [
VB.NET: UShort ] [ C, C++: unsigned short ] [ C#: ushort ] [ Python: ctypes.c_ushort
]
Specify the arbitration SJW.
The setting range is 1 to 127. Also, please set arbitration time segment
2 (ArbTSeg2) as follows.
The unit is TQ.
ArbTSeg2 [
VB.NET: UShort ] [ C, C++: unsigned short ] [ C#: ushort ] [ Python: ctypes.c_ushort
]
Specify the arbitration time segment 2.
The setting range is 2 to 128. Also, please set arbitration time segment
1 (ArbTSeg1) as follows.
The unit is TQ.
DataBitrate
[ VB.NET: UInteger ] [ C, C++: unsigned long ] [ C#: uint ] [ Python:
ctypes.c_uint ]
Specify the data bitrate.
The setting range is 60000 to 5000000. The unit is bps. (bit per second)
DataTSeg1 [
VB.NET: UShort ] [ C, C++: unsigned short ] [ C#: ushort ] [ Python: ctypes.c_ushort
]
Specify the data time segment 1.
The setting range is 2 to 257. The unit is TQ.
DataSJW [
VB.NET: UShort ] [ C, C++: unsigned short ] [ C#: ushort ] [ Python: ctypes.c_ushort
]
Specify the data SJW. (Synchronization Jump Width)
The setting range is 1 to 127. Also, please set data time segment 2 (DataTSeg2)
as follows.
The unit is TQ.
DataTSeg2 [
VB.NET: UShort ] [ C, C++: unsigned short ] [ C#: ushort ] [ Python: ctypes.c_ushort
]
Specify the data time segment 2.
The setting range is 1 to 128. Also, please set data time segment 1 (DataTSeg1)
as follows.
The unit is TQ.
Ret [ VB.NET: Integer ] [ C, C++: long ] [ C#: int ] [ Python: ctypes.c_long ]
Definition |
Value |
Description |
CAN_ERR_SUCCESS |
0 |
Normality completion |
CAN_ERR_SYS_RECOVERED_FROM_STANDBY |
7 |
Execute CanResetDevice function because the device has recovered from standby mode. |
CAN_ERR_DLL_INVALID_ID |
10001 |
Invalid ID specified. |
CAN_ERR_DLL_CALL_DRIVER |
10002 |
Driver can't be called (Failed in the device I/O control). |
CAN_ERR_SYS_CH_NO |
20101 |
Channel number is outside the settable range |
CAN_ERR_SYS_ARB_TSEG1 |
20131 |
Arbitration time segment 1 is outside the settable range. |
CAN_ERR_SYS_ARB_SJW |
20132 |
Arbitration Synchronization Jump Width is outside the settable range. |
CAN_ERR_SYS_ARB_TSEG2 |
20133 |
Arbitration time segment 2 is outside the settable range. |
CAN_ERR_SYS_DATA_TSEG1 |
20141 |
Data time segment 1 is outside the settable range. |
CAN_ERR_SYS_DATA_SJW |
20142 |
Data Synchronization Jump Width is outside the settable range. |
CAN_ERR_SYS_DATA_TSEG2 |
20143 |
Data time segment 2 is outside the settable range. |
CAN_ERR_SYS_TIMING_COMBINATION |
20144 |
This is a combination in which the communication parameters cannot be set. |
CAN_ERR_SYS_BUSON |
20200 |
Cannot execute because the bus is on. |
The others (See also: Details of Error Code)
None
Set the CAN FD communication timing.
Setting is possible only when the CAN bus is not connected.
It depends on the combination of the CAN
communication clock installed in the device and the prescaler to divide
this clock.
Therefore, there are restrictions on the combinations of arbitration bitrate,
ArbTSeg1, ArbTSeg2, ArbSJW that can be set on the device, and if it is
not possible to set it, it will be corrected to a similar value.
CanGetCanFdTimingUse
the function to ensure that the bitrate and sample point ratio are the
desired values.
It is easy to check using the CAN communication sample program.
For details, please refer to CAN
communication transmission time.
Set ArbBitrate = 1000000 bps, ArbTSeg1 = 100TQ, ArbSJW = 60TQ, ArbTSeg2 = 60TQ, DataBitrate = 1000000 bps, DataTSeg1 = 50TQ, DataSJW = 30TQ, DataTSeg2 = 30TQ to ChannelNo = 1.
VB.NET |
Dim Ret As Integer Ret = CanSetCanFdTiming
( Id , 1 , 1000000 , 100 , 60 , 60 , 1000000 , 50 , 30 , 30 ) |
C, C++ |
long Ret; |
C# |
int Ret; |
Python |
Ret = ctypes.c_long() Ret.value
= ccan.CanSetCanFdTiming ( Id , 1 , 1000000 , 100 , 60
, 60 , 1000000 , 50 , 30 , 30 ) |