MSCS-667: Industrial Automation Systems
Abu Sayed Md. Mostafizur Rahaman
Department of Computer Science and Engineering
• CAN Bus
• Sample Exercise
CAN (Controller Area Network)
– CAN (Controller Area Network) is a serial bus system used to communicate between
several embedded 8-bit and 16-bit microcontrollers.
– It was originally designed for use in the automotive industry but is used today in many
other systems (e.g. home appliances and industrial machines).
– Highest Baud Rate is 1Mbit.
– CAN uses a message oriented transmission protocol.
• Developed by
– Robert Bosch GmbH in the 1980s.
• Application Area
– Automotive sectors.
• Reason for developing:
– Increasing share of controller and automating technology
– lively data exchange
• i.e. a high number of communication process but only small data packets
– Minimization of wiring effort
– High error safety
– Small latency time
– Distributed systems, several receiver
– Good extensibility
– Priorization of messages
• Bus level
– Dominant and the Recessive level
– Dominant level means logic 0 and the
Recessive level means logic 1
Overview ISO / OSI Layer Model
• Physical layer
– Serial data transmission in a bus topology.
• MAC Layer:
– Protocol (CSMA/CA)
• Each participant that wants to send listens
• if the bus is occupied ( carrier sense) and starts the sending process when
the bus was idle for a certain time.
• There is the possibility that several participants start to send at the same
time ( multiple access).
• The resolving of an eventually appearing collision is carried out as part of
the arbitration process.
• Hereby all the affected participants start by putting their frames (starting
with the identifier) bit by bit on the bus.
• After each bit the sender checks if the actual level on the bus corresponds
with the level that it applied on the bus. If not it stops sending
• This results that message with the highest priority gains the bus access
without the destruction of the message (collision avoidance).
Out of the 7 layers, only the
blue colored ones ( 1, 2, and 7 )
are considered for field busses
LLC- Logical Link Control
• The communication on the bus is based on four different frame formats:
– Data Frame
– Remote Frame
– Error Frame
– Overload Frame
LLC- Logical Link Control (Frame format)
• Start of Frame: 1 dominant bit to identify start
• Arbitration field: 11 bit identifier + 1 bit RTR (remote transmission
• Control field: 2 bits reserved for extended CAN, 4 bits for data
• Data field: 0-8 byte of data possible, starting with MSB
• CRC-field: 15 bit + 1 recessive CRC delimiter bit
• ACK-field: 1 bit ACK-slot + 1 bit ACK delimiter (recessive):
transmitter sends recessive bit in the slot; recipients that received
error free,send a dominant bit in the slot.
• End of Frame: 7 bit
Data frame format
In total the minimum frame length results in 44 bits. Additionally are the 0-64 data bits and potentially stuff bits.
LLC- Logical Link Control (Frame format)
• Remote Frame
– A participant of the bus uses the remote frame to trigger the sending of a special data frame
with the same identifier by a data source.
– Data frame and remote frame only differ in a varying RTR bit ( RTR bit of remote frame =1,
RTR bit for data frame=0 )
• Error Frame
– If a participant of the bus recognizes an erroneous frame ( e.g. wrong checksum in CRC field),
it reports this by sending an error frame.
– Therefore a sequence ( 6 bits with the same polarity) that isn’t permissible during normal
operation is switched on the bus.
– This implicates that all the other ( fully functional node) switch themselves an error frame on
the bus as the bit stuffing rule was violated. An error frame is terminated with 8 recessive bits.
• Overload Frame
– An overload frame is used to enlarge the spacing between two frames.
– It can only be send at the beginning of the spacing.
• In order to reduce the fault liability of the CAN bus the following safety
mechanisms are realized:
• Bit Monitoring
– Each transmitting network node monitors whether or not the bus level it has
transmitted is actually present on the bus. Otherwise a fault has appeared that has to be
dissolved or the sending process has to be terminated (arbitration phase).
• Frame Format Check
– As the frame format is fixed, every participant of the bus can check whether this
format is maintained ( e.g. recessive delimiter bits). Otherwise a fault is existent.
– The CAN protocol uses the NRZ bit coding ( non-return to zero).
– This means that there are longer phases without bit edges for synchronization.
– To avoid this an inverted stuff bit is set after 5 bits of the same polarity. This bit
permits the synchronization of every node and is deleted when received.
• Cyclic Redundancy Check (CRC)
– The transmitted message is secured again by CRC. Thereby the message is divided by
a special polynomial generator and the result is deposit in the CRC field. The message
is divided again by this polynomial generator by the receiver and the result is
compared with the transmitted CRC field. If there are not identical a transmission
error has appeared. (polynomial generator x15+x14+x10+x8+x7+x4+x3+1
• It should be clear by now that a major goal in designing error detection
algorithms is to maximize the probability of detecting errors using only a
small number of redundant bits. Cyclic redundancy checks use some fairly
powerful mathematics to achieve this goal.
• For example, an 8-bit message consisting of the bits 10011010 corresponds
to the polynomial,
• M(x) = 1×x7 +0×x6 + 0×x5 +1×x4 + 1×x3 + 0×x2 +1×x1 + 0×x0
= x7 +x4 + x3 +x1
• We wanted to create a polynomial T(x) for transmission that is derived from
the original message M(x), is k bits longer than M(x), and is exactly divisible
• We can do this in the following way:
1. Multiply M(x) by xk, that is, add k zeros at the end of the message. Call this zero-extended message xk
2. Divide xk M(x) by G(x) and find the remainder R(x).
3. Subtract the remainder from xk M(x) to get T(x).
It should be obvious that what is left at this point is a message that is exactly divisible by
The CAN-specification does not restrict the number of bus nodes, the length of the bus
system and the maximum baud rate. Nevertheless, the bus length or the maximum baud rate,
respectively, is limited in a real bus system.
a) Give the correlation between the baud rate and the maximum bus length. Assume a
simplified bit-timing-model. What is the maximum bus length of a CAN bus system if a
baud rate of 500kbit/s shall be achieved? The signal propagation velocity is vSig =
0.2m/ns (signal propagation velocity on a two-wire line) and the delay time caused by
the signal processing is 100ns.
• Three nodes start at the same time to write messages on the bus with the
identifiers 204 (hex), 208(hex) and 287(hex).
a) Write down the identifiers in binary notation. Take possible safety mechanisms into
204(hex) = 516(dec) = 010000010100 (bin) (Stuff-Bit)
208(hex) = 520(dec) = 010000011000 (bin) (Stuff-Bit)
287(hex) = 647(dec) = 01010000111 (bin)
b) Which message will prevail in the arbitration process? Why (give reasons)?
The message with the identifier 204 will assert it elf since it has the lowest identifier and with that the
highest priority (zero-level is dominant).
c) Carry out the arbitration process step by step. At which time, do the nodes with the
lower priority stop their transmission? Which signal level results on the bus?
The control of the power train of a new car requires four controllers to exchange safety
critical data. Motor controller and gearbox controller exchange data cyclically with a period
of 20 ms.
ABS-controller and motor controller exchange cyclically safety critical data with a period of
10 ms. Additionally, motor controller, gearbox controller, and ABS-controller shall send
acyclic data of variable length to the central diagnosis device.
Which one of the bus systems CAN, FlexRay, Profibus, or EtherCat is suited for the
interconnection of all four controllers? Explain for each bus system why it is suited or
• FlexRay: best suited. It’s time triggered and allows deterministic
transmission of safety critical cyclic data and asynchronous data as well.
• Profibus: Master-Slave-communication Single-Point of failure
– No deterministic cycle time
– Not suited
• EtherCat: Special hardware required rather expensive
• CAN: suited, but CSMA-CA not deterministic
1. Define CAN bus. Give the reason of developing of CAN bus.
2. List some application of CAN bus.
3. Describe the protocol used in CAN bus to MAC layer.
4. Give the bus level used in CAN bus with an example.
5. Describe briefly the data frame format used in CAN bus.
6. Define remote frame, error Frame and overload frame used in CAN bus.
7. Describe briefly the safety mechanism techniques used in CAN bus.
8. Describe CRC technique with an example.
• CAN-Bus (approx. 35 min)
In an automation-project of an office building you have the task to engineer the
field bus. A CAN-bus is to be used. The office building consists of 7 floors
(including ground floor) with 14 offices each. The building automation system
is responsible for the climate control, fire monitoring, and lighting control.
Figure 1 shows the layout of a floor of the office building.
The following requirements have to be considered:
• In each office a CAN node exist. The CAN node is connected with a smoke detector, a
temperature sensor, a light sensor, and a climate control unit to set the room temperature.
The coordination and control is realized through a central automation computer.
• The central automation computer should be able to query explicitly every sensor and
actuator in every room.
• In order to provide maximum safety, messages that come from the smoke detectors shall
have a higher priority than all other messages.
The sensor and actuator layout of an office is shown in Figure 2.
1. Bus Configuration
In the first step, the basic parameters of the bus system are to be determined.
Question 2.1: Transmission Rate
The length of the bus cable is 1480 m.
What is the maximum possible transmission rate?
You may assume a simplified bit timing model. The signal propagation velocity is Vsig =
0.2 m/ns and the delay time caused by the signal processing is 100 ns.
Question 2.2: Message Transfer Time
The maximum message transfer time shall not exceed 1.25 ms. You may assume a maximum
message length of 80 Bit. Can this be realized with the maximum transmission rate? Justify
your answer with a calculation.
Solution 2.1 & 2.2
2. Message Format
In the second step, the actual CAN messages are to be specified. The message identifier and
the respective data parts have to be defined.
Hint: Use binary representation!
Question 2.3: Message Coding
Each message to be transmitted shall contain the message type, the floor number, and the
a) Which messages must be distinguished in the system?
b) How do you define the encoding of message identifiers, taking message priorities into
account? Give a schematic definition of the message identifiers and justify your decision.
c) Give for each message occurring in the system an example with appropriate coding of the
b) As any sensor/actuator is to be addressed individually, the coding has to be
done within the identifier Considering the higher priority of fire alarm
messages, the definition of the Identifiers is as follows:
Question 2.4: Data Coding
The MEASURED-temperature values of a temperature sensor are measured in an interval of
0° C to 100° C with an accuracy of 0.1° C and sent to the central automation computer on demand. The SET-
temperature values of the climate control unit are provided in an interval of 5° C to 30° C with a resolution of
0.1° C. The smoke detector reports only the status (1 - smoke / 0 - no smoke). The MEASURED-light values
of a light sensor are measured in an interval of 0 lx to 10000 lx with an accuracy of 1 lx and sent to the central
automation computer on demand.
a) What is the minimum size of the required data part of the respective CAN messages in
b) Write down the respective data parts of the minimum and maximum values. You do not
need to apply any safety mechanisms.
Question 2.5: Safety Mechanisms
Write down the message identifier and the data part for the message that represents a MEASURED-light value
of 2727 in office No. 13 in the 4th floor. Apply CAN-specific safety mechanisms where necessary. Explain
briefly your result.
• MEASURED Temperature:
Interval from 0°C-100°C with accuracy 0.1°C => 1000 values
Coding of 1000 values => 10bit => 2 Data byte necessary
Coding: binary 0 = 00000000 00000000 = 0°C (without Stuffing-Bit)
binary 1000 = 00000011 11101000 = 100°C (without Stuffing-Bit)
– Interval from 5°C - 30°C with accuracy 0.1°C => 250 values
– Coding of 250 values => 8 bit => 1 Data byte necessary
– Coding: binary 0 = 00000000 = 5°C
– binary 250 = 11111010 = 30°C
• Fire alarm:
– 1 Status bit => 1 bit => 1 Data byte!
– 0_0_0_0_0_0_0_Status bit
– Interval from 0 – 10000 with accuracy 1 => 10000 values
– Coding of 10,000 values => 14 bit => 2 Data byte necessary
– Coding: binary 0 = 00000000 00000000 = 0°lx (without Stuffing-Bit)
– binary 10000 = 00100111 00010000 = 10000°lx (without Stuffing-Bit)
Exercise: Home Automation
In this question we deal with ambient intelligence, which is a new trend in controlling the
living environment with respect to the human users. The plan shown in figure 3.1 shows the
top view of a house. The house is equipped with a CAN-Bus which can be used to connect
various devices together. One of the Bus members is an industrial PC (IPC), which has the
responsibility of coordination. It can also be used for manual inputs to the system by the
users. Your task as an automation engineer is conception of a CAN-Bus network to fulfill
the following requirements:
• Blind control: The blind is connected to the CAN-Bus via the PLC of question 2. Here
only the state of the two sensors (wind, light) are being sent to the IPC in one message.
• Radiator: There are 5 radiators placed in each room (except for the corridor and
balcony). The radiator sends the current temperature of the room to the IPC and receives
the desired temperature via the IPC.
• Fire Detector/sprinkler: In order to fight back against fire, “Fire Detectors” (Sensor)
and “sprinklers” (actuator) for detecting the fire and extinguishing it are used in pairs.
Each room contains one pair of fire detector/sprinkler, summing up to a total amount of 6
pairs. As soon as a fire is detected (fire detector activated), an alarm message is sent to
the IPC. The IPC, then, sends an activation message to the corresponding sprinkler.
• Air-Conditioning system: Altogether, there are 3 AC systems in the house. One in the
bedroom, one in the working office, and one in the living room. It sends the current room
temperature to the IPC and receives the desired temperature via the IPC. Furthermore, it
can explicitly be turned on/off from the IPC.
• Security system: The security system is being considered here as a black box. Its only
relevant action for us is to send an alarm message to the IPC in case of security issues.
• Industrial-PC: The IPC implements a user interface for communication
between the CAN-Network and the user; it presents information about the
connected devices to the CAN-Bus and allows interaction with them.
Furthermore, if a message from one of the Bus members affects another Bus
member, this has to be sent first to the IPC and via the IPC to the
Question 3.1: CAN-Node architecture
Design a suitable bus topology (arrangement of the nodes) that realizes the requirements of
the house. Mention all your CAN nodes.
Question 3.2: CAN-Messages
Identify the messages that are necessary to communicate between different node. Write
down for each node which message(s) are being sent or received by it. Combine messages of
equal type to one message.
Question 3.3: Message-Identifiers
For the purpose of addressing various nodes on the CAN-Bus System, you have been given
an address range from 300(hex) to 400(hex). Determine the message identifiers for the
messages you have detected in 3.2. Take into account the realistic requirements on the
Question 3.4: Baud rate
The length of the CAN-Bus System is 40m. Calculate the maximum baud rate of the Bus.
Consider the signal propagation velocity is 0.2m/ns and electrical switching time 200ns.
Question 3.5: Extension to the security system
In case of an alarm from the security system, a picture taken from a camera installed in the
house will be sent to the IPC through the CAN-Bus system. The size of the picture is 340
kByte. Since the size of a standard CAN message is not sufficient for sending such a picture,
it must be separated into several parts. Create a concept to efficiently encode the data parts.
Consider the order of the part messages. Write down your concept and mention the required
number of CAN messages for transmitting one picture.
Exercise: Ship Accident
After the fatal Costa Concordia cruise ship accident, the junior engineers of the Jahangirnagar
University have received the task to construct a new cruising ship, Costa Concordia v2.
Employing automation engineering techniques and highly modern technologies, the new cruising
ship should provide her passengers more comfort and safety. Due to cost matters it must, first a small
prototype of the cruising ship should be constructed. If this fulfills the requirements, an order for
constructing the real cruising ship will be allotted. From now on the small prototype is meant,
whenever Costa Concordia v2 is mentioned.
The Costa Concordia v2 consists of 7 floors with 14 cabins and a restaurant on each (see figure 1.1).
The following decisions/requirements are to be considered in Costa Concordia v2:
• Each cabin and restaurant has a smoke detector, which in case of fire sends a signal to the central
control unit. This signal causes a chain of alarms to go off. For more simplicity the chain of
alarms is considered as one alarm. Furthermore, simultaneous occurrence of two or more alarms
from different cabins or restaurants is ignored.
• In each cabin and restaurant there is a temperature sensor and a temperature selector installed. The
temperature sensor sends the current temperature to the central control unit. Via the temperature selector a
person can set the desired temperature, manually. Once a person has set a desired temperature, it is sent to
the central control unit. Furthermore, the temperature can be set automatically by the central control unit,
regardless of the selector.
• On the outside body of the cruising ship (under the water) a modern sonar unit (Sound Navigation and
Ranging Unit) is installed. The sonar unit can detect the underwater reefs, which might be hazardous for the
cruising ship. In case such a reef is detected, a signal is sent to the central control unit.
• The central control unit should be able to access all the sensors/actors in each cabin or restaurant.
• In order to make the future passengers of Costa Concordia v2 always positively remember the junior
engineers of the University of Stuttgart a further comfort function should be included. Each cabin will have
a cool box, which will be filled with German beer. An integrated sensor in the cool box detects how many
beer bottles are left. If the amount of beer bottles is not equal to the maximal capacity of the cool box, a
signal is sent to the central control unit. This signal will from thereon be forwarded to the catering staff to
take care of. The catering staff is not considered here.
The distribution of the sensor and actor elements of the cabins and restaurants, shown in figure 1.1, is the same
for each floor.
Question 1.1: CAN Baud Rate
The length of the bus system is 1590 m. What is the maximal possible baud rate? Assume that the signal
propagation velocity is v line) and the delay time caused by the signal processing is 100 ns.
Question 1.2: CAN Message Length
The maximal message transmission time should be 1.5 ms. How big is the maximal message size allowed to
Question 1.3: CAN Identifier
Each transmitted message should include the type of the message, the floor number and the cabin number.
Design an identification coding, which fulfills the above mentioned requirements. How would you choose your
coding? Provide an example for each type of message.
The measured temperature values of the temperature sensors are measured in an interval of 0°C to 100°C with
an accuracy of 0.1° and can be sent to the central control unit on demand. The desired temperature values,
given via the temperature selectors, are provided in an interval of 5°C to 30°C with a resolution of 0.5°C. The
smoke detectors, sonar unit and cool boxes send only the status (1 -smoke / 0 - no smoke), (1 - reef detected /
0- no reef detected) and (1 cool box full- / 0 – cool box not full).
a) What is the minimum size of the required data part of each CAN message type in bits and bytes? Justify
b) Write down, in binary form, for each type of message the data field corresponding to the start value of the
message and the end value of that message. E.g. for the type of message “desired temperature” the binary
forms of the CAN messages 5°C and 30°C are requested.
· Write down only those bytes, which are required for each data field.
· Ignore any CAN specific safety mechanisms.
Question 1.5: CAN Message Examples
Write down the message identifier and the data part for the message that represents the
measured temperature value of 25.6° C of the cabin number 14 on the 7th floor and the
measured temperature value of 12.8° C of the cabin number 1 on the 1th floor. Write your
answer in binary as it will appear on the bus. Apply CAN-specific safety mechanisms where
Question 1.6: CAN Arbitration
The two temperature messages of the question 1.5 are put simultaneously on the bus. Which
message receives the bus access? Justify your answer. Sketch the arbitration process and the
sending behavior of each CAN node. What appears on the bus?