Go Down

Topic: Arduino Due CAN transmit speed (Read 355 times) previous topic - next topic



Does anyone know the time it takes to transmit a CAN message?
when i time the loop that sends 1 CAN msg it takes ~900┬Ás is this normal?
I am using the due_can library.

I have a project where i am simulating some CAN nodes.
It needs to send 7 msg's @ 10ms and 9 @ 20ms and receive msg's on CAN0
and receive msg's and send 1 msg @ 10ms on CAN1

when all messages are send in the same loop it give problems with the timing.

is there anyway to speed up the transmit process?


No one can give you a definite answer to your timing question because it depends on a lot of information you didn't give.

For one, CAN frames can be different sizes. You could have 0 to 8 data bytes. Also, the bus does bit stuffing which adds some bits to the total in ways that are only predictable if someone knows the exact bits in the source message. Lastly, the bus can run at a WIDE range of speeds.

So, let's go for a run of the mill example. Let's say you're using standard frames (11 bit ID) and all 8 data bytes. 8 data bytes is 64 bits. The 11 bit ID brings this up to 75. Start bits, end bits, bit stuffing, various control bits, and the CRC add more overhead. I'm too lazy to look it all up but it'll be right around 110 bits to send this sort of frame. Let's also say that you're using the 250000 baud bus speed. That's 4 microseconds per bit.  4 * 110 = 440uS to send the frame. Thus, I'd say that 900uS sounds a bit long unless you are using 125000 bus speed.

The easiest approach to speed things up is to use a faster bus speed. You can go all of the way up to 1 million baud which would drop the frame transmit time down to 110us. But, the faster you go the harder it is to keep communications working properly. Usually people stick to 250k and 500k. My advice would be to use 500k bus speed.

Go Up