INNO USB-CAN MODULE User Manual

Page 1
www.inno-maker.com
1
USB-CAN MODULE User Manual
Design Service,Production Service
Support: support@inno-maker.com www.inno-maker.com/wiki Bulk Price: sales@inno-maker.com
Page 2
Design Service,Production Service
2
1. Compatible with Raspberry Pi Zero/Zero W/2B/3B/3B+.
2. Full support for CAN bus 2.0A and 2.0B specification.
3. Elimination the need for software drivers when you run Debian9 system of Raspberry Pi.
4. Comes with demos of Socket CAN, save your development time.
5. “plug and play” (hot-pluggable) USB device ,no external power required.
6. On board high-speed STM32 microcontroller, stronger data processing ability and lower power
www.inno-maker.com

General Description:

which realizes long-distance communication between your Raspberry Pi and other devices stably
though CAN- Bus connection.
With small size and convenient operation, It’s a cost-effective solution that are safe and reliable
for all your data-conversion / device-protection applications for any experienced engineer
interfacing to expensive industrial equipment yet simple enough for home use by an amateur
hobbyist.

Features:

consumption.
6.Wider CAN baud rate, 20Kbps----1Mpbs can be programmed arbitrarily.
7. Power supply and signal isolation ,Built-in surge and static protection.
8. 120 Ohm selectable jumper feature.
Support: support@inno-maker.com www.inno-maker.com/wiki Bulk Price: sales@inno-maker.com
Page 3
www.inno-maker.com
3

1. Pin Out Configuration

2. 120 Ohm resistor setting.

Hardware Description

Design Service,Production Service
Disable 120 Ohm resistor. Enable120 Ohm resistor.
Support: support@inno-maker.com www.inno-maker.com/wiki Bulk Price: sales@inno-maker.com
Page 4
Design Service,Production Service
4

1. CAN Communication Test Demo

(1) Prepare two USB-CAN module and two Raspberry Pi board. Connect the H and L port of
(2) Down the the demo image from INNO wiki page:
(3) Execute commands to visited the test demo.
(4) Execute following commands in serial terminal. You should see the “can 0” socket can device.
(5) Set one Pi as receiver, execute following commands in serial terminal. Now this Raspberry pi
www.inno-maker.com

Software Description

Run demo for two Raspberry Pi

USB-CAN module to other’s port, and then insert into the USB Host of Raspberry PI board.
http://www.inno-maker.com/wiki/doku.php?id=usb_can
Or http://www.inno-maker.com/wiki/
Note :You must use a TF card at least than 16Gb, Otherwise it will write failed.
ifconfig –a
is blocked.
./can0_receive
Support: support@inno-maker.com www.inno-maker.com/wiki Bulk Price: sales@inno-maker.com
Page 5
www.inno-maker.com
5
(6) Set other Pi as sender, execute following commands.
(7) You should see that the receiver has received the packet.
./can0_send
Design Service,Production Service
Support: support@inno-maker.com www.inno-maker.com/wiki Bulk Price: sales@inno-maker.com
Page 6
Design Service,Production Service
6
www.inno-maker.com

Run demo for only one Raspberry Pi

In this case, you also can insert two USB-CAN module into a Raspberry PI board to test. You
should see two can socket “can 0” and “can 1” devices. So notice that you need to modify the
code to change “can 0” to “can 1” when you use “can 1” device.
Support: support@inno-maker.com www.inno-maker.com/wiki Bulk Price: sales@inno-maker.com
Page 7
Design Service,Production Service
7

2. Linux C Programing

(1) Preparations:

(2) For Sender’s code:

www.inno-maker.com
Now with previous demo’s code to show you how to program socket can in linux. The socket
can is an implementation of CAN protocols(Controller Area Network) for Linux. CAN is a
networking technology which has widespread use in automation, embedded devices, and
automotive fields. While there have been other CAN implementations for Linux based on
character devices, Socket CAN uses the Berkeley socket API, the Linux network stack and
implements the CAN device drivers as network interfaces. The CAN socket API has been designed
as similar as possible to the TCP/IP protocols to allow programmers, familiar with network
programming, to easily learn how to use CAN sockets.
Elimination the need for software drivers when you run Debian9 system of Raspberry
Pi.(2018-06-27-raspbian-stretch.img is validated already)or later.
If you meet problems in other system, You need to reconfigure the kernel drivers. Enable
gs_usb can and install gs_usb.ko into system. So notice that if you only compile this drivers, It
may fail to load in system. At this time, compile fully with new configure.
The compiled firmware with LINUX -4.14.50 version is available from our wiki link as below:
http://www.inno-maker.com/wiki/doku.php?id=usb_can
Or http://www.inno-maker.com/wiki/
Note :You must use a TF card at least than 16Gb, Otherwise it will write failed.
Step 1: Create the socket, If an error occurs then the return result is -1.
Support: support@inno-maker.com www.inno-maker.com/wiki Bulk Price: sales@inno-maker.com
Page 8
Design Service,Production Service
8
www.inno-maker.com
Step 2: Locate the interface to “can0” or other name you wish to use. The name will show when
you execute “./ifconfig –a”.
Step 3: Bind the socket to “can0”.
Step 4: Disable sender’s filtering rules,this program only send message do not receive packets.
Step 5: Assembly data to send.
Support: support@inno-maker.com www.inno-maker.com/wiki Bulk Price: sales@inno-maker.com
Page 9
Design Service,Production Service
9

(3) For Receiver’code:

www.inno-maker.com
Step 6: Send message to the can bus.You can use the return value of write() to check whether all
data has been sent successfully .
Step 7: Close can0 device and disable socket.
step 1 and step 2 is same as Sender’s code.
step 3:It’s different from Sender’s.
Support: support@inno-maker.com www.inno-maker.com/wiki Bulk Price: sales@inno-maker.com
Page 10
Design Service,Production Service
10
Version
Description
Author
Date
E-mail
V1.0.0.0
First edition
Calvin
2019.01.015
calvin@inno-maker.com
www.inno-maker.com
Step 4Define receive filter rules,we can set more than one filters rule
Step 5: Read data back from can bus.
For more Socket CAN detail please refer to below link:
https://www.kernel.org/doc/Documentation/networking/can.txt

Version Descriptions

If you have any suggestions,ideas, codes and tools please feel free to email to me. I will update
the user manual and record your name and E-mail in list. Look forward to your letter and kindly
share.
Support: support@inno-maker.com www.inno-maker.com/wiki Bulk Price: sales@inno-maker.com
Loading...