G120HDR + CAN DW module - 100kbps

Hello everyone,
How can I read data on CAN bus at speed 100kbps? Enumerator “ControllerAreaNetwork.Speed” has only 1000, 500, 250, 125kbps values.
Example:


var can = new ControllerAreaNetwork(ControllerAreaNetwork.Channel.One,
ControllerAreaNetwork.Speed.Kbps125);

Is there some way to read CAN bus at 100kbps?

There si overload method, but I do not know timing parameters:


var timings = new ControllerAreaNetwork.Timings(15, 8, 7, 20, 1);
var can = new ControllerAreaNetwork(ControllerAreaNetwork.Channel.One, timings);

To calculate parameters I use online calculator http://www.kvaser.com/support/calculators/bit-timing-calculator/
but I do not know Input clock frequency. :frowning:

Thank you!

@ Adam - The static property SourceClock on ControllerAreaNetwork will tell you the input clock for CAN on your device.

CiA Draft Standard DS-102 states “100kbps is not recommended for new development” without giving any explanations. I guess that’s why it is not in the enumeration.

Ok,
my input clock frequency is: 6MHz.
Desired CAN bus bit rate is 100kbps.

I am confused in parameters of method “ControllerAreaNetwork.Timings”. Method has these:

int propagation
int phase1
int phase2
int brp
int synchronizationJumpWidth

Calculated result table has: (http://www.kvaser.com/support/calculators/bit-timing-calculator/)
T1: the number of quanta before the sampling point.
T2: the number of quanta after the sampling point.
BTQ: the number of quanta per bit.
SP%: the position of the sampling point, in percent of the whole bit.
SJW: the Synchronization Jump Width.
Bit Rate: the resulting bus speed, in kbps.
Err%: the deviation, in percent, from the desired bit rate.
BTR0: Bus Timing Register 0, in hex, for 82527/SJA1000/82C200/compatible.
BTR1: Bus Timing Register 1, in hex, for 82527/SJA1000/82C200/compatible.

What is what? :slight_smile: I’m sorry, I’m not CAN BUS expert. :frowning: Thank you!

@ Adam - try my this post https://www.ghielectronics.com/community/forum/topic?id=12703&page=1#msg131130

It is not entirely correct, but should help…

Had 2 minutes free… Try these numbers (calculated on-the-fly):

BRP=39
PROP=2
PHASE1=5
PHASE2=6
SJW=3

Thank you! I have tried to calculate values too but without success. I have used your values. Now, I have an error code “2”.

Still error code “2” = Bus_Off. Any suggestions are welcome. On oscilloscope everything looks good.

Tell us more about your system. How long are the cables? Have you terminated them correctly? How many devices on it? Or is it just G120?

I have only two nodes. Now, distance between them is about 10m, but at the end of debugging it will be 0,5m. Terminators are on both devices and both have 120ohm.
The second device is Inverter and is connected to solar panels. I am trying to read some values as actual supplied power and so on… I know, and on the oscilloscope I can see it, that bit rate is 100kbps. Connection is made with two wires. CANL is connected on CANL and CANH is connected to CANH. It seems that everything is OK. Have you some advice please? :slight_smile:

What are the CAN timing parameters of that other node?

http://www.nxp.com/documents/data_sheet/PCA82C250.pdf

Finally, I can read CAN BUS messages transmitted by other node wiht bitrate 100kbps. My findings are:

  1. CAN DW module must be powered by 5V not 3.3V.
  2. Calculated values by given (*) formula was bad.

There are values which works:
BRP=25
PROP=0
PHASE1=15
PHASE2=8
SJW=1

*(https://www.ghielectronics.com/community/forum/topic?id=12703&page=1#msg131130)