Question about CAN bus accuracy

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
r_romeo
Posts: 54
Joined: Wed Nov 02, 2011 3:57 pm
Has thanked: 14 times
Been thanked: 3 times

Question about CAN bus accuracy

Post 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 2457 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 269 times
can-test-1-RX.fcf_pic16
(18.5 KiB) Downloaded 273 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Question about CAN bus accuracy

Post 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;

Post Reply