Fleetpc 5 Can Bus Manual
Fleetpc 5 Can Bus Manual
CANBUS - Manual
1.0 Introduction
The CARTFT CANBUS is a low cost and easy to use CAN/USB dongle, that could be used
together with Windows or Linux O/S with two types of drivers. One Virtual COM Port driver (VCP)
which acts as a standard RS232 COM port (in this mode CANBUS can replace our CAN232 and
gain more bandwidth on CAN with minor or none software change). The other driver is a Direct
Driver (D2XX) which uses a DLL to communicate with the CANBUS. Both drivers can not co-excist
on the same PC, you have to choose one of them, however it is easy do uninstall and change from
e.g. VCP to D2XX driver. CANBUS uses same type of commands (standard ASCII format) such
as the CAN232 V2, though some old way of communicating (V1 Poll and Poll All) has been remo-
ved in favour of new optimized transfer speeds. The CANBUS handles both the 11bit ID format as
well as the 29bit ID format, RTR frames, built in FIFO queues, extended info/error information and
simple power up through a few commands, no external power is needed, it is supplied from the
USB port. The CANBUS is only 60mm long, 35mm wide and 15mm thick using the latest technology
of small SMD parts on both sides of the board, the power behind is an Atmel AVR, the Philips
SJA1000 CAN controller and the FTDI Parallel FT245BM USB chip and that makes it very flexible
in the way of handling small bursts of CAN frames at a high bus speed. This document describes
the 1:st version of the CANBUS which can be updated via a bootloader via USB.
1.1 Installation
Please look at www.cartft.com for latest driver packages (VCP & D2XX). On the CANBUS site
there are also in depth installation instructions of the CANBUS with the drivers. Please select one
of the drivers which suite your needs the most. Maybe you just want to replace the CAN232 with a
CANBUS, then choose VCP drivers and you are up running quickly. D2XX drivers needs a totally
diffrent approach, though is faster in transfering CAN frames.
CANBUS - Manual
CANBUS - Manual
If you are migrating from CAN232, the CANBUS do not have the old fashioned P and A commands.
Instead incomming CAN frames are sent out at once. Replies back from t and T commands has
also changed, so it only replies [CR] or [BELL] instead of z[CR] or Z[CR] depending on command.
This to save bandwidth on the USB side of the driver. Otherwise commands are the same.
Always start each session (when your program starts) with sending 2-3 [CR] to empty any prior
comand or queued character in the CANBUS (many times at power up there could be false char-
acters in the queue or old ones that was from a previous session), then check the CAN version
with V command (to be sure that you have communication with the unit at correct speed) then set
up the CAN speed with s or S command, then open the CAN port with O, then the CANBUS is in
operation for both sending and receiving CAN frames. Send frames with the t ot T command and
wait for a response back to see it it was placed in the CAN FIFO transmission queue or the queue
was full. Incomming frames from the CAN bus will be sent out at ones. Then once in a while send
the F command to see if there are any errors (e.g. each 500-1000mS or if you get an error back
from the CAN232). If you get to many errors back after sending commands to the unit, send 2-3
[CR] to empty the buffer, then issue the commands again, if this continue allert the user or application
within your program that there is a communication error (e.g. a damaged CAN tranceiver or power
failure etc.).
The www.cartft.com website offers many sample programs in source code. These programs are
free to use or alter to suit your needs.
CANBUS - Manual
S0 Setup 10Kbit
S1 Setup 20Kbit
S2 Setup 50Kbit
S3 Setup 100Kbit
S4 Setup 125Kbit
S5 Setup 250Kbit
S6 Setup 500Kbit
S7 Setup 800Kbit
S8 Setup 1Mbit
Example: S4[CR]
Setup CAN to 125Kbit.
Example: s031C[CR]
Setup CAN with BTR0=0x03 & BTR1=0x1C
which equals to 125Kbit.
Example: O[CR]
Open the channel
CANBUS - Manual
Example: C[CR]
Close the channel
Example 1: t10021133[CR]
Sends an 11bit CAN frame with ID=0x100, 2 bytes
with the value 0x11 and 0x33.
Example 2: t0200[CR]
Sends an 11bit CAN frame with ID=0x20 & 0 bytes.
Example 1: t0000010021133[CR]
Sends a 29bit CAN frame with ID=0x100, 2 bytes
with the value 0x11 and 0x33.
CANBUS - Manual
Example 1: F[CR]
Read Status Flags.
CANBUS - Manual
Example: M00000000[CR]
Set Acceptance Code to 0x00000000
This is default when power on, i.e. receive all frames.
Example: mFFFFFFFF[CR]
Set Acceptance Mask to 0xFFFFFFFF
This is default when power on, i.e. receive all frames.
The Acceptance Code Register and the Acceptance Mask Register works together and they can
filter out 2 groups of messages. For more information on how this work, look in the SJA1000
datasheet. In 11bit ID´s it is possible to filter out a single ID this way, but in 29bit ID’s it is only
possible to filter out a group of ID’s. The example below will set a filter to only receive all 11bit
ID’s from 0x300 to 0x3FF.
Commands Comments
M00006000[CR] AC0=0x00, AC1=0x00, AC2=0x60 & AC3=0x00
m00001FF0[CR] AM0=0x00, AM1=0x00, AM2=0x1F & AM3=0xF0
The first command tells the filter 2 to match 2 bits and if they are not set (in this case it corresponds
to 0x3nn, the 3). The second command tells the nn to be don't care, so it could be from 0 to FF,
though not so easy to read, since they are not placed nice in a row in memory. Filter 1 s turned off
(uses AM0, AM1 & half lower AM3). The last byte in the mask could also be 0xE0 instead of 0xF0,
then we filter out the RTR bit as well and you wont accept RTR frames.
.
CANBUS - Manual
Example: V[CR]
Get Version numbers
Example: N[CR]
Get Serial number
CANBUS - Manual
If the Time Stamp is OFF, the incomming frames looks like this:
t10021133[CR] (a standard frame with ID=0x100 & 2 bytes)
If the Time Stamp is ON, the incomming frames looks like this:
t100211334D67[CR] (a standard frame with ID=0x100 & 2 bytes)
Note the last 4 bytes 0x4D67, which is a Time Stamp for this
specific message in milliseconds (and of course in hex). The timer
in the CANBUS starts at zero 0x0000 and goes up to 0xEA5F before
it loop arround and get’s back to 0x0000. This corresponds to exact
60,000mS (i.e. 1 minute which will be more than enough in most
systems).
Example 1: Z0[CR]
Turn OFF the Time Stamp feature (default).
Example 2: Z1[CR]
Turn ON the Time Stamp feature.