Robotell USB-CAN Adapter

I bought a few of the cheap Robotell USB-CAN Adapters fro Aliexpress and finally decided to use them on a project as I needed a low-cost PC-CAN Adapter. Someone will recall I made USB/CAN Adapters some years ago using STM32F105, but I had so much trouble with those that I never used them. I have on the agenda to create a proper isolated one using STM32G431 that can support CAN-FD, but that is for later. The first challenge with the adapter below is to find a driver and doxumentation – once that is done the adapter was straight up working.

Documentation : Robotell CAN-USB interface – python-can 4.2.2 documentation

For test app search for “RobotellCANMonitor”. Myself I don’t care about Python code as I want proper code in C++ or C#. The USB is a serial port in this case that will install directly on most PC’s – it did on mine. The USB is in this case just a means to connect to the PC, so for all practical purposes it is a serial port. I use C# a lot for top-side so it makes sence creating a C# driver. As for top-side tools I need two – one is a test tool using the driver and USB_CAN to communicate “CAN” to the devices, the second is a CAN Analyzer.

My initial test setup is two adapters in loopback as I write/test the C# driver. Writing a CAN Driver we need to start by normalizing the API because we don’t want a different API just because we later change the adapter – the interface we want is CANbus:

  • API to send/receive raw CAN Frames.
  • API to open/close driver on Serial ports.
  • API to set CAN configuration on top-side.

The USB/Serial thing in the middle is just a link, so we want to insert CAN in one end and get the same CAN message in the other. Robotell uses a byte frame as follows:

  • 2 bytes 0xAA as start mark
  • 4 bytes ID
  • 8 bytes data
  • 1 byte DLC
  • 1 byte Message Type (00:CAN. FF:System)
  • 1 byte IDE Flag
  • 1 byte Request flag
  • 1 byte CRC (Simple addition – exclude Frame Control, start and stop marks).
  • 2 byte 0xFF to mark end.

Note that if the array consist of 0xAf, 0xAA or 0xFF another oxA5 (Frame Control) must be inserted in front.

Note:As I receive frames the tart mark is 2 x 0x3F. To loop the same message back I must modify these to oxAA.

Assuming you use System Message you can replace ID with the following:

  • #define CAN_BAUDRATE_ID 0x01fffed0
  • #define CAN_CPU_INFO0_ID 0x01fffff0
  • #define CAN_CPU_INFO1_ID (CAN_CPU_INFO0_ID + 1)
  • #define CAN_VERSION_ID 0x01ffffe0
  • #define CAN_INIT_ID 0x01fffeff // Clean Flash(500,000 bps/mask 0x0000)
  • #define CAN_FILTER_BASE_ID 0x01fffeeX // X=0-F(Mask Index)
  • #define CAN_ABOM_ID 0x01fffeb0
  • #define CAN_ART_ID 0x01fffea0
  • #define CAN_RESET_ID 0x01fffec0 // Reset

Set baudrate

  • Replace ID with CAN_BAUDRATE_ID
  • 4 first bytes of data is speed.
  • DLC=4
  • System Message

1 byte CRC

For more details see this: Robotell-USB-CAN-Python/Robotell_USB-CAN.txt at master · nopnop2002/Robotell-USB-CAN-Python · GitHub

 

Leave a Reply