USBtin - USB to CAN interface

USBtin is a simple USB to CAN interface. It can monitor CAN busses and transmit CAN messages. USBtin implements the USB CDC class and creates a virtual comport on the host computer.
SMD board, programmed + tested

USBtin SMD board prototype
Buy on Fischl.de!
(€ 34,90 incl. 19% VAT excl. € 4 shipping)

Buy on TinyTronics.nl!
(€ 37,50 incl. 21% VAT excl. shipping)
English, Nederlands

Buy on Amazon.de!
(€ 37,90 incl. 19% VAT excl. shipping)
English, Deutsch, Nederlands,
Polski, Türkçe, Čeština

Contents

Drivers

For Linux, MacOS and Windows >8 no additional driver is needed! USBtin is automatically detected as virtual serial port.

Driver for Windows <8:
USBtin_Win_Driver.zip


USBtin is mapped to serial port "/dev/ACMx" (Linux, MacOS) or "COMx" (Windows). You have to select this corresponding port in the software. On some Linux systems, "modemmanger" blocks the port for about 20s after plug-in (if this disturbs: disable or remove the modemmanager).

Software

There are several options to control USBtin from the host computer.

USBtinViewer - Simple multi-platform GUI

USBtinViewer
USBtinViewer is a simple GUI for USBtin. It is open source (GPL), written in Java and runs on several platforms (Windows, Linux, MacOS). Depending on operating system, double-click the downloaded JAR file or run it from command line with "java -jar USBtinViewer_v1.3.jar".
Requirement: Java JRE>=1.6



USBtinLib - Java Library for own developments

usbtin.connect("COM3");

usbtin.addMessageListener(new CANMessageListener() {
    @Override
    public void receiveCANMessage(CANMessage canmsg) {
        System.out.println(canmsg);
    }                
});

usbtin.openCANChannel(10000, USBtin.OpenMode.ACTIVE);

System.in.read(); // wait for user input

usbtin.send(new CANMessage(0x100, new byte[]{0x11}));

usbtin.closeCANChannel();
usbtin.disconnect();
USBtinLib is a Java Library for accessing USBtin. It simplifies the use of USBtin in own applications. USBtinLib is open source (LGPL) and runs on several platforms (Windows, Linux, MacOS). The example code (left box) prints out incoming CAN messages and send out one message. Tutorial: Create own GUI with USBtinLib for testing or simulating CAN bus devices.
Requirement: Java JRE>=1.5

USBtinLib-1.2.0.jar (2016-04-29)



Serial terminal - Control USBtin with any serial terminal

Hterm in use with USBtin
Commands to USBtin can be sent with any serial terminal program such as HTerm which is available as freeware for Windows and Linux. There is a sequence file for HTerm with the main USBtin commands predefined. To load it in HTerm, right click into "Sequence Overview" -> "Load File...".



Linux-can (SocketCAN) - Use linux CAN functions

Wireshark and USBtinKayak
USBtin also works with linux-can (SocketCAN). Here is short tutorial about this:
USBtin and linux-can (SocketCAN)

Tools based on linux-can can be used with USBtin. For example:


Third party and community projects - Software supporting USBtin

Libraries and tools supporting USBtin:

Firmware

Source code and HEX file

The firmware of USBtin is available as precompiled HEX file and as C (XC8 compiler) source code:

usbtin.2017-11-24.tar.gz Version v1.8 - Increased rx buffer, optimized message handling, added selftest on startup.

usbtin.2016-10-13.tar.gz Version v1.7 - Fixed filter init and RX flag handling. Improved throughput (patch by Kaloian Doganov, Carista).

usbtin.2016-04-13.tar.gz Version v1.6 - Fixed order of outgoing messages (TX fifo). Added support for USB serial number.

usbtin.2014-12-05.tar.gz Version v1.5 - New buffer structure with USB ping-pong and CDC directly to USB ram.

usbtin.2014-09-20.tar.gz Version v1.4 - Improved performance: Increased bulk transfer packet size (patch by Jürgen Liegner)

usbtin.2014-04-07.tar.gz Version v1.3 - Based on improvement suggestions by Mikael Gustavsson (MG Digital Solutions)

usbtin.2013-01-11.tar.gz Version v1.2 - Added filter function 'm' and 'M' and register write 'W'

usbtin.2012-03-09.tar.gz Version v1.1 - First public version

Firmware update via bootloader

Set the bootloader jumper (JP1) and plug in USBtin. Now the bootloader starts. Use bootloader application (e.g. en MPHidFlash) to load the new firmware into the flash of USBtin:
mphidflash -w USBtin_firmware_v1.x.hex

ASCII commands

USBtin registers as a virtual serial port on the host computer. With simple ASCII commands USBtin can be controlled over this serial port. You can send/receive commands from any serial terminal program or from your own program. If you don't like to deal with the plain commands, there is also a simple GUI: USBtinViewer.

Example

Set 10 kBaud, open CAN channel, send CAN message (id=001h, dlc=4, data=11 22 33 44), close CAN:
Command:                Response:
S0[CR]                  [CR]
O[CR]                   [CR]
t001411223344[CR]       z[CR]
C[CR]                   [CR]

Command list

The commands are line based and terminated with newline character CR (0xD). On error the USBtin responses with 0x7.

Sx[CR] Set baudrate
x: Bitrate id (0-8)
 S0 = 10 kBaud
 S1 = 20 kBaud
 S2 = 50 kBaud
 S3 = 100 kBaud
 S4 = 125 kBaud
 S5 = 250 kBaud
 S6 = 500 kBaud
 S7 = 800 kBaud
 S8 = 1 MBaud
sxxyyzz[CR] Set can bitrate registers of MCP2515. You can set non-standard baudrates which are not supported by the "Sx" command.
xx: CNF1 as hexadecimal value (00-FF)
yy: CNF2 as hexadecimal value (00-FF)
zz: CNF3 as hexadecimal value
Gxx[CR] Read MCP2515 register. xx: Address of MCP2515 register to read as hexadecimal value (00-FF).
Wxxyy[CR] Write MCP2515 register. xx: Address of MCP2515 register to write. Hexadecimal value (00-FF).
yy: Data to write to the register. Hexadecimal value (00-FF).
V[CR] Get hardware version.
v[CR] Get firmware version.
N[CR] Get serial number. Returns always 0xffff.
O[CR] Open CAN channel.
l[CR] Open device in loop back mode.
L[CR] Open CAN channel in listen-only mode.
C[CR] Close CAN channel
tiiildd..[CR] Transmit standard (11 bit) frame.
iii: Identifier in hexadecimal format (000-7FF)
l: Data length (0-8)
dd: Data byte value in hexadecimal format (00-FF)
Tiiiiiiiildd..[CR] Transmit extended (29 bit) frame.
iiiiiiii: Identifier in hexadecimal format (0000000-1FFFFFFF)
l: Data length (0-8)
dd: Data byte value in hexadecimal format (00-FF)
riiil[CR] Transmit standard RTR (11 bit) frame.
iii: Identifier in hexadecimal format (000-7FF)
l: Data length (0-8)
Riiiiiiiil[CR] Transmit extended RTR (29 bit) frame.
iiiiiiii: Identifier in hexadecimal format (0000000-1FFFFFFF)
l: Data length (0-8)
F[CR] Read status/error flag of can controller
Return: Fxx[CR] with xx as hexadecimal byte with following error flags:
Bit 0 - not used
Bit 1 - not used
Bit 2 - Error warning (Bit EWARN of MCP2515)
Bit 3 - Data overrun (Bit RX1OVR or RX0OVR of MCP2515)
Bit 4 - not used
Bit 5 - Error-Passive (Bit TXEP or RXEP of MCP2515)
Bit 6 - not used
Bit 7 - Bus error (Bit TXBO of MCP2515)
Zx[CR] Set timestamping on/off.
x: 0=off, 1=on
mxxxxxxxx[CR] Set accpetance filter mask. SJA1000 format (AM0..AM3). Only first 11bit are relevant.
xxxxxxxx: Acceptance filter mask
Mxxxxxxxx[CR] Set accpetance filter code. SJA1000 format (AC0..AC3). Only first 11bit are relevant.
xxxxxxxx: Acceptance filter code

Hardware

Schematic - USBtin's circuit diagram

USBtin Schematic

Partlist - Build your own USBtin!

Here you find a list of all parts needed to build your own USBtin board. The red marked parts are also available as USBtin-Set (PCB + programmed uC + crystal).

PartnumberValue
C14,7u
C2, C3, C4, C5100n
C6, C722p
CON1USB-B
CON23pol
IC1PIC18F14K50-I/P
IC2MCP2515-I/P
IC3MCP2551-I/P
JP1, JP22pol 2,54mm
LED13mm LED red
Q124Mhz !fundamental!
R1, R2, R3, R51k
R4120
M13pol
M2Jumper
M3Socket 20
M4Socket 18
M5Socket 8
M6Case
M7PCB

Troubleshooting

Linux/Ubuntu: "Permission denied" when accessing /dev/ACM0

/dev/ttyACMx belongs to dialout group, so add user to this group (re-login or reboot to take effect!):
$sudo adduser $USER dialout

Linux/Ubuntu/RaspberryPi: USBtin is blocked or misconfigured after plugging in or bootup

The program "network-manager" probes the serial port (sends strings for modem detection). Add rule so network-manager ignores USBtin:
sudo gedit /etc/udev/rules.d/10-local.rules
Add this line:
ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="000a", ENV{ID_MM_DEVICE_IGNORE}="1"

Arduino: No communication between Arduino+MCP2515 and USBtin

Please check the clock of the MCP2515 used on your Arduino board. It must match with the settings in the Arudino MCP2515 library (e.g. default of the MCP_CAN Library for Arduino is 16 MHz). Otherwise the CAN controller generates unexpected baudrates.

Linux: "cdc_acm 1-2.2:1.0: acm_port_activate - usb_submit_urb(ctrl irq) failed" when accessing /dev/ACM0

This is a bug in the cdc-acm kernel module. Please update your kernel!
USBtin is used in various applications (personal and professional). Some users even built their own USBtin device.
Please tell me about your USBtin project!

USBtin by Thomas Fischl
   by Thomas Fischl (04/2012)

USBtin-Set with PCB, programmed uC and crystal available:
Order USBtin-Set. Other parts see partlist.
USBtin by Nico Ferreira
   by Nico Ferreira (02/2014)

PCB is homemade with laser.
Plastic box is a Hammond 1551K.
USBtin by John
   by John (05/2014)

Wired on breadboard.
USBtin by Βασίλης Σπυρόπουλος
   by Βασίλης Σπυρόπουλος (07/2014)

Mounted in case Teko 10014.9.
With OBD-2 adapter cable.
USBtin by Александр Сафонов
   by Александр Сафонов (09/2014)

USBtin by John Gerrard
   by John Gerrard (12/2014)

USBtin with Wago Buskoppler 750-307
   USBtin EB and Wago CANopen Fieldbus Coupler 750-307 test setup
by Georg G. (01/2015)

USBtin connected to Android device
   USBtin EB connected to Android device with USB-OTG (Host) function.
USB Serial Terminal Lite is used to communicate with USBtin.
(04/2015)
Maxon Epos CANopen with USBtin
   USBtin connected to Maxon EPOS CANopen motor controller. USBtin is used for Sniffing at CANopen.

Video: Use USBtin to run CANopen devices from a Pyton script

by Bas de Bruijn (05/2015)
Control LC5100 with USBtin
   USBtin EB connected to Beckhoff LC5100 CANopen bus coupler.
For further details see Control CANopen devices with USBtin.
(07/2015)
USBtin connected to BMW iDrive controller
   USBtin EB communicates with BMW iDrive controller.

by Manuel R. (08/2015)
USBtin used for racing car
   USBtin EB is used for parametrization and monitoring of racing car components.

by UPBracing Team e.V. (11/2015)
USBtin connects SCHUNK FTM115 with KUKA KRC3
   USBtin EB (installed in blue box) is used to connect SCHUNK FTM115 force torque module with KUKA KRC3 industrial robot.

by Dennis B. (12/2015)
USBtin wired on breadboard
   USBtin wired on breadboard. Uses TJA1054 instead of MCP2551. Connected to CAN bus of Jeep Grand Cherokee.

by Mariusz K. (12/2015)
USBtin connected to Eltek Valere Flatpack2
   IW0BYL Michele Aita is using USBtin EB to interface Eltek Valere Flatpack2 powersupply. Output voltage and current is controlled via the CAN interface (default output voltage is 53,5V, not suitable to supply the RF power amplifier, therefore Michele sent commands to the Faltpack2 to setup a default voltage of 48,6 V). Also the power supply status, i.e. temperature, line voltage, ecc can be monitored.
(05/2016)
3D printed case for USBtin
  
Marina designed a case for USBtin EB and printed it on a 3d printer.
STL 3D file: USBtin_case_Marina_rev.1.stl
(07/2016)
USBtin with OpenWRT router
  
CAN-to-Ethernet: USBtin EB connected to a NEXX WT3020F mini pocket router with OpenWRT installed.
Installation like Printserver for label printer Brother QL570 with driver "opkg install kmod-usb-acm". Then you can send messages from a router shell to USBtin: echo "O" > /dev/ttyACM0
(10/2016)
Volta Helicopter
  
Two USBtin interfaces are used for the HMI unit of the first all-electric conventional helicopter: http://voltahelicopter.com
(12/2016)
USBtin EB with two Beckhoff 5120 units
  
An USBtin EB controls two Beckhoff 5120 units with the Datalink Engineerings CANopen API (Windows, C++ and C#/.NET).
(01/2017)
3D printed case for USBtin EB
  
3D printed case for USBtin EB designed by Daniel Förstmann.
STL 3D file: USBtin_EB_Case stl
(02/2017)
USBtin clone
  
Single side USBtin board with THT components.

by vova Avlacenko (03/2017)
Buderus Logaterm WPS Headpump
  
USBtin connects Buderus Logaterm WPS Heatpump to the FHEM house automation server.

FHEM perl module: 26_KM273.pm
Discussion about this plugin: Modul für Buderus Wärmepumpe WPS (German).
by mike3436 (05/2017)
USBtin connected to Stiebel Eltron WPF 10
  
USBtin EB logs CAN bus messages of the heating / heat pump controller Stiebel Eltron WPF 10.
Description: Connecting and analysing WPF 10 CAN bus (German).

by REccoon (06/2017)
USBtin EB on Loxone Link (Miniserver)
  
Sven uses an USBtin EB to monitor and analyse the Loxone Link. Test setup: Loxone Miniserver Go with RS485 Extension and RS485 relay board.
Description: Loxone Link protocol analysis (German).

by Sven L. (07/2017)
USBtin EB used by Fast Forest Formula Student Team Deggendorf IT
  
USBtin EB is used in racing cars to add additional CAN bus channels to the control units.

by Fast Forest e.V. Formula Student Team Deggendorf IT (07/2017)
USBtin EB with B&R controller
  
Andy uses USBtin EB to troubleshoot the CAN interface between a B&R industrial controller and a large battery charger, designed to charge a very large bank of batteries for a sea platform.

by Andy W. (08/2017)
USBtin EB with Rocrail
  
USBtin controls model railroads with Rocrail. Different model railway CAN bus systems are supported, e.g. Märklin CS2/CS3 and Gleisbox, MERG CBUS, Zimo MX10 or Roco Z21.

by Rocrail, Rob Versluis (02/2019)
Digital display for skittle alley with USBtin EB
  
Digital display for skittle alley, realized with USBtin EB and Raspberry Pi.

by Felix P. (09/2019)
USBtin single sided PCB
  
Théo designed a version of the USBtin PCB to be able to mill it on a cheap milling machine on a one sided PCB.
Kicad files: https://github.com/Villanut0/USBtin

by Théo Villanueva (01/2020)
USBtin 3d printed case
  
Florian designed a case for 3D printing to protect the USBtin PCB and adapt it to D-SUB.
Design on Thingiverse (CC BY-NC 3.0): USBtin D-SUB case

by Florian P. (02/2020)
USBtin controls Huawei R4850G2
  
Matthew read out statistics and set output voltage of Huawei R4850G2 power supply with USBtin.
CAN message to aquire statistics: T108040fe80000000000000000

by Matthew G. (03/2023)
Maxim has wired a USBtin from several breakout boards
  
Maxim has wired a USBtin from several breakout boards.

By Maxim D. (04/2024)

USBtin and linux-can (SocketCAN)

Other can interface projects

en CANUSB adapter by LAWICEL
de Tiny-CAN interface by MHS Elektronik