# Embedded Control Systems Design/Field busses

* The Wikibook of
* Embedded Control Systems Design
This chapter looks at the inter-system communication components that occur in the embedded motion systems this book is focusing on.
* Serial lines
* Controller Area Network (CAN)
* Profibus
* Realtime ethernet (RTnet, EtherCat, ProfiNet...)
* Devicenet
* Inter-Integrated Circuit (I2C)
* Serial Peripheral Interface (SPI)
* Firewire

## Description

A field bus is a part of a system which provides the communication between several components in that system (for example an actuator or a sensor). A bus is a cable with an interface on the two ends . A bus system is a collective noun for all buses, this means that there is a distinguish between:
* Factory buses (or a factory network)
* CPU buses
* Field busses

### Factory buses

A factory bus supports the management. The data of consequence for planning, logistic, quality, etc. will be sent over this network. A factory bus has been developed especially for the connection between several computers (for example: PCL, VME, etc.).

### CPU buses

See the chapter about processors

### Field buses

Three communication types exist for field buses, namely serial, parallel and wireless buses. The difference between serial and parallel field buses is principally the quantity of data that can be sent in one cycle. For a serial bus the process of sending data is one bit at one time. This is in contrast to parallel communications, where all the bits of each symbol are sent together. Wireless field busses are nowadays still in development. Because of this, the use of wireless field buses is limited in control systems.

## Why not use the same network everywhere?

Networks such as TCP/IP and Novell have already been on the market for a long time. Much software has been developed for it, and the paediatrics diseases are already solved. Field buses are still “young” networks which are aimed, in contrast to standard networks, to transport small quantities of information. Field busses need less hardware than standard networks. Because of this, they can be incorporated in the smallest sensors and actuators. Field bus applications secure special requirements to the hardware, for example intrinsic safe, voltage supply over the network, very high protection against electric jamming, galvanic separation, control at several places, etc.

## OSI model

OSI model :
| | Data unit | Layer | Function |
| Application (Control systems) | Data | Application | Network process to application |
| Application (Control systems) | Data | Presentation | Data representation and encryption |
| Application (Control systems) | Data | Session | Interhost communication |
| Transport | Segments | Transport | End-to-end connections and reliability (TCP) |
| Transport | Packets | Network | Path determination and logical addressing (IP) |
| Transport | Frames | Data link | Physical addressing (MAC & LLC) |
| Transport | Bits | Physical | Media, signal and binary transmission |
The operation of the network program can be described by the OSI layer model. The OSI, or Open System Interconnection, model defines a network frame for implementing protocols in 7 layers. Control is passed from one layer to the next, starting at the application layer in one station, proceeding to the bottom layer, over the channel to the next station and back up the hierarchy.
In each of these layers there are certain rules. Two computer systems that want to make contact with each other, must keep themself to these rules. Otherwise there will be misunderstandings and the communication between both will go wrong.
Transport:

### Layer 1: Physical

In this layer is described which sort of cable (serial/parallel/wireless) with which bit rate is used. This layer conveys the bit stream through the network at the electrical and mechanical level. Fast Ethernet and RS232 are protocols with physical layer components.

### Layer 2: Data link

This layer fixes how and at which moment a message from a computer to another computer can be sent over the same cable. Also defining the addresses and the format of the messages belongs to the agreements of this layer. The data link layer is divided into two sub layers: The Media Access Control (MAC) layer and the Logical Link Control (LLC) layer. The MAC sub layer controls how a computer on the network gains access to the data and permission to transmit it. The LLC layer controls frame synchronization, flow control and error checking.

### Layer 3: Network

This layer provides switching and routing technologies, creating logical paths, known as virtual circuits for transmitting data from node to node. If several networks are put together it is necessary to make agreements: -How does the general addressing happen and on how is the route chosen that the message must follow?

### Layer 4: Transport

This layer provides transparent transfer of data between end-systems, or hosts, and is responsible for end-to-end error recovery and flow control. In this way we obtain a reliable network connection. It ensures complete data transfer.
Application (control systems):

### Layer 5: Session

This layer establishes, manages and terminates connections between applications. There are three kinds of sessions in the OSI-model: - ‘one way’: the information will be sent in one direction. - ‘two way simultaneously’: both participants can send and receive at the same time (full duplex). - ‘two ways alternate’: both sides can various send and receive (half duplex).

### Layer 6: Presentation

This layer provides independence of differences in data representation (e.g., encryption) by translating from application to network format, and vice versa (for example: from ASCII to EBCDIC).

### Layer 7: Application

This layer specifies which applications are available to the user. Everything at this layer is application specific. The user programs are situated in this layer with which you can read files on another computer, run a process, etc.

## Typical usages of field buses at the application levels

There are several typical usages of field buses, the differences are mainly in the way they handle information. The different types in control systems are:
* Remote I/O (central controllers, distributed sensors, machine tools with CAN I/O):
This type of field bus acts as a multiplexer. The data bits are offered to the network and further transported to the outputs elsewhere in the network.
* Master/slave (master controller, distributed slave controllers)
The master can send a task to the slave via the bus. The slave processes this task and gives an answer. Slaves can’t communicate mutually.
* Client/server :
A field bus with several masters. A client gives a task to the server. These will carry out the task first and answer afterwards. A station can be both client and server at the same time and so they can send several tasks at the same time.
* Consumer/producer:
A field bus with several masters where each consumer station is interested in a certain piece of data, while the producer station provides the information to the consumer that wants to subscribe to the producer data.

## Field bus protocol

The field bus interface encodes the commands or the state of an in- or output to digital information which is arranged for transport over the cable.

## Properties of field buses

* Short response time
* Large reliability
* Cheap wiring
* Open standards
* Simple protocols
* Low price per connection
Response time:
In real time: deterministic response time (for example CAN)
-very short response time: For the link PLC - periphery Examples: Profibus DP, CAN and Interbus-S.
-average response time: For the link PLC - supervision system Example: Profibus FMS
Wiring for field busses:
The trend is as follows:
* parallel -> serial -> wireless:
-previous coax (Ethernet cable)
-often RS485
advantages: cheap, easy to install
disadvantage: no high speeds
-also glass fiber
advantage: large distances possible
Open standard
-why:
To make communication possible between heterogeneous systems from different vendors that exists for different OSI layers
-Examples:
DIN 19245 (Profibus), IEEE 1118 (Bitbus) ISO/DIS 11519-1 AND ISO/DIS 11898 (CAN)
* field bus with layer 1 and layer 2
-protocols in hardware or software
-applicable in devices
-not arranged for link of heterogeneous devices
-Example: CAN
* field bus with layer 1, layer 2 and layer 7
-more complex protocols in software -arranged for link of heterogeneous apparatuses -Example: Profibus-FMS

## Topology

The construction of a network that is built by some field buses can take several physical forms. Such a form is called a topology of a network. Some examples of different topologies are:
* Star
* Line
* Tree
* Mono-master
* Multi-master

## Advantages of field buses

* Only a few cables necessary
* No problems with 4-20 mA conversion (direct communication with PLC or PC.)
* More intelligence possible in equipment
* Simple to extend without extra wiring
* Maintenance and jamming can be searched through the network
* Digital technique

## Disadvantages of field buses

* There is not yet a standardization of the user interface
* Sometimes you must contact several manufacturers for support when you have got a problem

## Aspects to consider when choosing a field bus

* The maximum bus length (see overview)
* Number of clients
* Data rate
* Topology
* Price
* The time (difficulty) to add/remove a client
* The maximum cycle time
* Compatibility between the different field buses
* Stability of the system
* Applicability for communication between controllers, PC’s, and/or intelligent equipment
* Availability of interface cards for PC’s
* Maximum number of repeaters
* Maximum number of nodes without using repeaters
* Maximum number of nodes with use of repeaters
* Maximum data in one message
* Maximum number of masters

## The most used different field buses

* Interbus
* Profibus
* CAN
* Ethernet
* EtherCAT
* AS-Interface
* DeviceNet

## Overview of the most used bus systems

Bus systems have been developed mostly to be used in a certain scope. In the table below an overview is given along with the specifications of the different bus systems.
| | Interbus | Profibus | CANopen | Ethernet | EtherCAT | AS-Interface | DeviceNET |
| bit rate | 500 kbit/s (Cu) 2 Mbit/s (fiberglass) | 9,6 / 19,2 / 93,75 / 187,5 and 500 kbit/s (FMS). DP like FMS but also supports 1,5 / 3 / 6 and 12 Mbit/s. PA supports only 31,25 kbit/s | 5kbit/s till 1Mbit/s | 10Base-2/5/T/F:10MBit/s 100Base-T/T4/TX/FX: 100 MBit/s | 10MByte/s | 167 kbit/s | 125kbit/s 250kbit/s 500kbit/s |
| bus length | 400 m 13 km (Cu) 80 km (fiberglass) | 100 m (12Mbit/s) 200 m (1,5Mbit/s) 400 m (500kbit/s) 1 km (187,5kbit/s) Maximum 10 km (Cu), more tan 90 km (fiber optic) | 40 m (1Mbit/s) 620 m (100kbit/s) 10 km (5kbit/s) | 10Base-2: 183m 10Base-5: 500m 10Base-T: 100m 10Base-F: 1000m 100Base-T/T4/TX: 100m 100Base-FX: -- | 10 m (E-bus) 100 m (2 Tln.) 2 km (fiberglass) | 100 m 300 m (repeater) | 100 m (500kbit/s) 250 m (250kbit/s) 500 m (100kbit/s) |
| Message size | 8 or 16 bit | 1 - 249 byte | 0 – 8 byte | | | 3 bit |
| safety-bus | INTERBUSsafety | ProfiSafe | CANopen-safety | Safe Ethernet | --- | ASi-Safety | DeviceNET safety |
| cycle time | 1 ms (1 I/O) linear up to 7,8 ms (1096 I/O) | after data rate and transfer 1ms (10Slaves/12Mbit/s) 2ms (10Slaves/1.5Mbit/s) 6ms (30Slaves/1.5Mbit/s) | Depending on : - transport speed - the range of data - communication type | --- | 12 μs (256 D-I/O) 50 μs (200 A-I/O) 350 μs (12000 D-I/O) | 500 μs 5 ms (31 Slaves) 10 ms(62 Slaves) | Depending on : - transport speed - the range of data - communication type |
| members | 256, 4096 I/O | maximal 126 | 124 | 100 pro Segment 1024 pro Network | 65535 | 31 (124 I / 124 O) 62 (248 I / 186 O) | 64 |
| Address allocation | automatic | coder | coder | 48-bit length | software | automatic | Software, coder |
| Topology | Ring, mono-master | Mono-/Multi-master, line | Multi-master, line | Star | Line, star, tree | Line, star, tree, mono-master | Multi-master |
| OSI layers covered | 1, 2 and 7 | 1, 2 and 7 | | 1, 2 | | | |
| Transport layer | RS485 | RS485 | | Ethernet specific | | | |
| Message destination (layer 3 & 4) | Point-to-point | Point-to-point, multicast and broadcast | | Point-to-point, multicast and broadcast | | | |
| Price | | | | | | | |
| Resistance against jitter | | | 120 Ohm | | | | |

## Further reading

* Wikibooks:Information technology bookshelf#Serial Communications
* Wikipedia:Serial Peripheral Interface Bus is a popular short-range bus (for chips on the same PCB).
* Wikipedia:Controller Area Network is a popular long-range bus