Configurable sample point for fdcanusb/mjcanfd-usb-1x
CAN-FD communication has a number of configurable parameters in order to specify how long each bit period lasts, what amount of clock skew is permissible, and when to sample the physical layer to clock in each bit. For many CAN 2.0 applications, only the bitrate is configured and the sample point and skew parameters are left to a default. Optimizing them may be necessary if you want to control timing margins over a CAN bus with many hosts. Doing so is often not necessary though, as for CAN 2.0 different hosts can have different sample points and largely still interoperate.
However, for CAN-FD networks the story is different. There, the specification is such that all hosts on the network do need to have a closely matching sample point in order to function with bit rate switching. For moteus, this hasn’t been too much of a problem as the sample point is hard-coded to the same value that the fdcanusb, mjcanfd-usb-1x, and pi3hat are hard-coded to. Most other adapters do allow configuring the sample point (although slcan and canable derived boards do not, which is why they cannot currently be used with moteus).
There are some instances where it makes sense to use a fdcanusb or mjcanfd-usb-1x as a host on a CAN network with exclusively non-moteus devices. To date, that was not possible unless the devices used a sample point that happened to coincide with the 66% that all moteus devices were hard-coded to.
Now, with that background out of the way, we can get to the point of
this post! As of fdcanusb release
2025-07-21,
both fdcanusb and mjcanfd-usb-1x devices can configure the sample
point, using the can.sample_point
and can.fd_sample_point
parameters. Very few people will need this, but if you do, you will
find it pretty helpful!