Interfacing
CAN controller
113
48193
|
FPeter replied at Mon Nov 17, 2014 12:08 
Here is my solution for CAN transceiver: MCP2551 with voltage divider
This small module can be fitt ...
Hello FPeter
how many of the Bpi-CAN_3 do you have? Do you sell?
Heinz |
|
|
|
|
|
|
|
hjoe replied at Thu Nov 20, 2014 14:23 
Hello FPeter
how many of the Bpi-CAN_3 do you have? Do you sell?
hello hjoe!
it's a homemade version, so i made only one but i can share its eagle project files
but since i realized that there is an internal pullup to 5V on it's TXD pin, it's not a perfect solution despite of the voltage divider on RXD pin...

so i think i will change it to a real 3.3V transciever like MAX3051 or SN65HVD23x family... |
|
|
|
|
|
|
|
If you have the choice, take Texas Instruments.
TI is active in the standardization, as far as I know TI was the first one offering 3.3V transceivers and TI is now working on CAN FD transceivers. |
|
|
|
|
|
|
|
Can someone of the can4linux users please check if my calculation of the bit timing register is correct. Especially the value for 1 Mbit/s.
In the mean time, I will add the controller to http://www.bittiming.can-wiki.info |
|
|
|
|
|
|
|
hjoe replied at Thu Nov 20, 2014 14:17 
you don't need any special tools to set the bitrate for can4linux devices.
Before opening any /dev ...
Hi,
the receive tool is enough for me, and I use it to set the bus speed also.
Even if I try to redirect the output to a file the result is the same.
But my main problem is the board hangs up when many frames are received. |
|
|
|
|
|
|
|
I tested it with these settings:
AccCode :-1
AccMask :-1
ArbitrationLost :0
Base :29539328
Baud :1000
CAN clock :24000000
Chipset :
dbgMask :0
framelength :8
IOModel :m
IRQ :58
OpenCount : 0(4)
Outc :0
Overrun :0
RxErr :0
RxErrCounter :0
Timeout :100
TxErr :0
TxErrCounter :0
version :4.3_BANANAPI SVN version 433
using ./receive -n -s 100 -l
Received with ret=0
Received with ret=0
Received with ret=0
Received with ret=0
Received with ret=12: 1416597819.726499 id=264/0x00000108
len=8 flags=0x80 : bD ( 8): 55 aa 55 aa 07 10 00 00
Received with ret=12: 0.000264 id=0/0x00000000
len=-28357 flags=0x1007aa55 : eRF (-28357):
Received with ret=12: 0.000000 id=270600192/0x10210800
len=0 flags=0xb23e9 : BRF [ 0]:
Received with ret=12: 2857697280.268937813 id=730461/0x000b255d
len=0 flags=0x00 : bD ( 0):
Received with ret=12: 1416597819.730857 id=0/0x00000000
len=0 flags=0x00 : bD ( 0):
Received with ret=12: 0.000000 id=0/0x00000000
len=0 flags=0x00 : bD ( 0):
Received with ret=12: 0.000000 id=0/0x00000000
len=0 flags=0x00 : bD ( 0):
Received with ret=12: 0.000000 id=0/0x00000000
len=0 flags=0x00 : bD ( 0):
Received with ret=12: 0.000000 id=0/0x00000000
len=0 flags=0x00 : bD ( 0):
Received with ret=12: 0.000000 id=0/0x00000000
len=0 flags=0x00 : bD ( 0):
Received with ret=12: 0.000000 id=0/0x00000000
len=0 flags=0x00 : bD ( 0):
Received with ret=12: 0.000000 id=0/0x00000000
len=0 flags=0x00 : bD ( 0):
Received with ret=2: 1416597819.765786 id=264/0x00000108
len=8 flags=0x00 : bD ( 8): 55 aa 55 aa 07 10 00 00
Received with ret=2: 0.000264 id=0/0x00000000
len=-28357 flags=0x1007aa55 : eRF (-28357):
Received with ret=0
while syslog prints out
Nov 21 19:23:39 lemaker kernel: [ 662.347950] can4linux: CAN[0][0] RX: FIFO overrun
Nov 21 19:23:39 lemaker kernel: [ 662.351530] can4linux: CAN[0] Rx: Overrun Status
Nov 21 19:23:39 lemaker kernel: [ 662.355106] can4linux: CAN[0] Rx: Overrun Status
Nov 21 19:23:39 lemaker kernel: [ 662.394403] can4linux: CAN[0] Rx: Overrun Status
Nov 21 19:23:41 lemaker kernel: [ 664.314068] can4linux: CAN[0] Rx: Overrun Status
than the board hangs
using ./receive -l -d -t 4 -n -B 2000 -s 1000
./receive V SVN $Revision: 433 $, Nov 16 2014
(c) 2012-2014 H.J. Oertel
using canmsg_t with 88 bytes
CAN FD data structure used
open CAN device "/dev/can0" in non-blocking mode
Change to Listen Only Mode
Change to Time Stamp Mode 4
Received with ret=0
Received with ret=0
Received with ret=0
Received with ret=0
Received with ret=0
Received with ret=0
Received with ret=0
Received with ret=0
Received with ret=0
Received with ret=0
Received with ret=0
Received with ret=0
Received with ret=0
Received with ret=0
Received with ret=0
Received with ret=0
Received with ret=0
Received with ret=0
Received with ret=0
Received with ret=0
Received with ret=0
Received with ret=14: 1416598397.389327 id=264/0x00000108
len=8 flags=0x80 : bD ( 8): 55 aa 55 aa 07 10 00 00
Received with ret=14: 0.000264 id=0/0x00000000
len=-27779 flags=0x1007aa55 : eRF (-27779):
Received with ret=14: 0.000000 id=270600192/0x10210800
len=0 flags=0x5fed5 : eRF ( 0):
Received with ret=14: 2857697280.268937813 id=393292/0x0006004c
len=0 flags=0x00 : bD ( 0):
Received with ret=14: 1416598397.393683 id=0/0x00000000
len=0 flags=0x00 : bD ( 0):
Received with ret=14: 0.000000 id=0/0x00000000
len=0 flags=0x1007aa55 : eRF ( 0):
Received with ret=14: 0.000000 id=0/0x00000000
len=0 flags=0x00 : bD ( 0):
Received with ret=14: 0.000000 id=0/0x00000000
len=0 flags=0x00 : bD ( 0):
Received with ret=14: 0.000000 id=0/0x00000000
len=0 flags=0x00 : bD ( 0):
Received with ret=14: 0.000000 id=0/0x00000000
len=0 flags=0x00 : bD ( 0):
Received with ret=14: 0.000000 id=0/0x00000000
len=0 flags=0x00 : bD ( 0):
Received with ret=14: 0.000000 id=0/0x00000000
len=0 flags=0x00 : bD ( 0):
Received with ret=14: 0.000000 id=0/0x00000000
len=0 flags=0x00 : bD ( 0):
Received with ret=14: 0.000000 id=0/0x00000000
len=0 flags=0x00 : bD ( 0):
Received with ret=7: 1416598398.578522 id=264/0x00000108
len=8 flags=0x00 : bD ( 8): 55 aa 55 aa 07 10 00 00
Received with ret=7: 0.000264 id=0/0x00000000
len=-27778 flags=0x1007aa55 : eRF (-27778):
Received with ret=7: 61512.000000 id=1030997/0x000fbb55
len=0 flags=0x4c0a : BD ( 0):
Received with ret=7: 2857697280.268937813 id=393292/0x0006004c
len=0 flags=0x00 : bD ( 0):
Received with ret=7: 1416598397.393683 id=0/0x00000000
len=0 flags=0x00 : bD ( 0):
Received with ret=7: 0.000000 id=0/0x00000000
len=0 flags=0x1007aa55 : eRF ( 0):
Received with ret=7: 0.000000 id=0/0x00000000
len=0 flags=0x00 : bD ( 0):
while syslog prints out
Nov 21 19:33:17 lemaker kernel: [ 200.740885] can4linux: CAN[0][0] RX: FIFO overrun
Nov 21 19:33:17 lemaker kernel: [ 200.744466] can4linux: CAN[0] Rx: Overrun Status
Nov 21 19:33:17 lemaker kernel: [ 200.748042] can4linux: CAN[0] Rx: Overrun Status
than the board hangs again
if I simply use ./receive the tool prints frames at fast speed but the board hang up as before |
|
|
|
|
|
|
|
Flavio,
if you specify -n, that means non blocking, together with -s 100
receive looks every 100ms if there are messages and reads these messages. But 100ms are a long time.
according to your log:
Received with ret=14: 0.000000 id=0/0x00000000
len=0 flags=0x00 : bD ( 0):
someone is sending CAN frames with ID=0 and zero data bytes. With 1 Mbit/s such a Fame is about 60 µs long and with a high bus load you will receive many frames in 100 ms. I always use blocking and something like
$ receive -t3 -H
-t3 displays the time between consecutive frames. And -H looks (for me) much nicer.
|
|
|
|
|
|
|
|
I have some problems at the moment with 1 Mbit/s. Thats why I asked to verify the bi timing register value.
But I did test with 500Kbit/s. I send frames with a desktop PC
can_send -t11 -s0 -T 1024 -b 500
this will send 1024 frames as fast as possible
The Banana receives it
receive -H -b 500 > log
After the transmitter has finished I stop the receiver. I do
wc -l log
1024
and see, that exactly as much as sent receive have received, 1024 frames
Looking at the log file log:
1416602290.130315 0/0x00000000 : bD ( 8): 55 02 03 04 05 06 07 aa
1416602290.130568 1/0x00000001 : bD ( 8): 55 02 03 04 05 06 07 aa
1416602290.130816 2/0x00000002 : bD ( 8): 55 02 03 04 05 06 07 aa
1416602290.131059 3/0x00000003 : bD ( 8): 55 02 03 04 05 06 07 aa
1416602290.131308 4/0x00000004 : bD ( 8): 55 02 03 04 05 06 07 aa
1416602290.131554 5/0x00000005 : bD ( 8): 55 02 03 04 05 06 07 aa
.........
1416602290.378913 1018/0x000003fa : bD ( 8): 55 02 03 04 05 06 07 aa
1416602290.379169 1019/0x000003fb : bD ( 8): 55 02 03 04 05 06 07 aa
1416602290.379427 1020/0x000003fc : bD ( 8): 55 02 03 04 05 06 07 aa
1416602290.379683 1021/0x000003fd : bD ( 8): 55 02 03 04 05 06 07 aa
1416602290.379943 1022/0x000003fe : bD ( 8): 55 02 03 04 05 06 07 aa
1416602290.380201 1023/0x000003ff : bD ( 8): 55 02 03 04 05 06 07 aa
it took
1416602290.380201-1416602290.130315 = .249886
250 ms for transmitting 1024 frames with 8 byte each.
.249886/1024 = .000244
each 244µs a frame was received, That's really nearly 100% bus load at 500 Kbit/s.
No Frame lost.
I hope to get the basic test done with 1 Mbit/s today or tomorrow.
Heinz
|
|
|
|
|
|
|
|
I have changed the bit timing values for 1 Mbit/s to 0x00090001, sample point at 83.3 %. Now it works for me. I don't know how I cam to the previous value. Please check use these values. I have checked it in into svn at SourceForge. |
|
|
|
|
|
|
|
Hi,
using 436 revision and ./receive -t3 -H
Correct frame id are:
0x00000090
0x00000108
0x000007f8
all others are read errors
- 0.009697 144/0x00000090 : bD ( 6): 02 00 00 00 1d 5e
- 0.000004 144/0x00000090 : bD ( 4): 66 cc 66 cc
- 0.000006 144/0x00000090 : bD ( 8): 55 aa 55 aa 02 10 78 00
- 0.000004 144/0x00000090 : bD ( 8): 00 00 00 00 00 00 00 00
- 0.000004 144/0x00000090 : bD ( 8): 00 00 00 00 00 00 00 00
- 0.000004 128/0x00000080 : bD ( 1): 00
- 0.000001 144/0x00000090 : bD ( 8): e8 ff ff ff 08 12 00 55
- 0.008682 144/0x00000090 : bD ( 4): 66 cc 66 cc
- 0.000003 144/0x00000090 : bD ( 8): 55 aa 55 aa 01 10 0e 00
- 0.000006 144/0x00000090 : bD ( 8): f2 ff ff ff 05 00 00 00
- 0.000004 144/0x00000090 : bD ( 6): 05 00 00 00 40 5e
- 0.000003 144/0x00000090 : bD ( 4): 66 cc 66 cc
- 0.000003 144/0x00000090 : bD ( 6): 02 00 00 00 41 5e
- 0.008927 144/0x00000090 : bD ( 8): d3 0d d0 bb 83 b5 ed 3e
- 0.000004 144/0x00000090 : bD ( 8): c8 2c ec bb 80 2b a6 3b
- 0.000004 144/0x00000090 : bD ( 8): 00 22 a8 b9 00 00 00 00
- 0.000004 144/0x00000090 : bD ( 8): 00 00 00 00 a7 52 ad bb
- 0.000004 144/0x00000090 : bD ( 6): f7 ff ff ff 62 5e
- 0.000001 144/0x00000090 : bD ( 8): 55 aa 55 aa 01 10 0e 00
- 0.000001 144/0x00000090 : bD ( 8): 55 aa 55 aa 02 10 78 00
- 0.008429 264/0x00000108 : bD ( 8): 00 00 00 00 20 fc 00 00
- 0.007239 264/0x00000108 : bD ( 8): 48 00 00 00 00 00 00 00
- 0.000018 280/0x00000118 : bD ( 4): 66 cc 66 cc
- 0.000003 144/0x00000090 : bD ( 8): 55 aa 55 aa 01 10 0e 00
- 0.000004 144/0x00000090 : bD ( 8): 15 00 00 00 f2 ff ff ff
- 0.000004 144/0x00000090 : bD ( 8): 00 00 30 00 00 00 eb 65
- 0.000004 144/0x00000090 : bD ( 8): fe ff ff ff dd ff ff ff
- 0.000000 0/0x00000000 : bD ( 0):
- 0.000000 2/0x00000002 : bD ( 1): 00
- 0.000001 0/0x00000000 : bD ( 0):
- 0.000000 64/0x00000040 : bD ( 0):
- 0.000000 685/0x000002ad : bD ( 0):
- 0.000000 1360/0x00000550 : bR ( 5):
- 0.000000 112/0x00000070 : bD ( 0):
- 0.000003 144/0x00000090 : bD ( 8): f9 ff ff ff f7 ff ff ff
- 0.007239 144/0x00000090 : bD ( 6): ed ff ff ff 8c 5e
- 0.000003 144/0x00000090 : bD ( 4): 66 cc 66 cc
- 0.000001 264/0x00000108 : bD ( 8): 55 aa 55 aa 09 10 b8 00
- 0.006552 264/0x00000108 : bD ( 8): 44 4a 49 01 18 42 18 42
- 0.000003 264/0x00000108 : bD ( 8): 18 42 18 42 00 00 00 00
- 0.000001 2040/0x000007f8 : bD ( 1): 04
- 0.000001 2040/0x000007f8 : bD ( 4): 66 cc 66 cc
- 0.000003 144/0x00000090 : bD ( 8): 55 aa 55 aa 01 10 0e 00
- 0.005151 144/0x00000090 : bD ( 6): 05 00 00 00 94 5e
- 0.000003 144/0x00000090 : bD ( 4): 66 cc 66 cc
- 0.000013 133/0x00000085 : bD ( 9): 00 08 21 00 44 4a 49 01
- 0.000001 144/0x00000090 : bD ( 6): 01 00 00 00 98 5e
- 0.000001 144/0x00000090 : bD ( 4): 66 cc 66 cc
- 0.000001 144/0x00000090 : bD ( 2): 66 cc
- 0.000001 264/0x00000108 : bD ( 8): 00 00 00 00 00 00 00 00
- 0.005131 144/0x00000090 : bD ( 2): 66 cc
- 0.000001 144/0x00000090 : bD ( 6): 05 00 00 00 94 5e
- 0.006876 144/0x00000090 : bD ( 4): 12 00 7b 8c
- 0.000001 279899612/0x10aeeddc : eR (15):
- 0.000000 64/0x00000040 : bD (14): 00 60 f8 1b bd 60 7f 2d
- 0.005280 48/0x00000030 : bD (12): 00 fc ff ff ff 9e 5e 02
- 0.000001 3/0x00000003 : bD ( 2): cc 08
- 0.000001 2/0x00000002 : bD ( 1): aa
- 0.003739 1360/0x00000550 : bR ( 5):
Copy the Code Than the board hangs again
The distance from the board and the device is less than 30cm |
|
|
|
|
|
|