Buffer size in relation to the cycle time

You will have to estimate how big the buffer has to be or how fast the task time must be. The following table will help you to define this in advance.

The CCAT CAN master has a memory for 512 messages, the EL6751 for 150 messages (RxMessages). The data will be lost if they are not fetched quickly enough from the memory. No indication is given, therefore the worst case should or must be estimated, or the variable NoOfRxMessages should as far as possible be smaller than the maximum buffer value. If this is always or in almost every cycle at the maximum value, then this indicates that more data are being received than can be recorded per cycle. Remedy: Shorten the task cycle time or enlarge the buffer of the CAN queue.

Example

A CAN telegram with 11-bit identifier and 8 bytes of user data needs about 260 µs at 500 Kbit/s. If one assumes a 100% bus load in the worst case, it would be maximally 3 telegrams with 1 ms. This means that a buffer of maximally 4 would be adequate in this case. If a task time of 5 ms is used instead of 1 ms, the buffer should be at least 20 (5000 µs / 260 µs). It must be remembered here that in this study only the data in one direction are considered and that the CAN data always have 8 bytes. Since a 100% bus load is not usually assumed, one can also evaluate the variable NoOfRxMessages and see whether it lies in most cases below the maximum number of buffers created. If NoOfRxMessages is often at the maximum value, the task time should be shortened or the buffer enlarged.

Worst case

However, the CAN interface is designed such that, as a rule, the data can always be fetched faster than they run into the buffer.

Example

1 MBaud data length 0 means 50 µs per CAN message. With a 1 ms task time this would be
1000 µ / 50 µs = 20
This means that even in this extreme worst case a buffer of 20 would be adequate to receive all CAN telegrams.

Table for the telegram runtimes with 11-bit ID [ms]1)

Bit rate
[kbit/s]

Data length in bytes

0

1

2

3

4

5

6

7

8

50

1.09

1.28

1.47

1.66

1.86

2.05

2.24

2.34

2.62

125

0.44

0.51

0.59

0.67

0.74

0.82

0.90

0.97

1.05

250

0.22

0.26

0.29

0.33

0.37

0.41

0.45

0.49

0.52

500

0.11

0.13

0.15

0.17

0.19

0.21

0.22

0.24

0.26

1000

0.05

0.06

0.07

0.08

0.09

0.10

0.11

0.12

0.13

1) Data from CIA