Page 1 of 1

Question about CAN bus accuracy

Posted: Fri Nov 23, 2012 9:42 am
by r_romeo
the facts:
If I have a flowchart that sends, lets say, one package of CAN every second with the function DELAY or with TIMER, the measured answer is very accurate (0,002 [ms]).
If I send that communication to other microcontroller, and using the detection of a CAN package as a trigger to send its own CAN package with a delay, THAT DELAY is not allays the same, even if I program it to do so.
this variable delay can be around 0.1-0.3 [ms] with my CAN bus running at 500 Kbits/s

question:
Is the detection of a CAN package somehow variable inside of the microcontroller (even if the data received is the same every time) ?
here is a screenshot showing the measurements
Immagine.jpg
Immagine.jpg (136.97 KiB) Viewed 2554 times
As you can see, the period (show the signal send by Tx, below ) is much accurate than the measure on top that show the answer to that CAN signal.

here are the files just if someone want to play , I just disable the TMR interrupt icon in RX to see the signal as is coming from TX
can-test-1-tx.fcf_pic16
(9.5 KiB) Downloaded 298 times
can-test-1-RX.fcf_pic16
(18.5 KiB) Downloaded 293 times

Re: Question about CAN bus accuracy

Posted: Fri Nov 23, 2012 10:20 am
by Benj
Hello,

I believe the varying delay you are experiencing is maybe due to the timer count value at the time you receive the CAN message. You could try presetting this in your C icon before enabling the interrupt by using the following C code.

TMR2 = 0x00;