USBtin (canUSB) board rev 0-2

USBtin (also called canUSB), is a project that allows  sending and receiving can messages from a USB host machine. The hardware and software design was done by Thomas Fischl, and more information can be learned from his page . When plugged into a computer the board creates a (CDC) serial port. This makes interfacing very easy.

canUSB_data
Board from above

 

canUSB_serialThe normal 9600 baud works well to connect the usb serial port to a terminal program. On windows I use putty as a serial port terminal.

 

 

 

CanUSB does not echo characters, and the newlines are set up in a linux way. So I force echo characters, and newline for every return line.

CanUSB_speed_prtScreen

The list of commands is as follows.

  
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

 

IMG_2494
Board from below

 

The code for the board is on our github, here.

There are two program on the pic currently. A loader program and a canUSB program. The loader away starts first. If the jumper is off the loader jumps to the canUSB program. If the jumper is on the loader waits for a new hex file.

If you want to program the board via USB, a jumper should be placed on bootloader jumper. The board will identify has an HID (human interface device). A program like mphidflash, can be used to load on new hex file on the board.

 

This project is very similar to several other commercially used products. 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>