Answer Key (doc 115 kB)

advertisement
Classroom Exercises
2008.12.05
Question 1: Messages sent over CAN network must be packed into frames as shown in
the following diagram.
1.1. The unavoidable frame data increase the communication overhead of the CAN
network. Suppose that we are using standard identifier format of 11 bits. How
many addition bits do we have to include in each CAN message?
Answer: 44 bits.
1.2. If we want to transmit N (<=8) bytes of data, how many bits does the message have?
What is the maximal bit number of a CAN message?
Answer: 44+N*8 bits. The maximal length is 108 bits.
1.3. If we want to transmit a data with arbitrary number of bytes N, what is the minimal
number of messages should we use to transmit the data?
Answer: N / 8 .
1.4. Suppose that the CAN network has a bandwidth of B bit per second (bps) and the bit
stuffing is ignored. How long does it take for the CAN network to transmit N (<=8)
bytes of data?
Answer: (44+N*8)/B
1.5. Suppose that a periodic task with period T (s) sends out N (<=8) bytes of data every
cycle on a CAN network of B (bps) bandwidth. What is the network utilization of
this task?
Answer: (44+N*8)/(B*T).
1.6. With the same assumption given in 1.5, what is the network utilization if N is an
arbitrary integer?
Answer: N bytes data are mandatory to transmit. The number of messages is
N / 8 (>=1); thus the number of additional bits is N / 8  44 . The total number of bits
to transmit is L= N  8  N / 8  44 . So the network utilization is L/(B*T).
Question 2. Three periodic tasks are sharing a CAN network with 250K bps. Bit stuffing
is ignored in this question. Each task is optimized so that a minimal number of messages
are transmitted.
 Task 1 has the period of 1 ms and sends out 4 bytes every cycle.


Task 2 has the period of 2 ms and sends out 8 bytes every cycle.
Task 3 has the period of 3 ms and sends out 12 bytes every cycle.
2.1. What is the utilization of the CAN network?
44  4  8
108
108  (44  4  8)


 0.765 .
Answer:
250 1
250  2
250  3
2.2. Please assign priorities, i.e., CAN frame identifiers, to the messages sent out by the
three tasks using the rate monotonic scheduling method.
2.3. Please draw the timing diagram of the message transmission.
Answer: Message transmissions are not pre-emptive. Message transmission time:
Task 1 = 0.304 ms,
Task 2 = 0.432 ms
Task 3 = 0.432 + 0.304 ms
At time 0, task 3 actually sends out two messages. The following diagram shows that the
8-byte message is sent out first and then the 4-byte message.
Owing to the higher priority of task 1, the two messages cannot be transmitted
successively. If, on the other hand, task 3 sends out 4 bytes first and then 8 bytes, the
timing diagram would follow the same pattern so that the two messages are interrupted
by a message of task 1.
Question 3: What is bit stuffing of CAN network? Design the automaton model of an
error detection device of the bit stuffing of CAN network. The device monitors the bit
stream on the network and issues a warning (by entering the marker states) whenever an
error arises.
Question 4: Recall your exercises in Lab 8: CAN communication.
4.1. How many channels does an MCF5213 microcontroller have?
Answer: 0-15 channels
4.2. Can you use a channel to both transmit and receive messages?
Answer: no.
4.3. How do you define a channel to receive or transmit messages?
Answer: Use can_initialise() driver function to define the receiving channels. All
the undefined channels from channel 2 to 15 can be used for transmission. Channels 0
and 1 are reserved for Rubus RTOS.
4.4. How many message identifiers can one channel receive?
Answer: one
4.5. How many message identifiers can one channel transmit?
Answer: multiple
4.6. When you transmit a message, do you specify the channel or identifier?
Answer: yes, you must specify the sending channel and the message identifier.
4.7. When you receive a message, do you specify the channel or identifier?
Answer: You only specify the channel. The matching between identifier and the
receiving channel is automatically made according to your initialization.
Download