SMD board, programmed + tested

USBtin SMD board prototype
€ 34,90
incl. 19% VAT excl. € 4 shipping
Order USBtin EB now!

Buy on Amazon.de!
(€ 37,90 incl. 19% VAT excl. shipping)
Shipping to all EU countries!

Buy on Amazon.co.uk!
(£ 27,90 incl. 19% VAT excl. shipping)
PCB + programmed uC + crystal
USBtin: PCB, uC, crystal
€ 14,90
incl. 19% VAT excl. € 4 shipping
Order USBtin-Set now!

Buy on Amazon.de!
(€ 17,90 incl. 19% VAT excl. shipping)
Shipping to all EU countries!

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.

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.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!

PCB + programmed uC + crystal
USBtin: PCB, uC, crystal
€ 14,90
incl. 19% VAT excl. € 4 shipping
Order USBtin-Set now!

Buy on Amazon.de!
(€ 17,90 incl. 19% VAT excl. shipping)
Shipping to all EU countries!
SMD board, programmed + tested

USBtin SMD board prototype
€ 34,90
incl. 19% VAT excl. € 4 shipping
Order USBtin EB now!

Buy on Amazon.de!
(€ 37,90 incl. 19% VAT excl. shipping)
Shipping to all EU countries!

Buy on Amazon.co.uk!
(£ 27,90 incl. 19% VAT excl. shipping)
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) - see photo in right box.

PartnumberValueReicheltConrad
C14,7u RAD 4,7/35 445587 - 62
C2, C3, C4, C5100n X7R-5 100N 531855 - 62
C6, C722p KERKO 22P 457167 - 62
CON1USB-B USB BW 738884 - 62
CON23pol AKL 182-03 729906 - 62
IC1PIC18F14K50-I/P PIC18F14K50-IP
(not programmed!)
651666 - 62
(not programmed!)
IC2MCP2515-I/P MCP 2515-I/P 651447 - 62
IC3MCP2551-I/P MCP 2551-I/P 651451 - 62
JP1, JP22pol 2,54mm SL 1X36G 2,54 742235 - 62
LED13mm LED red LED 3MM 2MA RT 184560 - 62
Q124Mhz !fundamental!--
R1, R2, R3, R51k 1/4W 1,0K 405256 - 62
R4120 1/4W 120 405140 - 62
M13polAKL 169-03 729841 - 62
M2Jumper JUMPER 2,54GL SW 737557 - 62
M3Socket 20 GS 20 189545 - 62
M4Socket 18 GS 18 189537 - 62
M5Socket 8 GS 8 189502 - 62
M6Case TEKO 10007 543335 - 62
M7PCB - -

USBtin PCB top view

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"
If you have built your own version of USBtin, please let me know!

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 and linux-can (SocketCAN)
de embedded projects Journal - Article about USBtin in Journal #13

Other can interface projects

en CANUSB adapter by LAWICEL
de Tiny-CAN interface by MHS Elektronik
de CAN interface with R8C/23