8 devices Korlan USB2CAN User manual

!
Korlan USB2CAN User Guide
High quality isolated USB to CAN interface
02-04-2022

Table of contents
1. Introduction! "3
1.1 Usage warning! "3
1.2 Technical specification! "3
2. Korlan USB2CAN converter! "5
2.1 CAN connector pinout! "5
2.2 LED indication! "6
2.4 Testing modes! "7
3. Work on Linux! "8
3.1 Driver and configuration! "8
3.2 Tools - can-utils (send/receive CAN packets)! "8
3.3 Python programming examples for Linux! "9
3.4 Firmware upgrade! "10
4. Work on Windows! "11
4.1 Installing Windows 10/11 WinUSB driver! "11
4.2 Korlan USB2CAB test application for Windows - kcan.exe! "12
4.3 Python programing examples for Windows! "14
4.4 Firmware upgrade!15
KORLAN USB2CAN USER GUIDE
2

1. Introduction
Korlan USB2CAN provides a convenient computer (USB) to CAN 2.0 network interface. "
You can send and receive CAN messages. Write your program for communicating with industrial, medical,
and automotive devices equipped with CAN interface. Korlan USB2CAN comes in two different versions:
DB9 or OBD2. The Korlan CANBUS USB adapter connects a CAN bus to the USB port of any device
running the Linux or Windows operating system, which also supplies the power to the adapter (no power
supply is required). In the downloads section, you can find all the related drivers, software applications, and
programming examples for Windows 10/11 and Linux operating systems."
1.1 Usage warning
Use your device with caution and a complete understanding of the risks. This warning informs you that the
operation of this device may be dangerous. Your actions can influence the behavior of a CAN-based
distributed embedded system, and depending on the application, the consequences of your improper
actions could cause serious operation malfunction, loss of information, damage to equipment, and physical
injury to yourself or others."
1.2 Technical specification
CONNECTORS
Computer
USB 2.0 Full speed, Type A connector
CAN
D-SUB, 9 pins. CAN-CIA standard interface pin assignment or OBD2, 16 pins. Standard interface pin
assignment.
CAN
Specification
ISO 11898-2 High-speed CAN"
2.0A (standard format) and 2.0B (extended format)
Bit rates
50, 50, 100, 125, 250, 500, 800, 1000 Kbit/s or user definable
Controller
ARM 32bit Cortex-M0 (STM32F072)
Transceiver
TI ISO1050
Galvanic isolation
Up to 2.5kV, separate for each CAN channel
Termination
None
MEASURES
Size
110 x 36.7 x 16.2 mm (L x W x H), no cable
Weight
DB9 version: 100g with cable, OBD2 version: 140g with cable
ENVIRONMENT
Operating temperature
From -35ºC to +55ºC
Relative humidity
15-90%, not condensing
Usage
Indoor only
OTHER
Available drivers
Windows 2000, Windows XP, Windows Vista, Windows 7, Windows 10, Linux
3rd party ptotocol support
Driver for VSCP protocol
KORLAN USB2CAN USER GUIDE
3

Open source CANAL API DLL for Windows
Linux SocketCAN compatible
CONNECTORS
KORLAN USB2CAN USER GUIDE
4

2. Korlan USB2CAN converter
2.1 CAN connector pinout
FIGURE 2-1. DB9 CONNECTOR
FIGURE 2-2. ODB2 CONNECTOR
Note: All other pins on OBD2 are not used and not connected.$
KORLAN USB2CAN USER GUIDE
5
PIN
SIGNAL
DESCRIPTION
1
-
No connection
2
CANL
CANL bus line (dominant low)
3
CAN GND
CAN Ground
4
-
No connection
5
CAN_SHLD
Connected to CAN GND via 100 Ω/0.1uF
6
CAN GND
CAN Ground
7
CANH
CANH bus line (dominant high)
8
-
No connection
9
-
No connection
PIN
DESCRIPTION
4
GND
5
GND
6
CAN Bus High
14
CAN Bus LOW

2.2 LED indication
Korlan USB2CAN has three LEDs (Power, Error, Info) for device status indication. &
Device status Indication modes are listed in the table below.
LED
STATUS DESCRIPTION
PWR LED on
Device is powered on.
INFO LED on, STAT LED off
CAN interface enabled, device is ready to receive or send data.
STAT LED on, INFO LED off
CAN interface is not enabled on a host device.
INFO LED on, STAT LED blinking
CAN interface sending data.
INFO LED blinking fast
CAN bus passive error.
INFO LED blinking slow
CAN bus warning.
STAT LED blinking slow
CAN bus-offerror.
KORLAN USB2CAN USER GUIDE
6
1. INFO – !LED (Info)&
2. STAT!–!LED (Status)"
3. PWR!–!LED (Power)
2.3 CAN bus termination
A High-speed CAN bus (ISO 11898-2) must be terminated on both ends with 120 Ohm resistors. "
Standard termination example."
The 120-Ωcharacteristic impedance twisted-pair cable must be terminated with an impedance of the same
value to minimized reflected waves that occur from miss-matched impedances. Bad terminal may cause signal
reflections and the transceivers of the connected CAN nodes (CAN- interface, control device) may not work."
"
The USB2CAN does not have an internal termination. Device must be used on a terminated CAN bus.

2.4 Testing modes
Korlan USB2CAN supports three testing modes:"
•Loopback - mode is used to test if the device is applicable when only one device is available. If Korlan
USB2CAN is in loopback mode, everything sent through the CAN interface is sent back to the device.
The CAN interface TX pins are connected to its RX pins."
•Silent - in this mode, the interface only listens CAN bus. No data or ACK frames are sent."
•Silent loopback - is a self-test mode that can be used in a working CAN system without interfering with
other devices connected to the CAN bus.$
KORLAN USB2CAN USER GUIDE
7

3. Work on Linux
3.1 Driver and configuration
Mainline Linux has supported the Korlan USB2CAN converter since version 3.9. It works with Linux
distributions like Ubuntu and Debian with no additional driver installation. For Raspbian, the driver must be
built manually. Instruction on building CAN driver for Raspbian can be found on 8devices WIKI pages. "
https://www.8devices.com/wiki/korlan:compile-raspberry"
Recommended Linux distributions:
•Ubuntu 18.04 or later"
•Debian 8 (Jessie) or later"
•Raspbian Bullseye"
You can verify if Korlan USB2CAN device is recognized by the system and drivers loaded correctly
using(the usb-devices command. In the output, you will see your device:"
usb-devices
T: Bus=03 Lev=02 Prnt=02 Port=02 Cnt=03 Dev#= 7 Spd=12 MxCh= 0
D: Ver= 2.00 Cls=ff(vend.) Sub=ff Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=0483 ProdID=1234 Rev=01.00
S: Manufacturer=8Devices
S: Product=USB2CAN converter
S: SerialNumber=9508BBCC
C: #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
I: If#=0x0 Alt= 0 #EPs= 4 Cls=ff(vend.) Sub=ff Prot=ff Driver=usb_8dev
If you use several Korlan USB2CAN devices, you will see all of them in USB-devices output with different
SeriaNumber values. The first device in the output will correspond to the can0 socketcan interface, the
second - can1, etc."
If the driver is loaded correctly, the CAN interface should be seen by issuing the command:"
ip link show
4: can0: <NOARP,ECHO> mtu 16 qdisc noop state DOWN mode DEFAULT group default qlen 10
link/can
Set can0 interface speed to 125 Kbps:"
sudo ip link set can0 up type can bitrate 125000 sample-point 0.875
Bring the can0 interface to UP state (INFO LED lights on, STAT LED lights off):"
sudo ip link set can0 up
To bring down the interface (STAT LED lights up, INFO LED lights off):"
sudo ip link set can0 down
To get more information about configuration options type:"
sudo ip link set can0 type can help
3.2 Tools - can-utils (send/receive CAN packets)
The programs allow you to get CAN communications instantly using two commands, cansend, and
candump.
Command to install the tool:
KORLAN USB2CAN USER GUIDE
8

sudo apt-get install can-utils
Send byte of information (1122334455667788) to can device with id = “1f334455”:
cansend can0 1f334455#1122334455667788
Receive everything on the can1 interface:
candump can1
3.3 Python programming examples for Linux
Python programming examples rely on the python-can module and socket can drivers.(Before running
code examples, you shall bring the CAN interface to the UP state using the command:
sudo ip link set can0 up type can bitrate 125000 sample-point 0.875
Example receive_all.py - receives and prints all messages on the screen until Ctr-C is pressed."
import can
bus = can.Bus(channel='can0', interface='socketcan', bitrate=1000000)
for i in range(10):
msg = can.Message(arbitration_id=0xc0ffee, data=[i,2,3,4,5,6,7,8],
is_extended_id=True)
bus.send(msg)
Example send.py - sends 10 CAN messages to the bus."
import can
bus = can.Bus(channel='can0', interface='socketcan', bitrate=1000000)
for i in range(10):
msg = can.Message(arbitration_id=0xc0ffee, data=[i,2,3,4,5,6,7,8],
is_extended_id=True)
bus.send(msg)
KORLAN USB2CAN USER GUIDE
9

3.4 Firmware upgrade
Install dfu-util tool
sudo apt-get install dfu-util
Switch to the internal bootloader using the set_dfu utility provided with the firmware:"
sudo ./set_dfu
Flash new firmware as root:"
sudo dfu-util -a 0 -s 0x8008000 -D USB2CAN-v2.0.bin
KORLAN USB2CAN USER GUIDE
10

4. Work on Windows
4.1 Installing Windows 10/11 WinUSB driver
Download the Korlan USB2CAN driver from"
https://www.8devices.com/media/products/usb2can_korlan/downloads/usb2can_winusb.msi."
Install it following the procedure."
Check if the device is functioning correctly using Windows Device Manager$
KORLAN USB2CAN USER GUIDE
11

4.2 Korlan USB2CAB test application for Windows - kcan.exe
There are two options to use kcan.exe on your computer."
•Download the zip file with all necessary files from"
https://www.8devices.com/media/products/usb2can_korlan/downloads/kcan.zip"
•Download kcan_setup.exe and run it to install kcan.exe on your computer"
https://www.8devices.com/media/products/usb2can_korlan/downloads/kcan_setup.exe"
Now you can run the kcan.exe application.
Select the desired Korlan USB2CAN device id from the dropdown menu if you use multiple Korlan devices
on your computer."
KORLAN USB2CAN USER GUIDE
12

From the dropdown menu, select the desired bit rate."
"
Click on the Configure button. You will observe device hardware and software details. And Korlan
connection status on the status bar at the bottom of the window."
Now you can proceed to the TX/RX tab and observe received and transmitted messages on a scrollable
messages pane. You shall set desired CAN ID and DATA for transmitting messages, then click on the button
Send.$
KORLAN USB2CAN USER GUIDE
13

You can run multiple instances of kcan.exe on your Windows computer to control multiple Korlan
USB2CAN devices. Make sure you select the proper device ID and set the correct bit rates."
THE Korlan USB2CAN test application is implemented in Python and relies on a versatile python-can library.
8devices provide the source code of kcan.exe under a very friendly license for your reference and
experiments."
4.3 Python programing examples for Windows
You will require a CANAL DLL library from the 8devices WEB site. It’s been provided for 64 and 32-bit
environments"
https://www.8devices.com/media/products/usb2can_korlan/downloads/korlan_python-can_examples.zip"
Examples are based on python-can library programming examples and are slightly modified, adding Korlan
USB2CAN specific information and providing an explicit path to the usb2can.dll library."
You will need to install a python-can library using your favorite Python package installer."
send_one_korlan.py - sends a single CAN bus message."
import can
with can.interface.Bus(bustype="usb2can", channel="9508bbcc", bitrate=1000000, dll='./
usb2can.dll') as bus:
msg = can.Message(arbitration_id=0xC0FFEE, data=[0, 25, 0, 1, 3, 1, 4, 1],
is_extended_id=True)
try:
bus.send(msg)
print(f"Message sent on {bus.channel_info}")
except can.CanError:
print("Message NOT sent”)
KORLAN USB2CAN USER GUIDE
14

receve_all_korlan.py - receiving and printing CAN bus messages in the loop until Ctrl-C is pressed."
import can
with can.interface.Bus(bustype="usb2can", channel="d3365afb", bitrate=1000000, dll='./
usb2can.dll') as bus:
try:
while True:
msg = bus.recv(1)
if msg is not None:
print(msg)
except KeyboardInterrupt:
pass # exit normally
4.4 Firmware upgrade
Firmware upgrade to version 2.3 is straightforward on Windows operating system. Follow the instructions
below."
1. Connect your Korlan USB2CAN adapter to the USB port of your computer."
2. Download Korlan USB2CAN Firmware Upgrade Tool v2.3 from our website:"
https://www.8devices.com/media/products/usb2can_korlan/downloads/USB2CAN_v23.exe"
3. Run the USB2CAN_v23.exe file to start the firmware upgrade."
4. Follow instructions and wait until the firmware upgrade is finished before disconnecting Korlan USB2CAN
device."
KORLAN USB2CAN USER GUIDE
15
Other manuals for Korlan USB2CAN
1
Table of contents