Set the CAN communication timing.
Ret = CanSetCanTiming ( Id , ChannelNo , Bitrate , TSeg1 , SJW , TSeg2 )
Id
[ C: short ] [ Python: ctypes.c_short ]
Specify the device ID retrieved from CanInit.
ChannelNo
[ C: unsigned short ] [ Python: ctypes.c_ushort ]
Specify the channel number.
Bitrate
[ C: unsigned int ] [ Python: ctypes.c_uint ]
Specify the bitrate.The unit is bps.(bit per second)
The specified range varies depending on the device.
For details, please refer to the Specifications based on devices section.
TSeg1 [
C: unsigned short ] [ Python: ctypes.c_ushort ]
Specify the time segment 1.
For details, please refer to the Specifications based on devices section.
SJW [
C: unsigned short ] [ Python: ctypes.c_ushort ]
Specify the SJW. (Synchronization Jump Width)
For details, please refer to the Specifications based on devices section.
TSeg2 [
C: unsigned short ] [ Python: ctypes.c_ushort ]
Specify the time segment 2.
For details, please refer to the Specifications based on devices section.
Ret [ C: long ] [ Python: ctypes.c_long ]
Definition |
Value |
Description |
CAN_ERR_SUCCESS |
0 |
Normality completion |
CAN_ERR_DLL_INVALID_ID |
10001 |
Invalid ID specified. |
CAN_ERR_DLL_CALL_DRIVER |
10002 |
Driver can't be called (Failed in the ioctl). |
CAN_ERR_SYS_CH_NO |
20101 |
Channel number is outside the settable range. |
CAN_ERR_SYS_BITRATE |
20110 |
The bit rate is outside the settable range. |
CAN_ERR_SYS_TSEG1 |
20120 |
Time segment 1 is outside the settable range. |
CAN_ERR_SYS_SJW |
20121 |
Synchronization Jump Width is outside the settable range. |
CAN_ERR_SYS_TSEG2 |
20122 |
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 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 Bitrate, TSeg1, TSeg2, SJW that can be set on the device, and if it is not possible to set it, it will be corrected to a similar value.
Use CanGetCanTiming 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.
Model |
Arguments |
Content |
CAN-4P-PE |
Bitrate |
The setting range is 60000 to 1000000. The unit is bps. (bit per second) |
TSeg1 |
The setting range is 2 to 513. The unit is TQ. |
|
SJW |
The setting range is 1 to 127. Also, please set it equal to or less than time segment 2 (TSeg2). The unit is TQ. |
|
TSeg2 |
The setting range is 1 to 128. Also, please set it equal to or less than time segment 1 (TSeg1). The unit is TQ. |
|
CAN-2-USB |
Bitrate |
The setting range is 5000 to 1000000. The unit is bps. (bit per second) |
TSeg1 |
The setting range is 2 to 16. The unit is TQ. |
|
SJW |
The setting range is 1 to 4. Also, please set it equal to or less than time segment 2 (TSeg2). The unit is TQ. |
|
TSeg2 |
The setting range is 1 to 8. Also, please set it equal to or less than time segment 1 (TSeg1). The unit is TQ. |
Set Bitrate = 1000000 bps, TSeg1 = 100TQ, SJW = 60TQ, TSeg2 = 60TQ to ChannelNo = 1.
C |
long Ret; |
Python |
Ret = ctypes.c_long() |