You are on page 1of 448

Industrial Automation

Automation Industrielle
Industrielle Automation

Reele industriale locale


7

Application

Presentation

Session

Transport

Network

Link

Physical

Titular curs: s.l. dr. ing. Nicoleta-Cristina G ITAN


cristinag@eed.usv.ro

2004 June, HK

Reele industriale locale


Durat :

14s pt mnix3 ore

Forma de examinare:

Examen semestrial

EPFL - Industrial Automation

2004 June, HK

3.3.1 OSI model

Cum se face notarea?

Nota la examen NF = 50%NL + 40%NE + 10%PC

NF

Nota Final

NE

Nota la Examen

NL

Nota la Laborator

PC

PrezenalaCurs

Examenulsedesf oar nscris.

Sedaubonusuridepn 10%pentruactivit isuplimentare(participarealaconcursuri,


conferinestudeneti,proiecte,etc.)

EPFL - Industrial Automation

2004 June, HK

3.3.1 OSI model

The OSI model

The Open System Interconnection (OSI) model is a standard way to


structure communication software that is applicable to any network.
was developed to structure telecommunication protocols in the 70
(Pouzin & Zimmermann)
standardized by CCITT and ISO as ISO / IEC 7498
all communication protocols (TCP/IP, Appletalk or DNA) can be mapped to the
OSI model.
is a model, not a standard protocol, but a suite of protocols with the same name
has been standardized by UIT / ISO / IEC for open systems data interconnection
(but with little success)
mapping of OSI to industrial communication requires some additions

EPFL - Industrial Automation

2004 June, HK

3.3.1 OSI model

OSI-Model (ISO/IEC standard 7498)

"Application"
protocols

"Transport"
protocols

Application

Presentation

Session

Transport

Network

Link

Physical

EPFL - Industrial Automation

2004 June, HK

All services directly called by the end user


(Mail, File Transfer,...) e.g. Telnet, SMTP
Definition and conversion of the data
formats (e.g. ASN 1)
Management of connections
(e.g. ISO 8326)
End-to-end flow control and error recovery
(e.g. TP4, TCP)
Routing, possibly segmenting
(e.g. IP, X25)
Error detection, Flow control and error recovery,
medium access (e.g. HDLC)
Coding, Modulation, Electrical and
mechanical coupling (e.g. RS485)

3.3.1 OSI model

OSI Model with two nodes

node 1

node 2

Application

Presentation

Session

Transport

Network

Link

Physical

Physical Medium

EPFL - Industrial Automation

2004 June, HK

3.3.1 OSI model

Repeater
500m
department A
workstations

Ethernet

To connect a workstation of
department A to the printer of
department B, the cable becomes too
long and the messages are corrupted.

server

The repeater restores signal


levels and synchronization.
It introduces a signal delay of
about 1..4 bits

repeater

printer
500m
department B

server
Physically, there is only one bus carrying
both departments traffic, only one node
may transmit at a time.

Ethernet
500m
EPFL - Industrial Automation

2004 June, HK

3.3.1 OSI model

OSI model with three nodes (bridge)


Node 1

bridge

Node 2

Application

Presentation

Session

Transport

Network

Link

Physical

physical medium (0)

physical medium (0)

e.g. Ethernet 100 MBit/s

e.g. ATM

The subnet on both sides of a bridge have:


the same frame format (except header),
the same address space (different addresses on both sides of the bridge)
the same link layer protocol (if link layer is connection-oriented)
Bridges filter the frames on the base of their link addresses
EPFL - Industrial Automation

2004 June, HK

3.3.1 OSI model

Bridge example
In this example, most traffic is directed from the workstations to the department
server, there is little cross-department traffic
department A
workstations

Ethernet

department A
server

Ethernet 1

repeater

printer

Bridge

printer
department B

department B

server

Ethernet

server

Ethernet 2

There is only one Ethernet which carries


both departments traffic
EPFL - Industrial Automation

server

2004 June, HK

There are now two Ethernets and only the


cross-department traffic burdens both busses
9

3.3.1 OSI model

Networking with bridges

LAN
port

port

port

port

port

Spanning-tree-Algorithmen
avoid loops and ensures
redundancy

port
LAN

port

port

LAN

EPFL - Industrial Automation

2004 June, HK

port

LAN

port

port
LAN

10

3.3.1 OSI model

Switch

nodes

queues

crossbarswitch
(or bus)

full-duplex

a switch is an extension of a hub that allows store-and-forward.

EPFL - Industrial Automation

2004 June, HK

11

3.3.1 OSI model

OSI Model with three nodes (router)


Node 1

Router

Node 2

Application

Presentation

Session

Transport

Network

Link

Physical

physical medium (0)

The router routes the frames on the base of their network address.
The subnets may have different link layer protocols
Frames in transit are handled in the network layer .

EPFL - Industrial Automation

2004 June, HK

12

3.3.1 OSI model

Repeater, Bridge, Router, Gateway: Topography


applicationdependent

gateway

backbone (e.g. FDDI)

different subnetworks,
same address space
same transport protocol,
segmentation/reassembly
routers are initially opaque

end-to-end
transport protocol

connects different speed,


different medium access
by store-and-forward
same frames and addresses
initially transparent in both ways.
can limit traffic by filtering

Router
Bridge

same speed
same medium
access
same frames

Repeater

segment
subnet (LAN, bus, extended link)
devices (nodes, stations) have different physical addresses
devices (nodes, stations) have different link addresses

EPFL - Industrial Automation

2004 June, HK

13

3.3.1 OSI model

Repeaters, Bridges, Routers and Gateways: OSI model

intelligent linking devices can


do all three functions
(if the data rate is the same)
gateway
Apl

Apl

Apl

Pre

Pre

Pre

Pre

Ses

Ses

Ses

Ses

Trp

Trp

Trp

TCP

Net

IP
LLC

bridge
( "switch")

Trp

(store-and-forward)

Net
MAC

MAC

MIS

Layer 1

MDS

MDS

10 Mbit/s coax

Layer 3

Net

repeater
or hub

LLC

Layer 2

MDS

Apl

router

LLC

LLC

LLC

MAC

MAC

MAC

MAC

MIS

MIS

MIS

MIS

MIS

MDS

MDS

MDS

MDS

MDS

10 Mbit/s fibre

100 Mbit/s Ethernet

RPC

MDS

Fibre
ATM 155 Mbit/s

EPFL - Industrial Automation

2004 June, HK

14

3.3.1 OSI model

application

presentation

session

network

link

physical

transport

To which level does a frame element belong ?

link phy

LLC

repeater, hub

destination

source

LLC

bridge

final

origin
router

NC

TRP

SES

PRE

Network Control

preamble

APL

CRC

ED

application
(gateway)

A frame is structured according to the ISO model

EPFL - Industrial Automation

2004 June, HK

15

3.3.1 OSI model

Encapsulation
INFO

User information
TrpCrt

Transport header
NetAdr

Network address
Link control
(Acknowledge, Token,etc.)

LinkCrt
LinkAdr

Link-address

size

Error detection

CRC

Flag

Frame

Flag

Signal
Each layer introduces its own header and overhead
EPFL - Industrial Automation

2004 June, HK

16

3.3.1 OSI model

Example: OSI-Stack frame structure


IEEE 802.4
token bus

ISO 8802
logical link control

MAC_header
13
MA. frame control

MA. destination
address
(6 octets)

ISO 8473
connectionless network control

LNK_hdr

NET_header

>48

L_destination SAP

ISO 8073
class 4 transport control

TRP_header
5

Protocol Identifier (81)

L_source SAP

Header Length

L_PDU

Version/Protocol ID (01)

LSAP = DSAP
FE = network layer
18 = Mini-MAP Object
Dictionary Client
19 = Network Management
00 = own link layer

Lifetime
SP MS ER

DT/ER Type

PDU Segment Length

L_PDU = UI, XID, TEST

Checksum

DATA

LI
TPDU

FIXED
PART

(CDT)

Destination
Reference
N(S)

ET

DATA (DT) TPDU


(normal format)
address length

IDP
(initial
domain
part)

AFI = 49

Destination Address
(18 octets)

MA. source
address
(6 octets)
ADDRESS
PART

Source Address
(18 octets)
Segmentation
(0 or 6 octets)
Options
(priority = 3 octets)

IDI, Area ID
(7 octets)
PSI
Physical Address
(6 octets)

LSAP = FE

DSP
(domain
specific
part)

NSAP = 00

EPFL - Industrial Automation

2004 June, HK

17

3.3.1 OSI model

Protocol Data Units and Service Data Units

N+1- Layer

ServiceData Unit
(SDU)

N - Layer

Protocol
Data Unit
(PDU)

(n)-layer entity

(n)-layer entity
Protocol
Data Unit
(PDU)

ServiceData Unit
(SDU)

N-1 Layer

(n+1)-layer entity

(n+1)-layer entity

(n-1)-layer entity

(n-1)-layer entity

Layer N provides services to Layer N+1;


Layer N relies on services of Layer n-1

EPFL - Industrial Automation

2004 June, HK

18

3.3.1 OSI model

Service Access Points

user of
service N

user of
service N

Service Access Points (SAP)

functions in layer N

Service Access Points (SAP)

provider of service (N-1)


provider of service (N)
Service Access Points represent the interface to a service (name, address, pointer,...)
EPFL - Industrial Automation

2004 June, HK

19

3.3.1 OSI model

Address and SAPs in a device

ASAP
z.B. TCP/IP

z.B. ISO 8073

Transport

TSAP

Transport-SAP

NSAP

Network-SAP
(not Network address)

LSAP

Logical Address or link address

ISO 8473

Network

ISO-stack

Link

Physical

EPFL - Industrial Automation

PhSAP

2004 June, HK

Application
(z.B. File transfer, Email,....)

20

Physical Address

3.3.1 OSI model

Procedure call conventions in ISO

Service User

Service Provider
(Network Transmission)

Service User

request
indication

confirm
(local)
confirm
(network)
confirm
(user)

response

time

EPFL - Industrial Automation

2004 June, HK

21

3.3.1 OSI model

OSI implementation
OSI should be considered as a model, not as an implementation guide
The idea of independent layers is a useful as a way of thinking, not the best implementation.
Even if many claim to have "OSI"-conformant implementation, it cannot be proven.
IEC published about 300 standards which form the "OSI" stack, e.g.:
ISO/IEC 8473-2:1996 Information technology -- Protocol for providing
the connectionless-mode network service -ISO/IEC 8073:1997 Information technology -- Open Systems
Interconnection -- Protocol for providing the connection-mode transport service
ISO/IEC 8327-1:1996 Information technology -- Open Systems
Interconnection -- Connection-oriented Session protocol: Protocol specification
ISO/IEC 8649:1996 Information technology -- Open Systems
Interconnection -- Service definition for the Association Control Service Element
ISO 8571-2:1988 Information processing systems -- Open Systems
Interconnection -- File Transfer, Access and Management

Former implementations, which implemented each layer by an independent process,


caused the general belief that OSI is slow and bulky.
OSI stack has not been able to establish itself against TCP/IP
EPFL - Industrial Automation

2004 June, HK

22

3.3.1 OSI model

OSI protocols in industry


Theory:
ISO-OSI standards should be used since they reduce specification and
conformance testing work and commercial components exist
Reality:
the OSI model is a general telecommunication framework implementations considers feasibility and economics.
the overhead of the ISO-OSI protocols (8073/8074) is not bearable
with low data rates under real-time conditions.
the OSI-conformant software is too complex:
simple devices like door control or air-condition have limited power.

the OSI model does not consider transmission of real-time data


Therefore:
industrial busses use for real-time data a fast response access and
for messages a simplified OSI communication stack
the devices must be plug compatible: there are practically no options.
Communication is greatly simplified by adhering to conventions
negotiating parameters at run-time is a waste in closed applications.
EPFL - Industrial Automation

2004 June, HK

23

3.3.1 OSI model

TCP / IP structure

FTP SMTP

Files

TCP

HTTP

routing
ATM

Applications

Transport

UDP

IP
Ethernet

SNMP

modem

ICMP

Network

radio

Link & Physical

The TCP/IP stack is lighter than the OSI stack, but has about the same complexity

TCP/IP was implemented and used before being standardized.


Internet gave TCP/IP a decisive push

EPFL - Industrial Automation

2004 June, HK

24

3.3.1 OSI model

Conclusions
The OSI model is the reference for all industrial communication
Even when some layers are skipped, the concepts are generally implemented
Real-Time extensions to OSI are under consideration
TCP/IP however installs itself as a competitor to the OSI suite, although some efforts are
made to integrate it into the OSI model
TCP/IP/UDP is becoming the backbone for all non-time critical industrial communication
TCP/IP/UDP is quickly displacing proprietary protocols.
Next generation TCP/IP (V6) is very much like the OSI standards.
Many embedded controllers come with an integrated Ethernet controller, an the
corresponding real-time operating system kernel offers TCP/IP services
Like OSI, TCP protocols have delays counted in tens or hundred milliseconds,
often unpredictable especially in case of disturbances.
For further reading: Motorola Digital Data Communication Guide

EPFL - Industrial Automation

2004 June, HK

25

3.3.1 OSI model

Reele industriale locale


Titular curs: s.l. dr. ing. Nicoleta-Cristina GITAN
cristinag@eed.usv.ro

EPFL - Industrial Automation

2004 June, HK

3.3.2 Field busses - Physical Layer

Industrial Automation
Automation Industrielle
Industrielle Automation

3.3.2

3. Industrial Communication Systems


Physical Layer

2004 June, HK

Physical Layer Outline


1. Layering
2. Topology
3. Physical media
4. Electric Signal coupling
5. Optical Fibres
6. Modulation
7. Synchronization
8. Encoding

9. Repeaters

EPFL - Industrial Automation

2004 June, HK

3.3.2 Field busses - Physical Layer

To probe further

Henri Nussbaumer, Tlinformatique 1, Presses polytechniques romandes


Fred Halsall, Data Communications, Computer Networks and Open Systems, Addison-Wesley
B. Sklar , Digital Communications, Prentice Hall, Englewood Cliffs, 1988
EIA Standard RS-485

EPFL - Industrial Automation

2004 June, HK

3.3.2 Field busses - Physical Layer

OSI Model - location of the physical level

Application
protocols

Application

Presentation

Session

Transport

Network

Link

Physical

Transport
protocols

EPFL - Industrial Automation

2004 June, HK

All services directly called by the end user


(Mail, File Transfer,...)
Definition and conversion of the
data formats (e.g. ASN 1)
Management of connections
(e.g. ISO 8326)
End-to-end flow control and error recovery
(z.B. TP4, TCP)
Routing, possibly segmenting
(e.g. IP, X25)
Error detection, Flow control and error recovery,
medium access (e.g. HDLC)
Coding, Modulation, Electrical and
mechanical coupling (e.g. V24)

3.3.2 Field busses - Physical Layer

Subdivisions of the physical layer

medium-independent signalling

medium-dependent signalling

Physical
Layer

electrical / optical
specifications

2004 June, HK

applies to one media


(e.g. optical fibres)
applies to one media type
(e.g. 200m optical fibres)

mechanical
specifications

EPFL - Industrial Automation

same for different media


(e.g. coax, fibre, RS485)

defines the mechanical interface


(e.g. connector type and pin-out)

3.3.2 Field busses - Physical Layer

Concepts relevant to the physical layer

Topology

Ring, Bus, Point-to-point

Mechanical

Connector, Pin-out, Cable, Assembly

Medium

signals, transfer rate, levels

Channels

Half-duplex, full-duplex, broadcast

Control

Send, Receive, Collision

Modulation

Baseband, Carrier band, Broadband

Coding/Decoding

Binary, NRZ, Manchester,..

Synchronisation

Bit, Character, Frame

Flow Control

Handshake

Interface

Binary bit, Collision detection [multiple access]


Signal quality supervision, redundancy control

EPFL - Industrial Automation

2004 June, HK

3.3.2 Field busses - Physical Layer

Example: RS-232 - Mechanical-Electrical Standard


Originally developed for modem communication, now serial port in IBM-PCs

Topology:
Data
Terminal
Equipment

DTE

DCE

Terminal

Telephone
lines

DCE

Data Communication
Equipment (Modem)

Cabling rules

Modem

Data
Terminal
Equipment

Computer

modem eliminator
extension

Tip: Do not use


Modem cables,
only Extension
cables

DTE
2

computer

extension

terminal

cable

cable

2 3

Mechanical
1

25

Electrical:

EPFL - Industrial Automation

transmitter

receiver

+12V

+3V

-12V

-3V

2004 June, HK

"0" Space On
"1" Mark Off

3.3.2 Field busses - Physical Layer

Physical Layer Outline


1. Layering
2. Topology
3. Physical media
4. Electric Signal coupling
5. Optical Fibers
6. Modulation
7. Synchronization
8. Encoding

9. Repeaters

EPFL - Industrial Automation

2004 June, HK

3.3.2 Field busses - Physical Layer

Topology: Simplex, Half and Full Duplex


Link (Point -To-Point)
Full-duplex

Sender/
Receiver
Sender/
Receiver

Sender/
Receiver
Half-duplex

Sender/
Receiver

Examples:
RS232

Examples:
RS485

Bus (Half-Duplex, except when using Carrier Frequency over multiple bands)
Terminator

Examples:
Ethernet, Profibus

Ring (Half-Duplex, except double ring)

Examples:
SERCOS, Interbus-S
consists of point-to-point links

EPFL - Industrial Automation

2004 June, HK

10

3.3.2 Field busses - Physical Layer

Bus topologies
party-line
Terminator
Terminator

advantage: little wiring


star

disadvantages: easy to disrupt, high attenuation and reflections, no fibres

hub

point-to-point

advantage: robust point-to-point links, can use fibres

disadvantage: requires hub, more wiring

free topology

radio

repeater

a bus is a broadcast medium (delays come from propagation and repeaters)


EPFL - Industrial Automation

2004 June, HK

11

3.3.2 Field busses - Physical Layer

Repeater
500m
department A
workstations

Ethernet

server

To connect a workstation of
department A to the printer of
department B, the cable becomes
too long and the messages are
corrupted.

repeater

500m

printer
department B

server

Ethernet
500m
EPFL - Industrial Automation

2004 June, HK

12

3.3.2 Field busses - Physical Layer

Bus: repeaters and hubs

higher-level hub

repeaters

point-to-point
link

EPFL - Industrial Automation

partyline

partyline

2004 June, HK

13

3.3.2 Field busses - Physical Layer

Party-line (bus) and star wiring


d = average distance between devices
PLC

wiring length = d n,
increases linearly with number of devices

Up to 32 devices
(more with repeaters)
I/O

hub

I/O

I/O

I/O

wiring length = d n n / 2 2
increases with square of number of devices

PLC

Up to 16 devices
per hub
does it fit into the
wiring tray ?

EPFL - Industrial Automation

I/O

I/O

2004 June, HK

I/O

14

I/O

I/O

I/O

3.3.2 Field busses - Physical Layer

Rings

classical ring

ring in floor wiring


wiring
cabinet

EPFL - Industrial Automation

2004 June, HK

15

3.3.2 Field busses - Physical Layer

Physical Layer Outline


1. Layering
2. Topology
3. Physical media
4. Electric Signal coupling
5. Optical Fibres
6. Modulation
7. Synchronization
8. Encoding

9. Repeaters

EPFL - Industrial Automation

2004 June, HK

16

3.3.2 Field busses - Physical Layer

Media (bandwidth x distance)


Transfer rate (Mbit/s)
optical fibres

coaxial cables

twisted wire

700m

single mode

2058

516

207

5.5

very good

multimode

196

49

20

6.5

very good

0.5

6.5

very good

50 Ohm

20

1.2

good

75 Ohm TV 1/2"

12

2.5

1.0

2.2

good

93-100 Ohm

15

0.8

2.5

good

twinax

0.9

0.2

3.5

very good

individually
shielded (STP)

0.35

0.15

.5

very good

group shielding (UTP)

0.3

0.1

0.2

0.1

0.05

0.2

good (crosstalk)
regular (foreign)
good (crosstalk)
bad (foreign)

Power line carrier

0.05

0.01

very bad

Radio

bad

Infrared

0.02

good

ultrasound

0.01

bad

Telephone cable
others

Electromagnetic
Compatibility

200m

plastic

2000m

Costs
(Fr/m)

the bandwidth x distance is an important quality factor of a medium


EPFL - Industrial Automation

2004 June, HK

17

3.3.2 Field busses - Physical Layer

Physical Layer Outline


1. Layering
2. Topology
3. Physical media
4. Electric Signal coupling
5. Optical Fibres
6. Modulation
7. Synchronization
8. Encoding

9. Repeaters

EPFL - Industrial Automation

2004 June, HK

18

3.3.2 Field busses - Physical Layer

Electrical: Transmission media

Zw = 50 ... 100

Cost
efficient
core
Coaxial
cablewiring:
twisted pair (without
dielectric

screen

inflexible, costly,
low losses
10 MHz..100 MHz

shield

Shielded twisted wire


(Twinax)

Zw = 85..120

Shield

Unshielded twisted wire


Uncommitted wiring
(e.g. powerline com.)

EPFL - Industrial Automation

twisting compensates disturbances

very cheap,
sensible to perturbations

Telephone
numerous branches, not terminated,
except possibly at one place

2004 June, HK

flexible, cheap,
medium attenuation
~1 MHz..12 MHz

19

very cheap,
very high losses and disturbances,
very low speed (~10 ..100 kbit/s)

3.3.2 Field busses - Physical Layer

Electrical: Twisted wire pair


characteristic impedance most used in industrial environment:
120 Ohm for bus, 150 Ohm for point-to-point.
Standard from the telecommunication world: ISO/IEC 11801
Cat 5 (class D): 100 MHz, RJ 45 connector
Cat 6 (class E): 200 MHz, RJ 45 connector
Cat 7 (class F): 600 MHz, in development
These are only for point-to-point links ! (no busses)

EPFL - Industrial Automation

2004 June, HK

20

3.3.2 Field busses - Physical Layer

Electrical: What limits transmission distance ?

All parameters

Characteristic impedance
Attenuation
Linear resistance
Linear capacitance
Cross talk
Common-mode
Shield protection

are frequency-dependent

Signal reflection on discontinuities (branches, connectors) cause self-distortions

EPFL - Industrial Automation

2004 June, HK

21

3.3.2 Field busses - Physical Layer

Consider in cables

lumped line model


L'

L'

R'

C'

Zw =

G'

L'

L'

R'

C'

L'

R'

G'

specific inductance (H/m)


specific resistance (/m)

C'

G'

R'

C'

G'

specific capacitance (F/m)


specific conductance (S/m)

C'

EPFL - Industrial Automation

2004 June, HK

22

3.3.2 Field busses - Physical Layer

Electrical: Signal Coupling Types


Resistive

direct coupling
driver on line without galvanic coupling
collision possible when several transmitters active

Wired-OR combination possible


cheap as long as no galvanic separation is required (opto-coupler)
good efficiency

Inductive

transformer-coupling
galvanic separation
good electromagnetic compatibility (filter)
retro-action free
good efficiency
signal may not contain DC-components
bandwidth limited

Capacitive

EPFL - Industrial Automation

capacitor as coupler
weak galvanic separation
signal may not contain DC components
cheap
not efficient

2004 June, HK

23

3.3.2 Field busses - Physical Layer

Electrical: Resistive (direct) coupling

Unipolar, unbalanced

Bipolar, unbalanced

+ Us
Coax

Ru

+ Us

Zw

Zw
Rd
- Us

Open Collector

Ut

(unbalanced)

Ut = 5 V (e.g.)
Rt

Rt

Bus line, characteristic impedance = Zw

Terminator and
Pull-up resistor

wired-OR behaviour
(Low wins over High
Out

In

device

EPFL - Industrial Automation

2004 June, HK

Out

In

device

24

Out

In

device

3.3.2 Field busses - Physical Layer

Electrical: Balanced Transmission

+Ub
Zw

100

symmetrical line (Twisted Wire Pair)

Shield

Rt

UA

Differential amplifier
(OpAmp)

UB

(Data Ground)

Used for twisted wire pairs (e.g. RS422, RS485)

EPFL - Industrial Automation

2004 June, HK

25

3.3.2 Field busses - Physical Layer

Electrical: RS-485 as an example of balanced transmission

TxS RxS

TxS RxS

TxS RxS

100
Terminator

stub

A
tap
120

120

Data-GND
B

Zw 120, C' 100 pF/m


segment length

multiple transmitter
allowed

Short-circuit limitation
needed

Ishort < 250 mA


EPFL - Industrial Automation

2004 June, HK

26

3.3.2 Field busses - Physical Layer

Electrical: RS-485 Distance x Baudrate product

distance
10000
5000

limited by copper resistance


100 /km -> 6dB loss limit

2000
1200

1000
500
limited by
frequency-dependent
losses 20 dB/decade

200
100
50
20
12
10KBd

EPFL - Industrial Automation

100KBd

2004 June, HK

1 MBd

27

10 MBd

Baudrate

3.3.2 Field busses - Physical Layer

Electrical: Transformer Coupling

Sender/Receiver
Sender/Receiver

Isolation transformer

isolation resistors
shield
Twisted Wire Pair

Source: Appletalk manual

EPFL - Industrial Automation

2004 June, HK

28

3.3.2 Field busses - Physical Layer

Electrical: MIL 1553 as an example of transformer coupling


Direct Coupling
(short stub: 0.3 m)

Double-Transformer
(long stub: 0.3 .. 6m)
Sender/Receiver

Isolation transformer

short
stub

long
stub
Isolation transformer

isolation resistors

isolation resistors

shield

shield

Twisted Wire Pair


Extract from: MIL-STD-1553

EPFL - Industrial Automation

2004 June, HK

29

3.3.2 Field busses - Physical Layer

Electrical: Free topology wiring

voltage
source

terminator

Free topology is used to connect scattered devices which are usually line-powered.
Main application: building wiring

EPFL - Industrial Automation

2004 June, HK

30

3.3.2 Field busses - Physical Layer

Electrical: Power Line Carrier technology

HF-trap

220V

A free-topology medium using the power lines as carrier.


Capacitive or inductive coupling, sometimes over shield
Problems with disturbances, switches, transformers, HF-traps, EMC,..

EPFL - Industrial Automation

2004 June, HK

31

3.3.2 Field busses - Physical Layer

Electrical: Mechanical Connecting devices to an electrical bus

short stub

thread-through

double-connector

junction box

2 connectors
live insertion
installation ?

1 connector
live insertion
(costly) junction box

stub

1 connector
live insertion

EPFL - Industrial Automation

2 connectors
no live insertion

2004 June, HK

32

3.3.2 Field busses - Physical Layer

Practical solution to live insertion

EPFL - Industrial Automation

2004 June, HK

33

3.3.2 Field busses - Physical Layer

Electrical: Connectors

Field busses require at the same time low cost and robust connectors.
The cheapest connectors come from the automobile industry (Faston clips)
and from telephony (RJ11, RJ 45)
The most popular connector is the sub-D 9 (the IBM PC's serial port),
which exists in diverse rugged versions.
Also popular are Weidmann and Phoenix connectors.

EPFL - Industrial Automation

2004 June, HK

34

3.3.2 Field busses - Physical Layer

Electrical: Water-proof Connectors

EPFL - Industrial Automation

2004 June, HK

35

3.3.2 Field busses - Physical Layer

Physical Layer Outline


1. Layering
2. Topology
3. Physical media
4. Electric Signal coupling
5. Optical Fibers
6. Modulation
7. Synchronization
8. Encoding

9. Repeaters

EPFL - Industrial Automation

2004 June, HK

36

3.3.2 Field busses - Physical Layer

Fiber: Principle

3 components:
transmitter

fibre

GaAs
LED

receiver
PIN
fotodiode

Is
different refraction
coefficients

Transmitter, cable and receiver must be "tuned" to the same wavelength

EPFL - Industrial Automation

2004 June, HK

37

3.3.2 Field busses - Physical Layer

Fiber: Types
Multimodefibre

Monomode fibre

N(r)
50 m

Refraction profile

Cross-section

50 - 300 m

50 - 100 m

2-10 m

total reflection

gradual reflection

waveguide

3 dB/km
0,6 dB/km
1 GHzkm

2,3 dB/km
0,4 dB/km
100 GHzkm

Core
Clad

Longitudinal section

(red) 650nm
800nm
(infra-red) 1300nm

10 dB/km
5dB/km
20MHzkm

HCS (Hard-Clad Silica)


200 m, < 500m

EPFL - Industrial Automation

2004 June, HK

50 or 62.5 m LAN fibre

38

telecom - costly

3.3.2 Field busses - Physical Layer

Fibre: Use

Type

POF

HCS/PCF

GOF

Material
distance
Usage
Connector
Cost
aging
bending
bandwidth

plastic
70m
local networking
simple
cheap
poor
very good
poor

glass / plastic
400m
remote networking

glass
1km
telephone
high-precision
medium
good
poor
very good

EPFL - Industrial Automation

2004 June, HK

39

precision
medium
very good
good
good

3.3.2 Field busses - Physical Layer

Fiber: building an optical bus


n% coupling losses

Passive coupler
n% coupling losses

Passive star coupler

Active star coupler

1
2
3
4
5
6

Fused zone

electrical segment (wired-or)

1
2
3
4
5
6
opto-electrical
transceiver

fibre pair

EPFL - Industrial Automation

2004 June, HK

40

3.3.2 Field busses - Physical Layer

Fiber: building an optical ring and bridging


spring
prism

example of
solution

Powered

unpowered

Double ring

EPFL - Industrial Automation

2004 June, HK

41

3.3.2 Field busses - Physical Layer

Fiber: advantages
1 ) high bandwidth and data rate (400 MHz x km)
2 ) small, frequency-insensitive attenuation (ca. 3 dB/km)
3 ) cover long distances without a repeater
4 ) immune against electromagnetic disturbances (great for electrical substations)

5 ) galvanic separation and potential-free operation (great for large current environment)
6 ) tamper free
7 ) may be used in explosive environments (chemical, mining)
8 ) low cable weight (100 kg/km) and diameter, flexible, small cable duct costs
9 ) low cost cable
10) standardized

EPFL - Industrial Automation

2004 June, HK

42

3.3.2 Field busses - Physical Layer

Fiber: Why are fibres so little used ?


1) In process control, propagation time is more important than data rate
2) Attenuation is not important for most distances used in factories (200m)
3) Coaxial cables provide a sufficiently high immunity
4) Reliability of optical senders and connections is insufficient (MTTF 1/power).

5) Galvanic isolation can be achieved with coaxial cables and twisted pairs through opto-couplers
6) Tapping is not a problem in industrial plants
7) Optical busses using (cheap) passive components are limited to a few branches (16)
8) In explosive environments, the power requirement of the optical components hurts.
9) Installation of optical fibres is costly due to splicing
10) Topology is restricted by the star coupler (hub) or the ring structure

EPFL - Industrial Automation

2004 June, HK

43

3.3.2 Field busses - Physical Layer

Radio Transmission

Radio had the reputation to be slow, highly disturbed and range limited.
Mobile radio (GSM, DECT) is able to carry only limited rate of data (9.6 kbit/s) at high costs,
distance being limited only by ground station coverage.
IEEE 802.11 standards developed for computer peripherals e.g. Apples AirPort
allow short-range (200m) transmission at 11 Mbit/s in the 2.4 GHz band with 100mW.
Bluetooth allow low-cost, low power (1 mW) links in the same 2.4 GHz band, at 1 Mbit/s
Modulation uses amplitude, phase and multiple frequencies (see next Section)
Higher-layer protocols (WAP, ) are tailored to packet radio communication.
bluetooth module

Radio == mobile -> power source (batteries) and low-power technologies.


EPFL - Industrial Automation

2004 June, HK

44

3.3.2 Field busses - Physical Layer

Wireless Field busses

but: who changes the batteries ?

EPFL - Industrial Automation

2004 June, HK

45

3.3.2 Field busses - Physical Layer

Redundancy at the physical layer


Party-Line

Terminator
Terminator

decentralized wiring

Star topology

both cables can run in the same conduct where


common mode failure acceptable

star couplers should be separately powered


star coupler A

star coupler B

centralized wiring

EPFL - Industrial Automation

cable come together at each device

2004 June, HK

46

3.3.2 Field busses - Physical Layer

Physical Layer Outline


1. Layering
2. Topology
3. Physical media
4. Electric Signal coupling
5. Optical Fibers
6. Modulation
7. Synchronization
8. Encoding

9. Repeaters

EPFL - Industrial Automation

2004 June, HK

47

3.3.2 Field busses - Physical Layer

Modulation

Base band

Carrier band

Backward
channel
Broadband

EPFL - Industrial Automation

2004 June, HK

5-108
MHz

48

Forwardchannel
162-400
MHz

Frequency

3.3.2 Field busses - Physical Layer

Physical Layer Outline


1. Layering
2. Topology
3. Physical media
4. Electric Signal coupling
5. Optical Fibres
6. Modulation
7. Synchronization
8. Encoding

9. Repeaters

EPFL - Industrial Automation

2004 June, HK

49

3.3.2 Field busses - Physical Layer

Synchronisation: where does it take place ?

Example: Frame synchronisation using Manchester violation symbols

Data

1 1 0 1 0 0 0 1

Clock
+NRZ Data
+Framing

= Line Signal

Start-sync
(Violation)

EPFL - Industrial Automation

2004 June, HK

Data in Manchester II

50

Stop-sync
(Violation)

3.3.2 Field busses - Physical Layer

Frames: Synchronization
character-synchronous
(e.g. bisync)

Data

A B C SYN D E F G
SYN

Signal

SYN SYN

Byte-stuffing

flag

SYN
flag

bit-synchronous
(e.g. HDLC)

Data

11 100 0 11 111

110

011 1 1 1

flag

Signal

0 1 1 1 1 1 10 1 1 1 0 0 0 1 1 1 1 1 0 1 1 0

0 1 1 1 1 1 0 0 0 1 1 1 1 11 0

Bit-stuffing
delimiter
(e.g. IEC 61158)
Signal
"1" "1" "0" "0" "1" "1"

Delimiter (not Manchester)

EPFL - Industrial Automation

2004 June, HK

51

Manchester symbols

3.3.2 Field busses - Physical Layer

Physical Layer Outline


1. Layering
2. Topology
3. Physical media
4. Electric Signal coupling
5. Optical Fibers
6. Modulation
7. Synchronization
8. Encoding

9. Repeaters

EPFL - Industrial Automation

2004 June, HK

52

3.3.2 Field busses - Physical Layer

Encoding: popular DC-free encodings


user
1

Manchester

Differential Manchester

Ethernet, FIP
IEC 61158,
MVB, MIL 1553

LON

High-density
diskettes

Miller (MFM)

Xerxes

FlexRay

memoryless*: decoding does not depend on history


EPFL - Industrial Automation

2004 June, HK

53

3.3.2 Field busses - Physical Layer

Encoding: DC-free coding for transformer coupling

DC-free encoding is a necessary, but not sufficient condition

The drivers must be carefully balanced (positive and negative excursion |+U| = |-U|)

effect of unbalance
(magnetic discharge)

EPFL - Industrial Automation

2004 June, HK

54

3.3.2 Field busses - Physical Layer

Decoding base-band signals

Dynamic: 10 dB
line

unipolar signal

histeresis

idle level

Uh+
Uh-

time
active

RxS

Dynamic: 18 dB

idle

bipolar signal
Uh+
Uh-

Dynamic: 32 dB
Daten
1 0 1 0 1 0 1 0 1 N+ N- 1 0 N- N+ 0 1 1 1
Preamble

Delimiter

Dynamic: 38 dB

EPFL - Industrial Automation

2004 June, HK

55

3.3.2 Field busses - Physical Layer

Encoding: Physical frame of IEC 61158-2


1

N+

N-

N-

N+

N+

N-

+U
Preamble (variable) 0V
-U
Start delimiter (8 bit times)

Payload (variable length)


N- N+

End delimiter (8 bit times)


preamble

1
defines end of frame

start

EPFL - Industrial Automation

2004 June, HK

payload

56

end delimiter

3.3.2 Field busses - Physical Layer

Encodings: Multi-frequency

power

"SB1"
"0" "1"

unused

"SB2" "SB3"
"0" "1" "0" "1"

"SB4"
"0" "1"

"SB5"
"0" "1"

"SB6"
"SB7"
"0" "1" "0" "1"

"SB8"
"0" "1"

22,5 kHz 31,5 kHz 40,5 kHz 49,5 kHz 58,5 kHz 67,5 kHz 76,5 kHz 85,5 kHz
27 kHz 36
45 kHz
54
63
72
81 kHz
90 kHz
kHz
kHz
kHz
kHz

frequency

Best use of spectrum


Adaptive scheme (frequency-hopping, avoid disturbed frequencies, overcome bursts)

EMC considerations

EPFL - Industrial Automation

2004 June, HK

57

3.3.2 Field busses - Physical Layer

Bandwidth and Manchester Encoding


Delimiter

" 0 " " 1 "" 0 " " 0 " " 1 " " 1 " " 0 "

3-step

2-step

3-step
EPFL - Industrial Automation

2004 June, HK

58

3.3.2 Field busses - Physical Layer

Encoding: qualities

1) Self-clocking, Explicit clocking or asynchronous

2) Spectral efficiency

3) Efficiency: relation of bit rate to Baudrate

4) Decoding ease

5) Integrity
6) Polarity

EPFL - Industrial Automation

2004 June, HK

59

3.3.2 Field busses - Physical Layer

Physical Layer Outline


1. Layering
2. Topology
3. Physical media
4. Electric Signal coupling
5. Optical Fibres
6. Modulation
7. Synchronization
8. Encoding

9. Repeaters

EPFL - Industrial Automation

2004 June, HK

60

3.3.2 Field busses - Physical Layer

Repeater

node

node

node

repeater

EPFL - Industrial Automation

2004 June, HK

encoder

decoder

(RS 485)

node

node

decoder

encoder

segment 1

node

61

segment 2
(transformer-coupled)

3.3.2 Field busses - Physical Layer

Repeater and time skew

Repeaters introduce an impredictable delay in the transmission since they need


some time to synchronize on the incoming signal and resolve collisions.

EPFL - Industrial Automation

2004 June, HK

62

3.3.2 Field busses - Physical Layer

Star coupler (hub)

opto-electrical
transceiver

wired-or electrical media

to other device
or star coupler

to other device
or star coupler

fibre pair

device

EPFL - Industrial Automation

device

2004 June, HK

device

device

63

3.3.2 Field busses - Physical Layer

Reele industriale locale


Titular curs: s.l. dr. ing. Nicoleta-Cristina GITAN
cristinag@eed.usv.ro

EPFL - Industrial Automation

2004 June, HK

3.3.3 Field busses - Link Layer

Industrial Automation
Automation Industrielle
Industrielle Automation

3.

Industrial Communication Systems


Link Layer and Medium Access

2004 June, HK

Link Layer Outline


Link Layer in the OSI model
Stacks
HDLC as example
Frame sub-layer
Error detection
Error correction
Medium Access control
Quality Criteria
Single Master
Rings
Ethernet
Collision with winner
Token Passing
Comparison
Logical Link Control
Connection-Oriented and connectionless
Error recovery
Flow control
HDLC
EPFL - Industrial Automation

2004 June, HK

3.3.3 Field busses - Link Layer

Link Layer function


The link layer implements the protocols used to communicate within the same subnet.
(subnet: same medium access, same bit rate)

- but different media may be interconnected by (bit-wise) repeaters


Tasks of the link layer:
1) Data integrity
2) Medium Access
3) Logical Link Control
4) Link Layer Management

EPFL - Industrial Automation

2004 June, HK

3.3.3 Field busses - Link Layer

Link Layer in the OSI Model


Functions
Network

Application
bridge control

Presentation

Session

Logical Link
Control
(LLC)

Medium Access
Control
(MAC)

Transport

Network

Link

Physical

Frame

store-and-forward
address discovery
connection establishment
flow Control
error handling
medium allocation
(master redundancy)

addressing
frame format
integrity control

Physical
Signaling
Physical
Medium

Subnet (Bus or Ring)

EPFL - Industrial Automation

2004 June, HK

3.3.3 Field busses - Link Layer

OSI model with two nodes

Node 1

Node 2

Application

Presentation

Session

Transport

Network

Link

Physical

Physical Medium

EPFL - Industrial Automation

2004 June, HK

3.3.3 Field busses - Link Layer

OSI model with repeater (physical layer connection)


Node 1

Application

repeater

Node 2

Presentation

Session

Transport

Network

Link

Physical

1
physical medium (0)

physical medium (1)

The two segments on each side of a repeater form a single subnet, identified by
same speed (medium, modulation may differ)
same frame format (except fringe effects)
same medium access
same address space (transparent on both side of the repeater)
Repeaters introduce a delay in the order of a few bit time.
EPFL - Industrial Automation

2004 June, HK

3.3.3 Field busses - Link Layer

OSI model with three nodes (bridge): link layer connection


Node 1

bridge

Node 2

Application

Presentation

Session

Transport

Network

Link

Physical

physical medium (0)

physical medium (0)

The subnet on both sides of a bridge have:


the same frame format (except header),
the same address space (different addresses on both sides of the bridge)
the same link layer protocol (if link layer is connection-oriented)
Bridges filter the frames on the base of their link addresses
EPFL - Industrial Automation

2004 June, HK

3.3.3 Field busses - Link Layer

Link Layer Outline


Link Layer in the OSI model
Stacks
HDLC as example
Frame sub-layer
Error detection
Error correction
Medium Access control
Quality Criteria
Single Master
Rings
Ethernet
Collision with winner
Token Passing
Comparison
Logical Link Control
Connection-Oriented and connectionless
Error recovery
Flow control
HDLC
EPFL - Industrial Automation

2004 June, HK

3.3.3 Field busses - Link Layer

HDLC as example of a link layer protocol


Standard

HDLC (High Level Data Link)

Function

Reliable transmission between devices of a subnet

Objects

Frame structure according to ISO 3309.

Flag
01111110

Address

Control

8 bit

8 bit

Data

CRC

(n 8)

16 bit

Integrity Check

16-bit Cyclic Redundancy Check

Medium Access

Master/Slave, (with slave initiative possible)

Error recovery

positive acknowledgement and retry

Flow control

7-frames (127 frames) credit system

EPFL - Industrial Automation

2004 June, HK

10

Flag
01111110

3.3.3 Field busses - Link Layer

HDLC Topology
Secondary
(Terminal)

Secondary
(Terminal)

full-duplex
or
half-duplex
medium

Secondary
(Terminal)

Secondary
(Terminal)

Secondary
(Terminal)

Secondary
(Terminal)

Primary
(Mainframe)

Secondary
(Terminal)

Secondary
(Terminal)

The Primary (Master) is connected with the Secondaries (Slaves) over a


multidrop bus (e.g. RS 485) or over point-to-point lines
HDLC bases physically on a bus, but is logically a star network
EPFL - Industrial Automation

2004 June, HK

11

3.3.3 Field busses - Link Layer

HDLC - Full- and Half duplex operation


Full-Duplex

Command/Data

Requester/
Primary

Responder/
Secondary
Acknowledgement
Sender/Receiver

Sender/Receiver
Command/Acknowledgement

Requester/
Primary

Responder/
Secondary
Data
Sender/Receiver

Sender/Receiver

Half-Duplex
Requester/
Primary

Responder/
Secondary

Sender/Receiver
Sender/Receiver
The Primary switches the Secondary to send mode, the Secondary sends until it returns control

EPFL - Industrial Automation

2004 June, HK

12

3.3.3 Field busses - Link Layer

Link Layer Outline


Link Layer in the OSI model
Stacks
HDLC as example
Frame sub-layer
Error detection
Error correction
Medium Access control
Quality Criteria
Single Master
Rings
Ethernet
Collision with winner
Token Passing
Comparison
Logical Link Control
Connection-Oriented and connectionless
Error recovery
Flow control
HDLC
EPFL - Industrial Automation

2004 June, HK

13

3.3.3 Field busses - Link Layer

Frame Sublayer
Network

Network

Logical Link
Control
(LLC)

Logical Link
Control
(LLC)

Medium Access
Control
(MAC)

Medium Access
Control
(MAC)

Frame

Frame

Physical
Signaling

Physical
Signaling

Physical
Medium

Physical
Medium

sublayer

The frame layer is concerned with the correct frame format and contents,
with (practically) no consideration of the medium or speed.
EPFL - Industrial Automation

2004 June, HK

14

3.3.3 Field busses - Link Layer

Error Handling
Industry imposes high standards regarding data integrity
Transmission quality is not very high , but consequences are severe.
Errors not detected at the link layer are very difficult to catch at higher layers
Error detection
Frame data are protected by redundant information, such as parity bits,checksum,
CRC (Cyclic Redundancy Check)
Error recovery
Except when medium is very poor (Power Line Carrier, radio), error correcting
codes are not used.
Erroneous frames are ignored, the potential sender of the error is not informed
(the address of the sender is unknown if the frame is damaged)
The sender is informed of the lack of response when it does not receive the
expected acknowledgement within a time-out.
Definition of the time-out has a strong impact on real-time behaviour
EPFL - Industrial Automation

2004 June, HK

15

3.3.3 Field busses - Link Layer

Link Layer Outline


Link Layer in the OSI model
Stacks
HDLC as example
Frame sub-layer
Error detection
Error correction
Medium Access control
Quality Criteria
Single Master
Rings
Ethernet
Collision with winner
Token Passing
Comparison
Logical Link Control
Connection-Oriented and connectionless
Error recovery
Flow control
HDLC
EPFL - Industrial Automation

2004 June, HK

16

3.3.3 Field busses - Link Layer

Error Detection
Error detection require redundancy in the transmitted information.
Signal redundancy: Signal quality supervision (squelch, jamming,..)
Coding redundancy: Timing-violations in decoder
Data redundancy: error detecting code
k data bits

r check bits

n-bit codeword = (n,k) block code


Quality criteria
Code efficiency: CEF = k/n

Hamming-Distance
Residual Error Rate

EPFL - Industrial Automation

2004 June, HK

17

3.3.3 Field busses - Link Layer

Hamming Distance
The Hamming Distance between two words is the number of bits in which they differ:
Example

Word 1: 01100110
Word 2: 00101001

-> Hamming-Distance = 5

The Hamming Distance of a code is the minimum number of bits which need to be tilted
in a valid codeword to produce another valid (but erroneous) codeword
Number of detectable bit errors:

ZD = HD 1

Numbers of correctable bit errors:

ZC = (HD1)/2

Example: HD = 4: ZD = 3, ZC = 1
00000

00001

code word

00111

2004 June, HK

2nd error
18

01111
code word

m=4
1st error

EPFL - Industrial Automation

00011

3rd error

4th error

3.3.3 Field busses - Link Layer

Hamming distance in 3 dimensions: parity


1

par

D7

D6

D5

D4

D3

D2

D1

D0

Odd parity: sum Modulo-2 of all "1" in the codeword (including the parity bit) is odd
The parity bit is the last transmitted bit (->LSB first, a matter of convention)

illegal
111
110

101
100

legal

011
010

001
000

EPFL - Industrial Automation

2004 June, HK

19

3.3.3 Field busses - Link Layer

Error Detection through CRC


(Cyclic Redundancy Check)

Principle

The data stream consists of a sequence of n "0" and "1"


This sequence is treated as a polynomial of degree n.
This polynomial is divided by a Generator polynomial of degree m, m<n,
The rest of this division (which has (m-1) bits) is appended to the data stream.
data (dividend)
/
GP(divisor)
rest
At reception, the data stream is divided through the same generator-polynomial,
the rest of that division should be identical to the transmitted rest.
To simplify the receiver circuit, the rest is also divided by the generator polynomial,
the result should then be a known constant if the transmission was error-free.
The Generator Polynomial is chosen according to the expected disturbances:
burst or scattered errors, and the channel error model (bit inversion)
EPFL - Industrial Automation

2004 June, HK

20

3.3.3 Field busses - Link Layer

Residual Error Rate, Parity


Rer = Probability of occurrence of an undetected error in spite of an error detecting
code as a function of the bit error probability

Example:
Hamming Distance

Bit error probability

E
r

Residual error rate

R
er

= 1 - (1 - E )
r
no error

n E (1 - E )
r
r

n -1

exactly one error

Rer for two word length:


E = 10
r
E = 10
r

-5

n = 9 bit

R = 72 1 0
er

-5

n = 513 bit

R = 2.6 1 0
er

EPFL - Industrial Automation

2004 June, HK

21

-1 0

-5

quite efficient.
quite useless ...

3.3.3 Field busses - Link Layer

Integrity classes and bit error rate


The standard IEC 61870-5 (protocols for remote control of substations)
defines several classes of robustness in function of the bit error rate (bad/good bits)
Residual Error Rate
10 0
10 - 2
10 - 4
10 - 6
10 - 8
10 -10

10 -12
Integrity class I3
10 -14
10 -16
10 -5

EPFL - Industrial Automation

10 -4

2004 June, HK

10 -3
22

10 -2

10 -1

10 0

Bit error rate

3.3.3 Field busses - Link Layer

Synchronization Errors
HDLC-frame
flag

flag

01111110

any data

disturbance

HDLC-frame with error

FCS

01111110

Frame Check Sequence


(CRC)

flag

flag
"FCS"

01111110

1 Chance in 65536,
that the random data
form a correct CRC

FCS

01111110

false
flag

01111110

discarded

precisely 1111110 is the most frequent sequence in a


random bit stream because of bit-stuffing.

A single error can falsify a frame -> HD = 1


It is uninteresting how likely this case is, the fact is, that it can occur.
Because of this bug, HDLC when used in industry require additional error checks.

The synchronization should have a higher Hamming distance than the data itself.
EPFL - Industrial Automation

2004 June, HK

23

3.3.3 Field busses - Link Layer

Link Layer Outline


Link Layer in the OSI model
Stacks
HDLC as example
Frame sub-layer
Error detection
Error correction
Medium Access control
Quality Criteria
Single Master
Rings
Ethernet
Collision with winner
Token Passing
Comparison
Logical Link Control
Connection-Oriented and connectionless
Error recovery
Flow control
HDLC
EPFL - Industrial Automation

2004 June, HK

24

3.3.3 Field busses - Link Layer

Error Correcting Codes


Error correcting codes are used where the probability of disturbances is high (e.g. power
line communication) and the time to retransmit is long (e.g. space probe near Jupiter).
In industry, error correcting codes are normally directly embedded in the physical layer,
e.g. as part of a multitone transmission (ADSL) or of a radio protocol (Bluetooth).
Error correction necessarily decreases the data integrity, i.e. the probability of accepting
wrong data, since the redundancy of correction is taken from the code redundancy.
It is much more important to reject erroneous data (low residual error rate) than to try to
correct transmission.
However, when the medium is very bad (radio), error correction is necessary to
transmit even short messages.
Assigning bits for error detection and correction is a tradeoff between integrity and
availability.

EPFL - Industrial Automation

2004 June, HK

25

3.3.3 Field busses - Link Layer

Link Layer Outline


Link Layer in the OSI model
Stacks
HDLC as example
Frame sub-layer
Error detection
Error correction
Medium Access control
Quality Criteria
Single Master
Rings
Ethernet
Collision with winner
Token Passing
Comparison
Logical Link Control
Connection-Oriented and connectionless
Error recovery
Flow control
HDLC
EPFL - Industrial Automation

2004 June, HK

26

3.3.3 Field busses - Link Layer

Medium Access Control


Network

Network

Network

Logical Link
Control
(LLC)

Logical Link
Control
(LLC)

Logical Link
Control
(LLC)

Medium Access
Control
(MAC)

Medium Access
Control
(MAC)

Medium Access
Control
(MAC)

Frame

Frame

Frame

Physical
Signaling

Physical
Signaling

Physical
Signaling

Physical
Medium

Physical
Medium

Physical
Medium

Medium Access Control gives the right to send in a multi-master bus


EPFL - Industrial Automation

2004 June, HK

27

3.3.3 Field busses - Link Layer

Link Layer Outline


Link Layer in the OSI model
Stacks
HDLC as example
Frame sub-layer
Error detection
Error correction
Medium Access control
Quality Criteria
Single Master
Rings
Ethernet
Collision with winner
Token Passing
Comparison
Logical Link Control
Connection-Oriented and connectionless
Error recovery
Flow control
HDLC
EPFL - Industrial Automation

2004 June, HK

28

3.3.3 Field busses - Link Layer

Medium Access Control - quality criteria

Fairness

all requesters will eventually be allowed to transmit

Determinism

all requesters will be allowed to transmit within a finite time

Timelyness

all requesters will be allowed to transmit within a certain


time, depending on their priority.

Robustness

communication errors or the permanent failure of


one component does not prevent the others to
access the medium.

EPFL - Industrial Automation

2004 June, HK

29

3.3.3 Field busses - Link Layer

Link Layer Outline


Link Layer in the OSI model
Stacks
HDLC as example
Frame sub-layer
Error detection
Error correction
Medium Access control
Quality Criteria
Single Master
Rings
Ethernet
Collision with winner
Token Passing
Comparison
Logical Link Control
Connection-Oriented and connectionless
Error recovery
Flow control
HDLC
EPFL - Industrial Automation

2004 June, HK

30

3.3.3 Field busses - Link Layer

MAC single master (e.g. Profibus DP)

slave

slave

slave

bus
master
devices
(slaves)
bus

command reply
read

command ack
write with ack

command
write no ack

command
reply
read & write

time

the bus master allocates time slots to each slave


it may assign priorities (or no priority: round-robin, all are treated equally)
the master may be the source and the destination of data
+ strictly deterministic, complete and flexible control
- polling takes time, since devices which have nothing to transmit must be polled
- the master has little knowledge about data importance
improvement: look-at-me (short poll frame allowing slave to request poll of a longer frame)
= "slave initiative" used in Profibus DP
EPFL - Industrial Automation

2004 June, HK

31

3.3.3 Field busses - Link Layer

Link Layer Outline


Link Layer in the OSI model
Stacks
HDLC as example
Frame sub-layer
Error detection
Error correction
Medium Access control
Quality Criteria
Single Master
Rings
Ethernet
Collision with winner
Token Passing
Comparison
Logical Link Control
Connection-Oriented and connectionless
Error recovery
Flow control
HDLC
EPFL - Industrial Automation

2004 June, HK

32

3.3.3 Field busses - Link Layer

MAC Rings (1): register insertion principle

Devices are connected by point-to-point links (no bus!), there is one sender per segment.
The operation is similar to a large shift register.
The master sends a long frame with the output data to the first device in the ring.
Each device reads the data intended for it, inserts its data instead and
passes the frame to the next device.
The last device gives the frame back to the master.
data

time

output

application memory

devices

input

master

output
shift register

input

data

EPFL - Industrial Automation

output

input

time

2004 June, HK

33

3.3.3 Field busses - Link Layer

MAC Rings (2): pros and cons


Two major field busses use the ring topology, Interbus-S and SERCOS
and the register-insertion principle described.

the position of the bit in the frame corresponds to the position of the device in the ring,
there are no device addresses - easy to use, but prone to misconfiguration.
each device introduces a delay at least equal to a few bits

+ deterministic access, good usage of capacity, addresses are given by device sequence
on the ring, only point-to-point links
- long delays (some s per device)

EPFL - Industrial Automation

2004 June, HK

34

3.3.3 Field busses - Link Layer

Link Layer Outline


Link Layer in the OSI model
Stacks
HDLC as example
Frame sub-layer
Error detection
Error correction
Medium Access control
Quality Criteria
Single Master
Rings
Ethernet
Collision with winner
Token Passing
Comparison
Logical Link Control
Connection-Oriented and connectionless
Error recovery
Flow control
HDLC
EPFL - Industrial Automation

2004 June, HK

35

3.3.3 Field busses - Link Layer

MAC Ethernet (1): CSMA-CD principle (stochastic)

Principle

Every station sends as it pleases


if no acknowledgement comes, it retransmit

improvement 1: do not send when the medium is occupied


improvement 2: be aware that you are jammed
improvement 3: retry after a random time,
doubled after each collision, max 15 times

(pure Aloha)
(Carrier Sense)
(Collision Detection)
(Binary Backoff)

Advantage:

Arbitration does not depend on number or on address of the stations

Drawback:

No upper limit to the waiting time, mean waiting time depends


on the arrival rate of frames and on their average length.
The medium access is not deterministic,
but for light traffic (<1%) there is no noticeable delay.

EPFL - Industrial Automation

2004 June, HK

36

3.3.3 Field busses - Link Layer

MAC Ethernet (2): collision conditions


repeater

preamble

= 8 Bytes

(2 x 7.5 s/km+ 2
repeaters)

Tpd

minimum
frame size

= 64 Bytes

collision
Station A must
detect that its
frame collided
while it is still
transmitting its
frame

time

Station B started
transmission just
before receiving
As frame.
it nevertheless
transmits its
header completely

Ethernet minimum frame size = 64 Bytes, or 51,2 s @ 10 Mbit/s


at 10 Mbit/s, limits radius to about 2500 m
at 100Mbit/s, limits radius to about 250 m

EPFL - Industrial Automation

2004 June, HK

37

3.3.3 Field busses - Link Layer

MAC Ethernet (3): propagation conditions and bus diameter

The frame must be long enough to allow all stations to detect a collision while the frame is
being transmitted.

2 x Tpd = 2 x propagation time (@10Mbit/s Ethernet: 51,2 s)

500 m

500 m
Collisions can only be detected reliably when the frame size is longer than the
propagation delay -> padding to a minimum size (512 bits = 64 Bytes)

The "diameter" of the network is limited to 2,5 km


Since a station which expects a collision must wait one slot time before transmitting,
the maximum frame throughput on Ethernet is limited by the slot time.

EPFL - Industrial Automation

2004 June, HK

38

3.3.3 Field busses - Link Layer

MAC Ethernet (4): collision probability and simultaneous transmitters


After the end of a frame, a transmitter chooses a slot at random from a fixed number of slots
0

previous frame

utilisation 100%

time

frame size

0.8

4096
1024

0.6

512
48

0.4

0.2

0
1

10

32

64

128

256

number of transmitters

Ethernet is not efficient for small frame size and large number of simultaneous transmitters
Ethernet is considered to enter overload when reaching 10%-18% load
EPFL - Industrial Automation

2004 June, HK

39

3.3.3 Field busses - Link Layer

MAC Ethernet (5): when collisions can't be detected


It is not always possible to detect collisions.
LON uses a p-persistent MAC with 16-slot collision avoidance (p = 1/16)
1

probability of loosing a packet

source: P. Koopman, CMU

0.9
0.8
0.7

without collision detection

0.6
0.5
0.4
0.3

with collision detection

0.2
0.1
0

number of simultaneous transmitters


1

10

11

12

13

14

15

16

A small number of simultaneous transmitters causes a high probability loss of a packet .


LON can retry up to 255 times: probability of lost message is low, but delay is long
EPFL - Industrial Automation

2004 June, HK

40

3.3.3 Field busses - Link Layer

Link Layer Outline


Link Layer in the OSI model
Stacks
HDLC as example
Frame sub-layer
Error detection
Error correction
Medium Access control
Quality Criteria
Single Master
Rings
Ethernet
Collision with winner
Token Passing
Comparison
Logical Link Control
Connection-Oriented and connectionless
Error recovery
Flow control
HDLC
EPFL - Industrial Automation

2004 June, HK

41

3.3.3 Field busses - Link Layer

MAC CAN (1): Deterministic Arbitration

The CAN fieldbus uses media with a dominant and a recessive state
When several transmitters are simultaneously active, the dominant state wins
over the recessive state if there is at least one transmitter sending the dominant state
(dominant is Low in open collector, "Bright" in an optical fiber, or a collision on a medium that
allows collisions).

Such a medium allows a bit-wise "Wired-OR" operation


Example:
open-collector:
Terminator and
pull-up resistor

device 1
Out

Jam

device 2
In

Out

XOR

Jam

device 3
In

XOR

Out

Jam

XOR

device 4
In

Out

Jam

XOR

In

Terminator and
pull-up resistor
Ut

Ut

Rt

Rt

Bus line

A device is capable to know if the signal it puts on the line is disturbed (XOR).
EPFL - Industrial Automation

2004 June, HK

42

3.3.3 Field busses - Link Layer

MAC CAN (2): Collision with Winner

Also known as "Urn" or "binary bisection" method


Each station has a different identity (in this example: 4 bit ID)
Each station listens before sending and can detect collisions
Competing stations start transmitting at the same time (1st bit is a SYNC-sign)
Each station begins its transmission with its identity, bit by bit
In case of collision, "1" wins over "0" ("1" = Low, bright, dominant).
A station, whose "0" bit was transformed into a 1" retires immediately
The winning station has not been disturbed and transmits.
Loosing stations await the end of the ongoing transmission to start again.
slot time

Station 10 (wins)

Station 06

(1)

(1)

(0)

Station 09

(1)

Bus signal

Advantage: deterministic arbitration (assumes fairness), good behavior under load


Drawback: the size of the unique ID defines arbitration time,
transmission delay defines slot time -> 40m @ 1 Mbit/s, 400m @ 100 kbit/s
EPFL - Industrial Automation

2004 June, HK

43

3.3.3 Field busses - Link Layer

MAC CAN (3): Deterministic Arbitration

Advantage: deterministic arbitration (assumes fairness, I.e. a device only transmits


again when all losers could), good behavior under load.

Drawback: the slot time (one bit time) must be long enough so that every station can
detect if it has been disturbed - I.e. twice as long as the propagation time
from one end of the bus to the other ( signal speed = 5 ns / m).

Therefore, the bit rate is dependent on the bus extension:


40m @ 1 Mbit/s, 400m @ 100 kbit/s
the size of the unique ID defines arbitration time.

EPFL - Industrial Automation

2004 June, HK

44

3.3.3 Field busses - Link Layer

Link Layer Outline


Link Layer in the OSI model
Stacks
HDLC as example
Frame sub-layer
Error detection
Error correction
Medium Access control
Quality Criteria
Single Master
Rings
Ethernet
Collision with winner
Token Passing
Comparison
Logical Link Control
Connection-Oriented and connectionless
Error recovery
Flow control
HDLC
EPFL - Industrial Automation

2004 June, HK

45

3.3.3 Field busses - Link Layer

MAC Profibus (1): Token principle


z.B.: Token Bus (IEEE 803.4), Profibus (IEC 61158)

All stations form a logical ring

Each station knows the next station in the ring (and the overnext)
Each station delegates the right to send to the next station in the ring,
(in the form of a token frame or as an appendix to a data frame).
Variants

Token with Priority (back to the station with the highest priority)

Problems:

Loss or duplication of token, initialization


do not confuse with token ring !

EPFL - Industrial Automation

2004 June, HK

46

3.3.3 Field busses - Link Layer

MAC Profibus (2): Token passing


logical ring

station address

12

25

31

AS

AS

AS

current bus
master

active stations
(potential masters)

passive stations
(slaves)

Active Stations (AS) can become master if they own the token,
for a limited duration (one frame only).
After that time, the master passes the token to a station with a higher address
or, if it has the highest address, to the station with the lowest address.
A station must send at least one frame (data or token) when it gets its turn.
EPFL - Industrial Automation

2004 June, HK

47

3.3.3 Field busses - Link Layer

MAC Profibus (3): Token passing algorithm

Each station holds a List of Active Stations (LAS)


GAP
1

AS AS
Active
Station

PS
Previous
Station

TS

10 11

NS

This
Station

12 13 14 15

..

30 32

AS

Next
Overnext
Station Station

When the current master has no more data to send, or when its turn expires, it
sends a token frame to the Next Station (NS) in the ring.
NS acknowledges reception of the token.
If the master does not receive an acknowledgement for two consecutive trials,
the master removes the station from the LAS and declares the overnext
active station (OS) as NS.

This station accepts the token only if it receives it twice.


The master tests at regular intervals with a "Request FDL-Status" for the
presence of further stations in the gap between itself and NS.
EPFL - Industrial Automation

2004 June, HK

48

3.3.3 Field busses - Link Layer

MAC Profibus (4): Token initialization


A starting station listens to the bus before trying to send.
If it senses traffic, a station records the token frames and builds a list of active stations (LAS).
In particular, it observes if a station with the same name as itself already exists.
When a master checks the gap, the station will receive a token offer.
If a station does not register any traffic during a certain time, it sends a token frame to itself.
It sends the first token frame to itself, to let other starting stations register it.
Only when it detects no other station does a station begin with a systematic
poll of all addresses, to build the LAS.

EPFL - Industrial Automation

2004 June, HK

49

3.3.3 Field busses - Link Layer

Link Layer Outline


Link Layer in the OSI model
Stacks
HDLC as example
Frame sub-layer
Error detection
Error correction
Medium Access control
Quality Criteria
Single Master
Rings
Ethernet
Collision with winner
Token Passing
Comparison
Logical Link Control
Connection-Oriented and connectionless
Error recovery
Flow control
HDLC
EPFL - Industrial Automation

2004 June, HK

50

3.3.3 Field busses - Link Layer

Comparison of Medium Access Control Methods

deterministic

stochastic

pessimistic

optimistic
carrier sense

central master

collision detection

collision with winner

p-persistent collision

EPFL - Industrial Automation

2004 June, HK

token passing

51

3.3.3 Field busses - Link Layer

Link Layer Outline


Link Layer in the OSI model
Stacks
HDLC as example
Frame sub-layer
Error detection
Error correction
Medium Access control
Quality Criteria
Single Master
Rings
Ethernet
Collision with winner
Token Passing
Comparison
Logical Link Control
Connection-Oriented and connectionless
Error recovery
Flow control
HDLC
EPFL - Industrial Automation

2004 June, HK

52

3.3.3 Field busses - Link Layer

Logical Link Control Sublayer


Network

Network

Logical Link
Control
(LLC)

Logical Link
Control
(LLC)

Medium Access
Control
(MAC)

Medium Access
Control
(MAC)

Frame

Frame

Physical
Signaling

Physical
Signaling

Physical
Medium

Physical
Medium

Two Link services:

EPFL - Industrial Automation

- unacknowledged connectionless service and


- connection oriented services
2004 June, HK

53

3.3.3 Field busses - Link Layer

Connection-Oriented and Connection-Less communication


these considerations apply to all levels of the OSI model

Connectionless mode
(Datagram letter)
Each packet (Datagram) contains all
information needed to forward it to its final
destination over the network, including the
path back to the sender.
The network assumes no responsibility for
the ordering of packets and does not try to
recover damaged datagrams.
The burden of flow control and error recovery
is shifted to the application.

Semantic of CL-transmission

Connection-Oriented mode
(Virtual Circuit telephone)
A connection is first established between sender
and receiver.
Information packets are identified by their
connection identifier and by their sequence
number within that connection.
The network cares for opening and closing
connections and ensures that packets are received
in same order as they are sent, recovering lost
packets and controlling the flow.
Applications see the network as a reliable pipe.
Connection is closed after use (and reused)

Semantic of CO-transmission
Open_Channel(Node, Task, Channel_Nr);
Send_Message (Channel_Nr, Msg1);
Send_Message (Channel_Nr, Msg2);
Close(Channel_Nr);

Send_Packet (source, destination, Packet1);


Send_Packet (source, destination, Packet2);

Msg1 will be received before Msg2, sequence is maintained.

EPFL - Industrial Automation

2004 June, HK

54

3.3.3 Field busses - Link Layer

Connection-Oriented Link Service

Task: Flow Control and Error Recovery


Connection establishment and disconnection
Send and receive frames
Flow Control (Buffer control)
Retry in case of error
service
user

service
provider

service
user

REQUEST

INDICATION
RESPONSE
CONFIRM

EPFL - Industrial Automation

2004 June, HK

55

3.3.3 Field busses - Link Layer

Flow Control
( = synchronization at the link layer)
"Adapt the speed of the sender to that of the receiver"
Methods
Use Acknowledgements: do not send until an acknowledgement is received
(acknowledgements have two purposes: error recovery and flow control !)

Credit: the receiver indicates how many frames it can accept


(sliding Window protocol). Improvement: variable window size.
Explicit braking (CTRL-S/ CRTL-Q)
Lower Window
Edge
packets

Upper Window
Edge
8

10

11

12

time
sent and
acknowledged
EPFL - Industrial Automation

sent but not yet


acknowledged

2004 June, HK

56

can be sent

may not
be sent

3.3.3 Field busses - Link Layer

Simple transfer with window size = 1


Producer

LLC

Bus

Consumer

LLC

Connection
tm_message.req

Connect Request
connect
timer

nm_connect.ind

nm_connect.cnf

Connect Confirm
Transfer
DATA (0)

ack
timer

ACK (1)
DATA (1)

alive
time-out

ACK (2)
DATA ( last)
nm_message_ind
ACK (last)
Disconnection

nm_message.cnf

late
acks

time

Every packet takes at least two propagation times


EPFL - Industrial Automation

2004 June, HK

57

3.3.3 Field busses - Link Layer

Error Recovery
General rule: Erroneous information frames are repeated
(error correcting codes belong to physical layer)
1) In cyclic transmission, information is not explicitly repeated in case of loss,
the receiver will receive a fresh information in the next cycle.
A freshness control supervises the age of the data in case communication ceases.
2) In event-driven transmission, no information may be lost, a repetition is explicit:
a) The sender of information frames expects acknowledgement of the
receiver, indicating which information it received.
b) The sender repeats the missing information a number of times, until it
receives an acknowledgement or until a time-out expires.
c) To distinguish repetitions from new information, each packet receives
a sequence number (in the minimum odd/even).
d) The receiver acknowledges repetitions even if it already received the
information correctly.

3) In broadcast transmission, it is relatively difficult to gather acknowledgements


from all possible receivers, so in general unacknowledged broadcast is used.
The receiver is expected to protest if it does not receive the information.

EPFL - Industrial Automation

2004 June, HK

58

3.3.3 Field busses - Link Layer

Link Layer Outline


Link Layer in the OSI model
Stacks
HDLC as example
Frame sub-layer
Error detection
Error correction
Medium Access control
Quality Criteria
Single Master
Rings
Ethernet
Collision with winner
Token Passing
Comparison
Logical Link Control
Connection-Oriented and connectionless
Error recovery
Flow control
HDLC
EPFL - Industrial Automation

2004 June, HK

59

3.3.3 Field busses - Link Layer

Example: HDLC

HDLC (High-level Data Link Control is derived from IBM's SDLC


(Synchronous Data Link Control)
These protocols were developed for connection of point-of-sale terminals to a
one mainframe computer.
HDLC is the most frequently used link layer protocol.
It is the base for the CCITT-standard X25 (Telenet, Datex-P, Telepac) and used in Bitnet,
Appletalk, etc...
The HDLC protocol is implemented in the hardware of numerous
microcontrollers (e.g. Zilog 80C30, Intel, Siemens 82525,... and in some
microprocessors (e.g. 68360).
HDLC is the base for the Local Area Network protocol IEEE 802.2

EPFL - Industrial Automation

2004 June, HK

60

3.3.3 Field busses - Link Layer

HDLC Control Field (ISO 4335)


flag
01111110

flag
adr

control

FCS

any data

01111110

16

physical address of Secondary


(for command and response)
Control Field Bits
1

Control Field Format for:

N(S) = Sequence number of


sender

Information Transfer
Command/Response
(I-Format PDU)

Supervisory
Commands/Responses
(S-Format PDUs)

Unnumbered
Commands/Response
(U-Format PDUs)

N(S)

P/F

N(R)
N(R) = Sequence number of
receiver

P/F

N(R)
S = Supervisory

P/F

P/F = Poll/Final (Please respond/Final in sequence)

EPFL - Industrial Automation

2004 June, HK

61

3.3.3 Field busses - Link Layer

HDLC Connection Types


Traffic is divided into packets (= information frame) each receiving a sequence
number (Modulo 8).
The sender includes the sequence number in each packet.
The receiver indicates which packet it expects next, either through a special frame
( Receiver Ready N(R) ) or within its information frames (I-Frame, N(R))
At the same time, this sequence number acknowledges all previously received
frames with number N(R) -1.
HDLC provides different connection types:
LAP (link access procedure): assymetric Primary/Secondary;

NRM (normal response mode): only one station as primary;


ARM (asynchronous response Mode): spontaneous transmission of secondary;
LAPB (LAP-balanced): every station can become primary and start transmitting
(if medium access allows).

EPFL - Industrial Automation

2004 June, HK

62

3.3.3 Field busses - Link Layer

HDLC Exchange (NMR in ISO 4335)

Send Sequence
set normal response
mode, poll

please confirm

information packets

SNRM, P

I0,0

I2,0P

I1,0

I3,0

Primary
(Commander)

time
UA,F

Secondary
(Responder)

RR3,F

accept
connection,
final

receiver
ready, expects 3

Receive Sequence
set normal response
mode, poll
SNRM; P

receiver
ready, expects 0

receiver
ready, expects 3

RR0;P

RR3;P

Primary
(Commander)
Secondary
(Responder)

time
UA;F

I0,0

accept
connection, final

I1,0
several
information packets

I2,0;F

I3,0
last frame

The data transmission takes place under control of the Primary.


Therefore, both "Send Frame" and "Receive Frame" are supported
EPFL - Industrial Automation

2004 June, HK

63

3.3.3 Field busses - Link Layer

Clocks

In a fieldbus, devices must be synchronized to a common clock to time-stamp


their transmissions.

EPFL - Industrial Automation

2004 June, HK

64

3.3.3 Field busses - Link Layer

Time Distribution in a single master system


At fixed intervals, the Master broadcasts the exact time as a periodic variable.
When receiving this variable, the bus controllers generate a pulse which can
resynchronize a slave clock or generate an interrupt request.

int
req

int
req

PORTS

slave
clock
master
clock

application
processor 1

pulse

application
processor 2

int
req

PORTS

pulse

bus
controller

application
processor 3

PORTS

pulse

bus
controller

bus
controller
BUS

time variable

bus master

EPFL - Industrial Automation

2004 June, HK

65

3.3.3 Field busses - Link Layer

Clock compensation for transmission delays

other master
with clock

slave
clock
master
1

MVB 1

other MVB
synchronizer

master clock
device

slave clocks

The clock does not need to be generated by the Master, but the master must poll the clock
The clock can synchronize sampling within a few s across several bus segments.

EPFL - Industrial Automation

2004 June, HK

66

3.3.3 Field busses - Link Layer

IEEE 1588 PTP Clock Synchronization

IEEE 1588 defines the Precision Time Protocol, a clock synchronization that assumes that
two consecutive frames have the same delay, but the moment of sending suffers jitter.
The clock device (possibly coupled to a radio signal) sends the first frame with an coarse
time stamp, but registers in hardware the exact moment when the frame was sent.
It then sends a second frame with the exact time at which the first frame was sent.
Bridges and switches are responsible to compensate for their internal delays and send a
corrected time frame.

EPFL - Industrial Automation

2004 June, HK

67

3.3.3 Field busses - Link Layer

High precision clock synchronization

In some application, even the PTP protocol is insufficient.


In this case, either the clock is distributed by a separate, dedicated medium
(as in railways signalling and electrical substations.
Alternatively, all devices receive a radio signal from GPS to recalibrate their internal clocks.

EPFL - Industrial Automation

2004 June, HK

68

3.3.3 Field busses - Link Layer

Industrial Automation
Automation Industrielle
Industrielle Automation

PersonnelRecord ::= [APPLICATION 0]


SET {
name
Name,
title
[0] VisibleString,
number
EmployeeNumber,
dateOfHire [1] Date,
nameOfSpouse [2] Name,
children
[3] IMPLICIT
SEQUENCE OF ChildInformation
DEFAULT {}

3.3.4 Data presentation

2006, April HK

Prof. Dr. H. Kirrmann


ABB Research Center, Baden, Switzerland

To probe further

http://www.isi.salford.ac.uk//books/osi/all.html - An overview of OSI


http://www.oss.com/ - Vendor of ASN.1 tools
http://www-sop.inria.fr/rodeo/personnel/hoschka/347.txt - List of ASN.1 tools
http://lamspeople.epfl.ch/kirrmann/mms/OSI/osi_ASN1products.htm - ASN.1 products

Industrial Automation

2/48

3.3.4 Data Presentation

Presentation layer in the OSI-Model (ISO/IEC standard 7498)

All services directly called by the end user


(Mail, File Transfer,...)

Application

Definition and conversion of the


data formats (e.g. ASN 1)

Presentation

Session

Transport

Network

Link

Physical

Industrial Automation

Application
protocols

Management of connections
(e.g. ISO 8326)
End-to-end flow control and error recovery
(e.g. TP4, TCP)

Transport
protocols

Routing, possibly segmenting


(e.g. IP, X25)

Error detection, Flow control and error recovery,


medium access (e.g. 802.2, HDLC)
Coding, Modulation, Electrical and
mechanical coupling (e.g. Ethernet)

3/48

3.3.4 Data Presentation

Presentation Layer

The presentation layer is responsible that all communication


partners agree on the format of the data

Industrial Automation

4/48

3.3.4 Data Presentation

Justification for a data representation standard

Why do we need ASN.1 ( or a similar notation)

Industrial Automation

5/48

3.3.4 Data Presentation

Example: Transfer Syntax: describe what is in a frame ?


Role: how to define formally the format and meaning of the transmitted data
IEEE 802.4
token bus
MAC_header
13
MA. frame control

MA. destination
address
(6 octets)

ISO 8802
logical link control

ISO 8473
connectionless network control

LNK_hdr

NET_header

>48

L_destination SAP

ISO 8073
class 4 transport control
TRP_header

Protocol Identifier

(81)

Header Length

L_PDU

Version/Protocol ID (01)

L_PDU = UI, XID, TEST

Lifetime
SP MS ER

DT/ER Type

PDU Segment Length

(18 octets)
(18 octets)

(6 octets)

(CDT)
Destination
Reference

FIXED
PART

ET

N(S)

address length

IDI, Area ID
(7 octets)

Segmentation
(0 or 6 octets)
Options

LSAP = FE

6/48

IDP
(initial
domain
part)

PSI
Physical Address
(6 octets)

(priority = 3 octets)

Industrial Automation

TPDU

AFI = 49

Source Address
Address
Part

LI

Checksum
Destination Address

MA. source
address

DATA

L_source SAP

LSAP = DSAP
FE = network layer
18 = Mini-MAP Object
Dictionary Client
19 = Network Management
00 = own link layer

DATA (DT) TPDU


(normal format)

DSP
(domain
specific
part)

NSAP = 00

3.3.4 Data Presentation

Semantic Levels of Data Representation


Semantic format

Application Language format

154,5 Vrms
struct {
unsigned count;
int
item2:8;
int
item1:4;
int
dummy:4;
}

application memory

means actually 154,5 kV on the line

application
processor
D15

D00

Application Storage format


(Assembly language)
Storage format
traffic memory

Parallel Bus Format


(8 bit, 16 bit, 32 bits)

Traffic Memory format

transmission
specification
language and
encoding rules

SEQUENCE {
item1 INTEGER16,
item2 INTEGER4,
count UNSIGNED8;
}

bus controller

(16-bit oriented)

Bus Transmission Format

time

Industrial Automation

7/48

3.3.4 Data Presentation

Bit Transmission Order


Most data links are byte-oriented (transmit 8 bit as an indivisible unit)
The order of bit transmission within a byte (octet) is dependent on the link.
It does not matter as long as all bus participants use the same scheme
first

first

0 1 0 0 0 0 0 0
LSB

MSB

0 0 0 0 0 0 1 0
MSB

LSB

time

FDDI, FIP, CAN, MVB

UART, HDLC, Ethernet

Legacy of the old telex

There is no relation between the bit and the byte ordering scheme
octet in

octet out
Who says which bit is really transmitted first ?
(FDDI: multi-bit symbol transmission, multi-bit
transmission with interleaving)

Convention: only consider octet streams


Industrial Automation

8/48

3.3.4 Data Presentation

Integer representation in memory: Big-Endian vs Little Endian

Memory contents
MSB

address

LSB

0 0 0 0 0 0 1 0

x0001
x0002

0 0 0 0 0 0 0 1

x0003
x0004

0 0 0 0 0 0 0 1

x0005
x0006

0 0 0 0 0 0 0 0

BE

Intel

Motorola

DEC

7 6 5 4 3 2 1 0

x0000

LE

IBM, TCP/IP,
Unix, RISC

INTEGER8

=2

=2

INTEGER16

=1

= 256

INTEGER32

=1

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0

= 16777216

0 0 0 0 0 0 0 0

Processor

B7 B6 B5 B4 B3 B2 B1 B0

(bit name)

TCP/IP

0 1 2 3 4 5 6 7

(bit offset)

Profibus

1 2 3 4 5 6 7 8

(bit position)

Industrial Automation

9/48

three different naming schemes !

3.3.4 Data Presentation

How are sequence of octets transmitted ?

Most Significant First ?

Transmission Order on the bus ?

INTEGER32

time

how to name bits ?

The standard in network protocols is always:


Most Significant Octet first (Big-Endian)

Industrial Automation

10/48

3.3.4 Data Presentation

So, how to respect network byte ordering ?


Since network protocols require a most significant octet first transmission
(NBO =Network Byte Ordering), all little-endian processors must convert their data before
putting them into the transmission buffer, pipe or socket, by calling the Unix functions:
Function Name
htons
htonl
ntohs
ntohl

Description
Host order to
Host order to
Network order
Network order

network
network
to host
to host

order,
order,
order,
order,

short (2 bytes, 16 bits)


long (4 bytes, 32 bits)
short (2 bytes, 16 bits)
long (4 bytes, 32 bits)

All data "seen" by the sockets layer and passed on to the network must be in network order
struct sockaddr_in s;

/* WRONG */
s.sin_port = 23;
/* RIGHT */
s.sin_port = htons(23);

- Extremely error prone


Industrial Automation

11/48

3.3.4 Data Presentation

Inconsistency: Token-bus frame (IEEE 802.4)


first MAC
symbol

read this picture from left to right,


then top to bottom

preamble
N
N
F
F
I/G L/U

0
M
lsb

N
M

N
M

0
P

0
P

0
P
Destination Address

remaining 44 bits of address


msb
I/G L/U

Addresses are transmitted least significant bit first

lsb

Source Address
remaining 44 bits of address
msb
msb

lsb

first octet

Data are transmitted least significant bit first within


an octet, but most significant octet first within a
word (imposed by higher layers)
lsb
msb

msb

last data octet

Frame Check Sequence

Checksum is transmitted most significant bit first


I

Industrial Automation

lsb
E

12/48

3.3.4 Data Presentation

How to specify transmitted data ?


offset 0
offset
time

first: agree on a bit and byte ordering


scheme: {0,0} scheme recommended.

second: describe the data stream


formally (machine-readable)
formal

intuitive
0

snu

gni

nodeID or groupID

stationID

functionID

protocolID

command
parameter

i
i+1

Industrial Automation

CommandPDU :== SEQUENCE


{
BOOLEAN1
snu -- system
BOOLEAN1
gni -- group
CHOICE (gni)
{
Group
: ENUM6 groupID;
Individual: ENUM6 nodeID;
}
ENUM8
stationID;
...
13/48

3.3.4 Data Presentation

Can a C-declaration serve as an encoding syntax ?

typedef struct {
char location[ LOCATION_LEN ];
unsigned long object_id;
alarm_type_t alarm_type;
priority_level_t priority_level;
unsigned long index_to_SNVT;
unsigned value[ 4 ];
unsigned long year;
unsigned short month;
unsigned short day;
unsigned short hour;
unsigned short minute;
unsigned short second;
unsigned long millisecond;
unsigned alarm_limit[ 4 ];
} SNVT_alarm;

how is size given?


allowed values in enum ?

to which structure does it point?

is "short" a byte ?
is unsigned 16 bits or 32 bits ?

No!
Such a machine-dependent syntax is only valid if all applications use the same syntax on
the same machine with the same compiler, it is not suited to describe the bus traffic.
Industrial Automation

14/48

3.3.4 Data Presentation

One solution: Abstract Syntax Notation Number 1 (ASN.1)

The IEC/ISO define a standard notation in IEC 8824 (ASN.1), allowing to define
simple types (primitive) and constructed types.
Data structures can take forms not usually found in programming languages.
Each data structure is identified during transmission by a tag.
In principle, ASN.1 only defines data structures to be transmitted, but not how
they are encoded for transmission.
One possible coding of the primitive and constructed data types is defined in
ISO/IEC 8825 as "Basic Encoding Rules (BER) defined in ISO 8825.
More efficient encodings (PER,) also exist.
ASN.1 can be used for defining memory contents, file contents or communication
data, and in general any exchanged information.
ASN.1 was originally designed to transfer information between data bases.
ASN.1 has the same role as XML, but it is far more efficient.
see: http://asn1.elibel.tm.fr/en/index.htm

Industrial Automation

15/48

3.3.4 Data Presentation

ASN.1 Syntax Example


Informal
Name:
Title:
Employee Number:
Date of Hire:
Name of Spouse:
Number of
Children:

John P Smith
Director
51
17 September 1971
Mary T Smith
2

Child Information Ralph T Smith


Name:
11 November 1957
Date of Birth
Child Information Susan B Jones
Name:
17 July 1959
Date of Birth

ASN.1
PersonRecord ::=
name
title
number
dateOfHire
nameOfSpouse
children

[APPLICATION 0] SEQUENCE {
Name
[0] VisibleString,
EmployeeNumber,
[1] Date,
[2] Name,
[3] SEQUENCE OF
Childinformation
DEFAULT {} }

ChildInformation ::= SEQUENCE {


name
Name,
dateOfBirth
[0] Date}
Name ::= [APPLICATION 1] SEQUENCE {
givenName VisibleString,
initial
VisibleString,
familyName VisibleString}

EmployeeNumber ::= [APPLICATION 2] INTEGER


Date ::= [APPLICATION 3] VisibleString -- YYYYMMDD

Industrial Automation

16/48

3.3.4 Data Presentation

Abstract syntax and transfer syntax


An abstract syntax describes the elements of information without considering their
encoding (i.e. how they are represented in memory or on a bus)
E.g. A transfer syntax defines the name of the structures and elements, their value range
[e.g. 0..15], .
ASN.1 is defined in the standard ISO 8824-1 (current version is 2002).

A transfer syntax describes how the structures and elements are effectively
encoded for storing and transmission, so that the receiver can fully decode the
transmitted information. At transmission time, only the transfer syntax is visible, it cannot
be interpreted without knowing the abstract syntax.
E.g. A transfer syntax defines that an array of 33 Unicode characters is transmitted.
The receiver knows from the abstract syntax that this is a persons name.
The basic encoding rules for ASN.1 are defined in the standard ISO 8825-1.

Industrial Automation

17/48

3.3.4 Data Presentation

ASN.1 encoding: TLV

ASN.1 does not say how data are stored nor transmitted, but it assumes that the
transmission format consists for each item of: a tag, a length and a value (TLV)

tag

length

value

The value may be itself a structured object:


tag

length

tag

length

value

tag

length

value

(recursive)

the tag specifies the data type of the value that follows, implicitly or explicitly.

Industrial Automation

18/48

3.3.4 Data Presentation

ASN.1 Data Types

UNIVERSAL
APPLICATION
CONTEXT_SPECIFIC
PRIVATE

four Tag Types

Basic Types
BOOLEAN
INTEGER
BITSTRING
OCTETSTRING
NULL
OBJECT_ID
OBJECT_DESC
EXTERNAL
REAL
ENUMERATED
ANY

Constructed Types
SEQUENCE

ordered sequence of types (record, struct)

SEQUENCE OF ordered sequence of same type (array)


CHOICE

one of an unordered, fixed sequence of


different types.

SET
SET OF

unused
unused

pointers are not used objects of undefined length (closing character) are treated specially
Industrial Automation

19/48

3.3.4 Data Presentation

ASN.1 Universal Types


1 Boolean type
2 Integer type
3 Bitstring type
4 Octetstring type
5 Null type
6 Object identifier type
7 Object descriptor type
8 External type and Instance-of type
9 Real type
10 Enumerated type
11 Embedded-pdv type (imported type)
12 UTF8String type (unicode)
13 Relative object identifier type
14-15 Reserved for future editions
16 Sequence and Sequence-of types
17 Set and Set-of types
18-22, 25-30 Character string types
23-24 Time types
31-... Reserved for addenda
0 Reserved for use by the encoding rules
Industrial Automation

20/48

3.3.4 Data Presentation

ASN.1: The Type SEQUENCE


An ASN.1 SEQUENCE is similar to a C-struct:

Example: PersonRecord ::= SEQUENCE {


person
VisibleString
chief
VisibleString
title
VisibleString,
number
INTEGER,
dateOfHire UniversalTime }
This notation assumes that all elements in the sequence are present and are transmitted
in the specified order.

person
PersonRecord

chief

VisibleString

Industrial Automation

title

number

INTEGER
21/48

dateOfHire
UniversalTime
3.3.4 Data Presentation

Tagging

When elements of a sequence may be missing, it is necessary to tag the items,


i.e. identify the items by an integer.
Of course, if all types would be different, it would be sufficient to specify the type,
but this practice (called EXPLICIT tagging) is error-prone.
Structured types need in any case a tag, otherwise they cannot be distinguished
from another structured type (note how PersonRecord is identified as A1)
PersonRecord ::= [APPLICATION 1] SEQUENCE {
person
[1] VisibleString,
chief
[2] VisibleString,
title
[3] VisibleString,
number
[4] INTEGER,
dateOfHire
[5] UniversalTime }

person
tags

A1

[1]

Industrial Automation

number
[4]

dateOfHire

title
[3]

22/48

[5]
3.3.4 Data Presentation

ASN.1: The CHOICE type


A choice selects exactly one alternative of several.
There is normally a distinct tag for each choice, but the type can
also be used as tag, as long as all types are distinct:
Quantity ::= CHOICE {
[0] units
[1] millimetres
[2] kilograms
}

INTEGER16,
INTEGER32,
FLOAT

1234

quantity in units

1234

quantity in millimetres

1.2 E 03

kilograms, IEEE format

Industrial Automation

23/48

3.3.4 Data Presentation

Difference between ASN.1 and C or XML, XDR


ASN.1 is a format for data exchange, C is a compiler-dependent format for storage in RAM.
The basic data types are defined differently.
ASN.1 types may have a variable size (INTEGER may be 8, 16, 32, 64 bits).
ASN.1 SEQUENCE differs from a C struct since not all elements must be transmitted, nor is
their order to be maintained (if tagging is used).
ASN.1 CHOICE differs from a C union since the length depends on the chosen item,
and the contents differ.
ASN.1 has the same role as XML. XML is however both an abstract and a transfer syntax, it is
sent in clear text.

Unix systems use XDR (Sun's external data representation) that is 32-bit oriented, not efficient
for small data items, also a mixture of abstract and transfer syntax.

Industrial Automation

24/48

3.3.4 Data Presentation

Automatic, Explicit and implicit tagging

ASN.1 can assign automatically a tag to elements of a sequence.


This practice is dangerous, because another encoding (PER) could use other
tag numbers.
It is preferable to make tags explicit everywhere that is needed.
The most recent ASN.1 standard assumes that tags are implicit

Industrial Automation

25/48

3.3.4 Data Presentation

Transfer Syntax: Basic Encoding Rules (BER)

BER (ISO 8825-1), a companion to ASN1, defines encoding rules for ASN.1 data types
BER tags all data, either implicitly or explicitly
Type-Tag and size are transmitted before every value or structured data

Example:

type = UNIVERSAL Integer


length = 2 octets
value = 1234
02

02

12

(tag included in basic types)

34

BER supports all ASN.1 structures.


Exception: if size is 0, there is no value field (== NULL)
Industrial Automation

26/48

3.3.4 Data Presentation

Class
00 = UNIVERSAL
01 = APPLICATION
10 = CONTEXT_SPECIFIC
11 = PRIVATE

Primitive {0} or
Constructed {1}

BER Tag-Type field

P: after the size comes a value C: after the size comes a tag

Example:

Tag
(for universal class only):
00 = null (size = 0, no value)
01 = Boolean type
02 = Integer type
03 = Bitstring type
04 = Octetstring type
05 = Null type
06 = Object Identifier type
07 = Object Descriptor type
16 = Sequence and Sequence_Of types
17 = Set and Set_Of types
18-22 = Character strings (numeric, printable, )
23-24 = Time types
25 = Graphic string
26 = VisibleString (ISO646)
> 28 = reserve and escape: use a second octet.

00000010 = UNIVERSAL INTEGER


10100001 = [CONTEXT_SPECIFIC 1] SEQUENCE

Industrial Automation

27/48

3.3.4 Data Presentation

Basic Types in BER

A Boolean is represented by one octet (all zero for false)

01 01 FF = true

An Integer is represented by as many octets as necessary for the representation


of the number -> variable length encoding !
a:= 5 -> 1 octet
a:= 260 -> 2 octets
a:= 65544 -> 3 octets, etc

02 01 05
02 02 01 04
(hex representation)
02 03 01 00 08 (hex representation)

A Boolean Array is represented by as many octets as the array size requires.


The first octet indicates the number of unused bits in the trailing octet
e.g. BitString2 (Antivalent)
03 02 06 C0

bitstring

2 octets

Industrial Automation

6 unused bits

value = 11

28/48

3.3.4 Data Presentation

Example ASN.1 and BER


8

AP C
CallerRef :== [APPLICATION 7] SEQUENCE {
priority
[2] INTEGER,
command
[0] INTEGER,
reference
[1] INTEGER,
caller
INTEGER}

(useful information)

Industrial Automation

29/48

7
16

CS P

1
high_prio
CS P
0
1
command
CS P
1
2
reference (MSB)
reference (LSB)
CS P
3
4
UN P
2
2
caller (MSB)
caller (LSB)

high_prio

command

reference

caller

3.3.4 Data Presentation

Examples
constructed means: the octet following the size is not a value, but a type-tag !

Tag-Type:
80 10000000

Context Specific, not constructed, implicit, tag = [0]

61 01100001

Application Specific, constructed, implicit, tag = [1]

AB 10101101

Context Specific, constructed, implicit, tag = [11]

01 00000001

Basic Type, not constructed, boolean

decoding the first digit:


0,1:
2,3:
4,5:
6,7:
8,9:
A,B:

Universal, not constructed


Universal, constructed
Application Specific, not constructed
Application Specific, constructed
Context Specific, not constructed
Context Specific, constructed
Industrial Automation

30/48

[APPLICATION 1]
[6]
3.3.4 Data Presentation

Examples
green: tag / type
red: size
black: value

A0 0E 02 01 0A A1 09 A0 03 80 01 00 A1 02 80 00
A1 67 02 01 0A A1 62 A0 5D 1A 0B 54 65 6D 70 65
72 61 74 75 72 65 1A 0C 54 65 6D 70 65 72 61 74
75 72 65 31 1A 07 61 72 72 61 79 5F 35 1A 04 62
6F 6F 6C 1A 0F 66 65 65 64 65 72 31 5F 33 5F 70
68 61 73 65 1A 05 66 6C 6F 61 74 1A 0F 68 65 72
62 73 5F 74 65 73 74 5F 74 79 70 65 1A 08 75 6E
73 69 67 6E 65 64 81 01 00
-A0 18 02 01 0B A6 13 A0 11 80 0F 66 65 65 64 65
72 31 5F 33 5F 70 68 61 73 65
A1 34 02 01 0B A6 2F 80 01 00 A1 16 81 14 66 65
65 64 65 72 31 5F 33 5F 70 68 61 73 65 24 41 64
64 72 A2 12 A2 10 A1 0E 30 05 A1 03 85 01 10 30
05 A1 03 85 01 10
-A0 1E 02 01 0C A4 19 A1 17
Industrial Automation

31/48

null

3.3.4 Data Presentation

Variable length values a tricky issue

values are transmitted with a variable length. This costs a lot of encoding and decoding that
is not justified for simple types. Example for INTEGER:
Value

Length field

1
127
128
255
32767
32768
65535

01
01
02
02
02
03
03

-1
-127
-128
-129
-255
-32767
-32768
-32769

01
01
01
02
02
02
02
03

Value Octets

00
00
7F
00 80
00 FF

01
7F
80
FF
FF
00
FF

FF
FF
80
80
FF 7F

FF
81
80
7F
01
01
00
FF

Industrial Automation

// positive numbers > 127 take one octet more

// positive numbers > 32767 take one octet more

// note how this differs from 255

// negative numbers < -128 take one octet more

// negative numbers < - 32768 take one more octet

32/48

3.3.4 Data Presentation

Beyond ASN.1 and BER


ASN.1 / BER could not impose themselves in field busses because
of the high overhead involved (up to 32 bits for a single boolean !)
ISO / UIT developed more efficient encodings, such as
ISO/IEC 8825-2: Packed Encoding Rules (PER), that
exists in two versions: aligned (on an 8-bit boundary) or not aligned (bit stream)
In low speed busses such as fieldbus, this is still too much overhead.
IEC 61158-6 (Fieldbus) offers 3 encodings:
Traditional Encoding Rules (Profibus)
Compact Encoding Rules (for FAL)
Buffer Encoding Rules (FIP)
100 MBit/s Ethernet has sufficient bandwidth, but the burden is shifted to the processors
(Data compression gives variables length messages, costs a lot in compression &
decompression, in the worst case, compression takes as much place as the original)

Industrial Automation

33/48

3.3.4 Data Presentation

ROSIN Compact Retrofit Encoding


The railways operators needed to define formally the exchange rules for
data of already existing devices, of different manufacturers and vintage.
Therefore, a notation was developed (ROSIN notation) to describe any data transfer,
on a bit rather than a byte-orientation. It also allows to cope with alignment
(data should be transmitted at an offset that is a multiple of their size to reduce
processor load)
Indeed, since these devices already communicate using a proprietary protocol,
transmission must already be unambiguous.

Each data type is specified, e.g. Integer32 differs from Integer32_LE (Little Endian)
The ROSIN notation uses the ASN.1 meta-syntax, but it does not imply a TLV scheme.
- the length can be deduced from the type or position,
- typing information is inserted explicitly when:
a choice exists among several alternative types (e.g. depends on success/failure)
types have a (large) variable size (e.g. text strings, files)
sequences have optional fields and out-of-sequence fields (occurs too often).

Industrial Automation

34/48

3.3.4 Data Presentation

ROSIN - Retrofit encoding rules example


Type_InfoMessage ::= RECORD {
parameter1
INTEGER8
parameter2
INTEGER16,
parameter3
UNSIGNED6,
par4
ANTIVALENT2,
parameter5
Parameter5,
parameter6
STRING32,

--------

octet.
16-bit word, MSB first
6- bit value
2 bits for par4, e.g. check variable.
parameter5 has a structured type
an array of up to 32 8-bit characters.
trailed if shorter with 0 characters.

snu
ENUM1 {
USER
(0),
-- 0 = user
SYSTEM (1)
-- 1 = system
},
gni
ENUM1 {
-- could also be expressed as BOOLEAN1
INDIV (0),
-- individual function addressing
GROUP (1),
-- group addressing.
},
node_id
UNSIGNED6,
-- 6-bit unsigned integer
sta_or_func
ONE_OF [snu] { -- meaning depends on snu
function [USER] UNSIGNED8,
-- if snu = user, function identifier
station [SYSTEM] UNSIGNED8
-- if snu = system, station identifier
},
next_station_id
UNSIGNED8,
-- next station or FFH if unknown
tv
BOOLEAN1,
-- TRUE if 1
res1
BOOLEAN1 (=0), -- 0 (place holder)
topo_counter
UNSIGNED6,
-- 6-bit unsigned integer
tnm_code
ENUM8 {
-- has only two defined values
FIRSTCASE (1EH)
-- one of two defined values
SECONDCASE (84H)
-- the other defined value
},
action_code
Action_Code,
-- this type is used several times

parameter1

parameter2

2
3

parameter3

par4

parameter5

5
6
parameter6

CHARACTER8

39 snu gni

sta_or_func

40

next_station_id

41
42

node_id

tv

d1

top_counter

43

tnm_code

44

action_code

Industrial Automation

35/48

3.3.4 Data Presentation

Comparing Coding Efficiency


(ISO)

(SUN)

BER

XDR

Boolean

24

16

Integer8

24

Unsigned8

(UIT)
A-PER

(Profibus) (FIP)

U-PER

FER

BuER

ROSIN

16

16

16

12

16

16

24

16

11

11

16

16

Integer16

32

24

24

20

24

24

16

Unsigned 16

32

24

24

19

24

24

16

Integer32

48

40

24..48

36

40

40

32

Unsigned32

48

40

24..48

35

40

40

32

String [32]

272

272

272

272

272

272

256

encoding/decoding highly packed data may cost more than is won by shorter transmission

Industrial Automation

36/48

3.3.4 Data Presentation

The semantic limit


The good news: it is possible to decode entirely the element of a BER message
(tags, length, value) provided the start or entry point is known.
The bad news: one cannot understand the values unless the receiver knows the
original ASN.1 definitions.
Even worse news: even knowing the ASN. 1 original syntax does not allow to understand
the semantics of the value. If a value of 1234 represents a variable called errorCode
or temperatureAmb, one does not yet know the physical value really it represents.
Therefore, the application must define in any case a higher-level type specification
in a human readable form.
example:
switchPos ::= SEQUENCE {
open
[1] BOOLEAN,
closed [2] BOOLEAN,
operations [3] INTEGER,
closingTime [4] INTEGER
}

Industrial Automation

-----------

true when switch is open (debouncing 2 ms)


true when switch is closed (debouncing 2 ms)
(both can be false during opening /closing)
number of operations since installation
time in milliseconds from open to close

37/48

3.3.4 Data Presentation

Engineering Units

Many process variables represent analog, physical values of the plant.


Data presentation (e.g. integer) is insufficient to express the meaning of the variable.
Therefore, it is necessary to allocate to each variable a data type in engineering units.

"A unit of measure for use by operating/maintenance personnel usually


provided by scaling the input quantity for display (meter, stripchart or CRT)"
IEEE

Scaling (determined the possible range of a variable) is necessary for analog displays.
It requires the definition of the possible range of values that the variable may take.

Industrial Automation

38/48

3.3.4 Data Presentation

SI Units
All physical variables should be restricted to SI Units (NIST 330-1991, IEEE 268A-1974)
or referred directly to them
For instance:

speeds shall be expressed in meter/second, not in km/h or in miles/hour

angles shall be represented in radian rather than degree or grad.


variable
position, distance
mass
time
current
angle
force
torque
frequency
angular velocity
angular acceleration

Industrial Automation

unit
m
kg
s
A
rad
N
Nm
s-1
rad/s
-2
rad s

39/48

variable
power
energy
pressure
volume
flow
mass flow
tension
reactive power
impedance
temperature

unit
W
J
Pa
m3
m3 /s
kg/s
V
var

3.3.4 Data Presentation

Why floating point ?


Floating point format (IEEE Std 254)
- require twice the place (32 bits vs 16 bits),
- adds about 50% to traffic (analog values are only 10% of total),
- cost more to process (floating point unit)
but
- removes all ambiguities, rounding errors, overflow and underflow.
Floating point format is the only safe representation of a physical variable.
Internally, devices can use other formats.
Therefore, devices shall indicate their exported and imported variables as REAL32.
Exception:
Variables, whose precision do not depend on their absolute value:
e.g. time, elapsed distance (odometer), energy, money, countable objects
In special applications (e.g. GPS data), an ASCII representation may be more
appropriate, albeit not efficient. In this case, data can also be processed as BCD
(as in pocket calculators)

Industrial Automation

40/48

3.3.4 Data Presentation

Fractionals
A device can indicate the format of a fractional analog variable by
specifying (as a REAL32) the span and the offset to be applied to the base unit:
offset value
span value
physical variable
UNSIGNED16
0

65535
INTEGER16

-32768

+32767

e.g. offset = 0,0 m/s, span = 100,0 m/s, base unit = UNSIGNED16
means: 0 = 0,0 m/s, 65536 == 100,0 m/s
e.g. offset = - 32,768 V, span = 65,536 V, base unit = INTEGER16
means: 0 = -32,768 m/s, 65536 == 32,767 V

Industrial Automation

41/48

3.3.4 Data Presentation

Scaled Variables

Process Variables are often transmitted and processed as fractionals:


Fractional format expresses analog values as integer multiples of the resolution
e.g.:

caution

distance = 0..65535 x 0.1 m (resolution)


distance = -32768..+32767 x 0.1 m
speed = 0.. 6553,5 m/s, resolution = 0.1 m/s
speed = 0.. 6.5535 m/s, resolution = 0,0001 m/s

--> 0 .. 65535
--> -32768 .. 32768
--> 0 .. 65535
--> 0 .. 65535

(UNSIGNED16)
(INTEGER16)
(UNSIGNED16)
(UNSIGNED16)

The resolution is often a decimal fraction of a unit !

Some standards provides a bipolar or unipolar analog data format:


e.g. :
0%..+200-%
of 10 kV
-200%..+200-% of 10 kV

== 0 .. 65535
== -32768 .. 32768

(UNSIGNED16)
(INTEGER16)

fractionals require producer and consumer to agree on range and resolution:


e.g. resolution 0.5 V, range 6553.5 V

fractionals have some justifications in circular units


0 = 360
180

== 0
== 32768

fractionals are easy to process but error prone (overflow, underflow)


A conversion from fractional to floating point cost over 5 Mia (Ariane 501 accident)
Industrial Automation

42/48

3.3.4 Data Presentation

Constructed Application Data Types


Circuit Breaker command:
Code

DoubleCommand

Persistent
Regulating Command

RegulatingStep
Command

Double-Point
Information

00
01
10
11

not permitted
OFF
ON
not permitted

not permitted
Lower
Higher
not permitted

not permitted
Next Step Lower
Next Step Higher
not permitted

indeterminate
determined OFF
determined OFF
not permitted

Time-Stamped Variable:

value

time

status

Industrial Automation

43/48

3.3.4 Data Presentation

Application Data Types

Structured Text:
RTF - Microsoft Word Native Format
HTTP - Hypermedia data presentation
Some standards for video:
QuickTime -- an Apple Computer specification for video and audio.
Motion Picture Experts Group (MPEG) -- video compression and coding.
Some graphic image formats:
Graphics Interchange Format (GIF) -- compression and coding of graphic images.
Joint Photographic Experts Group (JPEG) -- compression and coding for graphic images.
Tagged Image File Format (TIFF) -- coding format for graphic images.

Industrial Automation

44/48

3.3.4 Data Presentation

Presentation Layer in the application


Coding and conversion functions to application layer data cannot be done in the
presentation layer due to the lack of established rules
These functions ensure that information sent from the application layer of one system will
be readable by the application layer of another system.
Examples of presentation layer coding and conversion schemes in the application:
Common data representation formats -- The use of standard image, sound, and video
formats allow the interchange of application data between different types of computer
Conversion of character representation formats -- Conversion schemes are used to
exchange information with systems using different text and data representations (such as
ASCII and Unicode).
Common data compression schemes -- The use of standard data compression schemes
allows data that is compressed at the source device to be properly decompressed at the
destination (compression can take place at different levels)
Common data encryption schemes -- The use of standard data encryption schemes allows
data encrypted at the source device to be properly unencrypted at the destination.

Industrial Automation

45/48

3.3.4 Data Presentation

Gateway
When devices share no common transport layer protocol, gateways act as protocol
converters and application layer protocols must ensure end-to-end control.
Protocol Conversion is costly in development and real time, since protocols are in
general insufficiently specified, custom-designed, and modified without notice.

Protocol Conversion requires at least an semantical equivalent of the objects on both


sides of the gateway, so that one command can be converted into another - if possible.
gateway
PD-marshalling
MSG

application

Real-Time
Protocols

PV

application
presentation

presentation

session

session

transport

transport

network

network

PV

link

link

link

link

physical

physical

physical

physical

bus type 1
Industrial Automation

bus type 2
46/48

3.3.4 Data Presentation

Industrial Automation
Automation Industrielle
Industrielle Automation

Prof. Dr. H. Kirrmann


ABB Research Center, Baden, Switzerland

Office
network

Industrial Automation
Automation Industrielle
Industrielle Automation

TCP - IP
Ethernet

Plant Network
Ethernet, ControlNet

Fieldbus
intelligent field devices
FF, PROFIBUS, MVB, LON

Sensor Busses
simple switches etc.
CAN, DeviceNet, SDS, ASI-bus, Interbus-S

Industrial Communication Systems

3.1

2006 March, HK

Field Bus: principles


Bus de terrain: principes
Feldbusse: Grundlagen

Titular curs: s.l. dr. ing. Nicoleta-Cristina GITAN

Field bus: principles

3.1 Field bus principles


Classes
Physical layer
3.2 Field bus operation
Centralized - Decentralized
Cyclic and Event Driven Operation

3.3 Standard field busses

Industrial Automation

3.1 Field bus principles

Location of the field bus in the plant hierarchy


File
Edit

SCADA level

Operator

23
2
4
33

12
2

Engineering

Plant bus
Programmable
Logic Controller

Plant Level

Field bus
Field level

Sensor/
Actor
Bus
direct I/O

Sensor /

Industrial Automation

3.1 Field bus principles

What is a field bus ?


A data network, interconnecting a control system, characterized by:
- transmission of numerous small data items (process variables) with bound delay (1ms..1s)

- harsh environment (temperature, vibrations, EM-disturbances, water, salt,)


- robust and easy installation by skilled people
- high integrity (no undetected errors)

- high availability (redundant layout)


- clock synchronization (milliseconds down to a few microseconds)
- continuous supervision and diagnostics
- low attachment costs ( 5.- / node)
- moderate data rates (50 kbit/s 5 Mbit/s) but large distance range (10m .. 4 km)
- non-real-time traffic for commissioning (e.g. download) and diagnostics
- in some applications intrinsic safety (oil & gas, mining, chemicals,..)

Industrial Automation

3.1 Field bus principles

Expectations

- reduce cabling
- increased modularity of plant (each object comes with its computer)
- easy fault location and maintenance
- simplify commissioning (mise en service, IBS = Inbetriebssetzung)
- simplify extension and retrofit
- large number of off-the-shelf standard products to build Lego-control systems
- possibility to sell ones own developments (if based on a standard)

Industrial Automation

3.1 Field bus principles

The original idea: save wiring


I/O

tray
marshalling
capacity
bar

dumb devices

PLC

(Rangierung,

PLC

COM

tableau de brassage (armoire de triage)

field bus

but: the number of end-points remains the same !


energy must be supplied to smart devices
Industrial Automation

3.1 Field bus principles

Marshalling (Rangierschiene, Barre de rangement)

The marshalling is the interface between


the PLC people and the instrumentation
people.

Industrial Automation

3.1 Field bus principles

Field busses classes

Office
network
TCP IP
Ethernet

Plant Network
Ethernet, ControlNet

Fieldbus
intelligent field devices
FF, PROFIBUS PA, LON

Sensor Busses
simple switches etc.
CAN, DeviceNet, SDS, ASI-bus, Interbus-S

The field bus depends on:


its function in the hierarchy
the distance it should cover
the data density it should gather
Industrial Automation

3.1 Field bus principles

Geographical extension of industrial plants


The field bus suits the physical extension of the plant
1 km .. 1000 km

Transmission & Distribution


Control and supervision of large distribution networks:
water - gas - oil - electricity - ...

1 km .. 5 km

Power Generation
Out of primary energy sources:
waterfalls - coal - gas - oil - nuclear - solar - ...

50 m .. 3 km

Industrial Plants
Manufacturing and transformation plants:
cement works - steel works - food silos - printing - paper
pulp processing - glass plants - harbors - ...

500m .. 2 km

Building Automation
energy - air conditioning - fire - intrusion - repair - ...

1 m .. 1 km

Manufacturing
flexible manufacturing cells - robots

1 m .. 800 m

Vehicles
locomotives - trains - streetcars - trolley buses - vans buses - cars - airplanes - spacecraft - ...

Industrial Automation

3.1 Field bus principles

Fieldbus Application: wastewater treatment

Pumps, gates, valves, motors, water level sensors, flow meters, temperature sensors,
gas meters (CH4), generators, are spread over an area of several km2
Some parts of the plant have explosive atmosphere.

Wiring is traditionally 4..20 mA, resulting in long threads of cable (several 100 km).

Industrial Automation

10

3.1 Field bus principles

Process Industry Application: Water treatment plant


Control Room

Japan
R emote
Maintenanc e
Sy s tem

source: Kaneka, Japan


LAS

SCADA

Malaysia

Ethernet

Bus Monitor
H1 Speed Fieldbus
JB

Segment 1

Segment 3

Sub Station

JB

AO
AI
AI

P ID
AI

P ID

AI

AI

AO

AI

AI

AI

AI

PLC

AO
P ID AO

AO

M.C.C.

DI

FB Protoc ol
C onv erter
JB

Segment 2

Segment 4

D igital Input/Output

AI

AI
AI

JB

AI

AI

P ID AI P ID
AO
AO

AI AI

AI

AI

Numerous analog inputs (AI),


low speed (37 kbit/s) segments merged to 1 Mbit/s links.
Industrial Automation

11

3.1 Field bus principles

Data density (Example: Power Plants)


Acceleration limiter and prime mover: 1 kbit in 5 ms
Burner Control:

2 kbit in 10 ms

per each 30 m of plant: 200 kbit/s


Fast controllers require at least 16 Mbit/s over distances of 2 m
Data are transmitted from the periphery or from fast controllers to higher level, but slower links to
the control level through field busses over distances of 1-2 km.
The control stations gather data at rates of about 200 kbit/s over distances of 30 m.
The control room computers are interconnected by a bus of at least 10 Mbit/s,
over distances of several 100 m.

Planning of a field bus requires to estimate the data density per unit of length (or surface)
and the requirements in response time and throughput over each link.

Industrial Automation

12

3.1 Field bus principles

Distributed peripherals

Many field busses are just


extensions of the PLCs Inputs
and Outputs,
field devices are data
concentrators.
Devices are only visible to the
PLC that controls them

relays and fuses

Industrial Automation

13

3.1 Field bus principles

Application: Building Automation


Source: Echelon

low cost, low data rate (78 kbit/s), may use power lines (10 kbit/s)
Industrial Automation

14

3.1 Field bus principles

Application: Field bus in locomotives

power line

radio

cockpit

Train Bus

diagnosis
Vehicle Bus

brakes

power electronics

data rate
delay
medium
number of stations
integrity
cost
Industrial Automation

motors

track signals

1.5 Mbit/second
1 ms (16 ms for skip/slip control)
twisted wire pair, optical fibers (EM disturbances)
up to 255 programmable stations, 4096 simple I/O
very high (signaling tasks)
engineering costs dominate
15

3.1 Field bus principles

Application: automobile

- 8 nodes
- 4 electromechanical wheel brakes
- 2 redundant Vehicle Control Unit
- Pedal simulator
- Fault-tolerant 2-voltage on-board power supply
- Diagnostic System
Industrial Automation

16

3.1 Field bus principles

Application: Avionics (Airbus 380)

Industrial Automation

17

3.1 Field bus principles

Networking busses: Electricity Network Control: myriads of protocols

control
center

SCADA
control
center

IEC 870-6

Modicom

Inter-Control Center Protocol

IEC 870-5

DNP 3.0

RTU
COM

ICCP

RTU

Conitel

control
center
RP 570

RTU

HV

High
Voltage

serial links (telephone)

RTU

Remote Terminal Units

RTU

substation

substation

FSK, radio, DLC, cable, fiber,...

RTU
RTU

houses

MV

Medium
Voltage

LV

Low
Voltage

RTU
RTU

low speed, long distance communication, may use power lines or telephone modems.
Problem: diversity of protocols, data format, semantics...
Industrial Automation

18

3.1 Field bus principles

The ultimate sensor bus

power switch and


bus interface

requires integration of power electronics and communication at very low cost.


Industrial Automation

19

3.1 Field bus principles

Industrial Automation
Automation Industrielle
Industrielle Automation

3 Industrial Communication Systems

3.2

Field Bus Operation


Bus de terrain: mode de travail
Feldbus: Arbeitsweise

ABB Research Center, Baden, Switzerland


2006 March, HK

Fieldbus - Operation

3.1 Field bus types


Classes
Physical layer
3.2 Field bus operation
Data distribution
Cyclic Operation
Event Driven Operation
Real-time communication model
Networking
3.3 Standard field busses

Industrial Automation

3.2 Field bus operation

Objective of the field bus

Distribute to all interested parties process variables, consisting of:


accurate process value and units
source identification: requires a naming scheme
quality indication: good, bad, substituted,
time indication: how long ago was the value produced
(description)

source

Industrial Automation

value

quality

time

description

3.2 Field bus operation

Master or peer-to-peer communication

communication in a control system is evolving from hierarchical to distributed


central master: hierarchical
PLC

all traffic passes by the master (PLC);


adding an alternate master is difficult
(it must be both master and slave)

master

AP

slaves

input
peer-to-peer: distributed

PLC

PLCs may exchange data,


share inputs and outputs
allows redundancy
and distributed intelligence
devices talk directly to each other

alternate
master

PLC

AP

AP

input

slaves

PLC
AP

output
masters

PLC
AP

output

separate bus master from application master !


Industrial Automation

3.2 Field bus operation

Broadcasts
A variable is read on the average in 1..3 different places
Broadcasting messages identified by their source (or contents) increases efficiency.

=
variable
instances

application
processor

application
processor

application
processor

application
processor

plant
image

plant
image

plant
image

plant
image

=
distributed
data base
bus

Each device is subscribed as source or as sink for a number of process variables


Only one device may be source of a certain process data (otherwise, collision).
The bus refreshes the plant image in the background, it becomes an on-line database

The replicated traffic memories can be considered as "caches" of the plant state
(similar to caches in a multiprocessor system), representing part of the plant image.
Each station snoops the bus and reads the variables it is interested in.
Industrial Automation

3.2 Field bus operation

Data format

source

value

quality

time

In principle, the bus could transmit the process variable in clear text (even using XML..)
However, this is quite expansive and only considered when the communication network
offers some 100 Mbit/s and a powerful processor is available to parse the message
More compact ways such as ASN.1 have been used in the past with 10 Mbit/s Ethernet
(see: Presentation Layer)
Field busses are still slow (1Mbit/s ..12 Mbits/s) and therefore more compact
encodings are used.

Industrial Automation

3.2 Field bus operation

Datasets
Field busses devices had a low data rate and transmit over and over the same variables.
It is economical to group variables of a device in the same frame as a dataset.
A dataset is treated as a whole for communication and access.
A variable is identified within a dataset by its offset and its size
Variables may be of different types, types can be mixed.

Dataset
binary variables

analog variables
dataset
identifier

wheel
speed
0

air
pressure
16

bit offset

Industrial Automation

line
voltage
32

time
stamp
48

64 66

70

all door closed


lights on
heat on
air condition on

size

3.2 Field bus operation

Dataset extension and quality

To allow later extension, room is left in the datasets for additional variables.
Since the type of these future data is unknown, unused fields are filled with '1".
To signal that a variable is invalid, the producer overwrites the variable with "0".
Since both an "all 1" and an "all 0" word can be a meaningful combination, each
variable can be supervised by a check variable, of type ANTIVALENT2:
Dataset

correct variable
error
undefined

variable value

check

0 1 0 1 1 1 0 0

0 1

0 0 0 0 0 0 0 0

0 0

1 1 1 1 1 1 1 1

1 1

00 = network error
01 = ok
10 = substituted
11 = data undefined

chk_offset

var_offset

A variable and its check variable are treated indivisibly when reading or writing
The check variable may be located anywhere in the same data set.
Industrial Automation

3.2 Field bus operation

Decoupling Application and Bus traffic


coupled (event-driven):

decoupled (asynchronous):
application
processor

application
processor

events
(interrupts)
traffic
memory

queues

bus
controller

bus
controller

sending: application writes data into memory

sending: application inserts data into queue


and triggers transmission,
bus controller fetches data from queue
receiving: bus controller inserts data into queue
and interrupts application to fetch them,
application retrieves data

receiving: application reads data from memory


the bus controller decides when to transmit
bus and application are not synchronized
Industrial Automation

3.2 Field bus operation

Traffic Memory: implementation


Bus and Application are (de)coupled by a shared memory, the Traffic Memory,
where process variables are directly accessible to the application.
Application
Processor

Traffic Memory

Ports (holding a dataset)

Associative
memory

an associative memory decodes


the addresses of the subscribed
datasets

Bus
Controller

two pages ensure that read and


write can occur at the same time
(no semaphores !)

bus
Industrial Automation

10

3.2 Field bus operation

Freshness supervision
It is necessary to check that the data in the traffic memory is still up-to-date,
independently of a time-stamp (simple devices do not have time-stamping)

Applications tolerate an occasional loss of data, but no stale data.


To protect the application from using obsolete data, each Port in the traffic
memory has a freshness counter.
This counter is reset by writing to that port. It is incremented regularly,
either by the application processor or by the bus controller.

The application should always read the value of the counter before using
the port data and compare it with its tolerance level.
The freshness supervision is evaluated by each reader independently, some
readers may be more tolerant than others.
Bus error interrupts in case of severe disturbances are not directed to the
application, but to the device management.

Industrial Automation

11

3.2 Field bus operation

Process Variable Interface


Access of the application to variables in a traffic memory is very easy:
ap_put (variable_name, variable value)

ap_get (variable_name, variable value, variable_status, variable_freshness)


Rather than fetch and store individual variables, access is done by clusters
(predefined groups of variables):
ap_put_cluster (cluster_name)
ap_get (cluster_name)
The cluster is a table containing the names and values of several variables.
The clusters can correspond to "segments" in the function block programming.

Note: Usually, only one variable is allowed to raise an interrupt when received: the one
carrying the current time (sent by the common clock)
Industrial Automation

12

3.2 Field bus operation

Time-stamping and clock synchronisation


In many applications, such as disturbance logging and sequence-of-events,
the exact sampling time of a variable must be transmitted together with its value.
To this purpose, the devices are equipped with a clock that records the creation date of
the value (not the transmission time).
To reconstruct events coming from several devices, clocks must be synchronized.
considering transmission delays over the field bus (and in repeaters,....)
A field bus provides means to synchronize clocks in spite of propagation delays and
failure of individual nodes. Protocols such as IEEE 1588 can be used.

t1

t2

processing

input

input

input

t3

t4

bus
t1 val1
Industrial Automation

13

3.2 Field bus operation

Transmission principle

The previous operation modes made no assumption, how data are transmitted.
The actual network can transmit data
cyclically (time-driven) or
on demand (event-driven),
or a combination of both.

Industrial Automation

14

3.2 Field bus operation

Cyclic versus Event-Driven transmission

cyclic: send value strictly every xx milliseconds

individual
period

misses the peak


(Shannon!)

always the same,


why transmit ?

time

hysteresis

event-driven: send when value change by more than x% of range

how much hysteresis ?


- coarse (bad accuracy)
- fine (high frequency)
Industrial Automation

limit update
frequency !,
limit hysteresis
15

nevertheless transmit:
- every xx as Im alive sign
- when data is internally updated
- upon quality change (failure)
3.2 Field bus operation

Fieldbus: Cyclic Operation mode

3.1 Field bus types


Classes
Physical layer
3.2 Field bus operation
Data distribution
Cyclic Operation
Event Driven Operation
Real-time communication model
Networking
3.3 Standard field busses

Industrial Automation

16

3.2 Field bus operation

Cyclic Data Transmission


address
Bus
Master

devices
(slaves)

Poll
List

plant

The master polls the addresses in a fixed sequence, according to its poll list.
Individual period
1

Individual period
6

2 3

N polls
6

2 3

6
time [ms]

The duration of each poll is the sum of


the transmission time of address and
data (bit-rate dependent)
and of the reply delay of the signals
(independent of bit-rate).

2 x Tpd
address
10 s/km
(i)

data
(i)

read transfer

address
(i+1)
time [s]

44 s .. 296 s

Industrial Automation

17

3.2 Field bus operation

Cyclic operation principle


Data are transmitted at fixed intervals, whether they changed or not.
The delivery delay (refresh rate) is deterministic and constant.
The bus is under control of a central master (or distributed time-triggered algorithm).
No explicit error recovery needed since a fresh value will be transmitted in the next cycle.
Only states may be transmitted, not state changes.
Cycle time is limited by the product of the number of data transmitted by the
duration of each poll (e.g. 100 s / point x 100 points => 10 ms)
To keep a low poll time, only small data items may be transmitted (< 256 bits)
The bus capacity must be configured beforehand.
Determinism gets lost if the cycles are modified at run-time.
Cyclic operation is used to transmit the state variables of the process.
These are called Process Data (or Periodic Data)

Industrial Automation

18

3.2 Field bus operation

Source-Addressed Broadcast
Process Data are transmitted by source-addressed broadcast.
Phase1: The bus master broadcasts the identifier of a variable to be transmitted:
bus
master

device

device

sink

source

subscribed devices
sink

devices
(slaves)

sink

bus

variable identifier

Phase 2: The device that sources that variable responds with a slave frame
containing the value, all devices subscribed as sink receive that frame.
bus.
master

subscribed
device

subscribed
device

sink

source

subscribed devices
sink

sink

devices
(slaves)

bus

variable value

Industrial Automation

19

3.2 Field bus operation

Read And Write Transfers


master

read transfer:
arb

source

address

turn-around
time

next transfer

data

arb

address

time

Read Transfer

write transfer:

master (source)
arb

address

next transfer

data

arb

address

Write-No ack transfer

time

turn-around time may be


large compared with
data transfer time.

destination

master (source)
arb

address

data

turn-around
time

ack

next transfer
arb

address

time

Write Transfer With Ack

Local Area Networks operate with write-only transfers.

Their link layer or transport layer provides acknowledgements by another write-only transfer

Parallel busses use read and write-ack transfers


Most field busses operate with read cycles only.
Industrial Automation

20

3.2 Field bus operation

Round-tip Delay
master

closest data sink


repeater

T_m

remotest data source


repeater

t_repeat

t_repeat

The
round-trip
delay limits
the extension
of a read-only
bus

propagation delay
(t_pd = 6 s/km)

T_m
t_source

t_mm

t_ms

(t_repeat < 3 s)

access delay
T_s

t_repeat

t_sm

T_m

distance

Industrial Automation

21

3.2 Field bus operation

Optimizing Cyclic Operation


Cyclic operation uses a fixed portion of the bus's time
The poll period increases with the number of polled items
The response time slows down accordingly
Solution: introduce sub-cycles for less urgent periodic variables:
2 ms period

4a

16

4 ms period

1 4b

64

4a

time
1 ms period
(basic period)

1 ms

1 ms

group with
period 1 ms

Cyclic polling need tools to configure the poll cycles.


The poll cycles should not be modified at run-time (non-determinism)
A device exports many process data (state variables) with different priorities.
If there is only one poll type per device, a device must be polled at the
frequency required by its highest-priority data.
To reduce bus load, the master polls the process data, not the devices
Industrial Automation

22

3.2 Field bus operation

Cyclic Transmission and Application

cyclic
poll

cyclic
algorithms

cyclic
algorithms

cyclic
algorithms

cyclic
algorithms

application
1

application
2

application
3

application
4

bus
master
Periodic
List

source
port

Traffic
Memory

Ports

Ports

Ports

sink
port

bus
controller

bus
controller

Ports

sink
port

bus
controller

bus
controller

bus
controller

bus
port address

port data

The bus traffic and the application cycles are asynchronous to each other.
The bus master scans the identifiers at its own pace.
Bus and applications are decoupled by a shared memory, the traffic memory,
which acts as distributed database actualized by the network.
Industrial Automation

23

3.2 Field bus operation

Application Of Cyclic Bus

The principle of cyclic operation, combined with source-addressed


broadcast, has been adopted by most modern field busses

It is currently used for power plant control, rail vehicles, aircrafts, etc...
This method gives the network a deterministic behavior, at expenses of a reduced
bandwidth and geographical extension.

The poll scan list located in the central master (which may be duplicated for
availability purposes) determines the behavior of the bus.
It is configured for a specific project by a single tool, which takes into account
the transmission wishes of the applications.
This guarantees that no application can occupy more than its share of the bus
bandwidth and gives control to the project leader.

Industrial Automation

24

3.2 Field bus operation

Example: delay requirement


publisher
application instance
device

subscribers application instances


device

device
applications

bus
bus instance
Worst-case delay for transmitting all time critical variables is the sum of:
Source application cycle time
8 ms
Individual period of the variable
16 ms
Sink application cycle time
8 ms
= 32 ms
Industrial Automation

25

3.2 Field bus operation

Example: traffic pattern in a locomotive


% periodic time

number of devices: 37 ( including 2 bus administrators)

30 frames of 128 bits

65 frames of 64 bits

37 of 16 bits

18 of 32

49 frames of 256 bits

occupancy is proportional to surface


total = 92%
period
16 ms

Industrial Automation

32 ms

26

64 ms

128 256

1024

3.2 Field bus operation

Fieldbus: Event-driven operation

3.1 Field bus types


Classes
Physical layer
3.2 Field bus operation
Data distribution
Cyclic Operation
Event Driven Operation
Real-time communication model
Networking
3.3 Standard field busses

Industrial Automation

27

3.2 Field bus operation

Event-driven Operation
Events cause a transmission only when an state change takes place.
Bus load is very low on the average, but peaks under exceptional situations
since transmissions are correlated by the process (christmas-tree effect).
Multi-master bus: uses write-only transfers

intelligent
stations

eventreporting
station

eventreporting
station

eventreporting
station

sensors/
actors

plant

Detection of an event is an intelligent process:


Not every change of a variable is an event, even for binary variables.
Often, a combination of changes builds an event.
Only the application can decide what is an event, since only the application
programmer knows the meaning of the variables.

Industrial Automation

28

3.2 Field bus operation

Bus interface for event-driven operation


application
filter
driver
Application
Processor

Each transmission on the bus causes an interrupt.


The bus controller only checks the address and
stores the data in the message queues.
The driver is responsible for removing the messages
of the queue memory and prevent overflow.
The filter decides if the message can be processed.
message (circular) queues

interrupt

Bus
Controller

bus
Industrial Automation

29

3.2 Field bus operation

Response of Event-driven operation


Caller
Application

Transport
software

Bus

Transport
software

Called
Application

request

interrupt
indication
confirm
time

Since events can occur anytime on any device, stations communicate by


spontaneous transmission, leading to possible collisions
Interruption of server device at any instant can disrupt a time-critical task.
Buffering of events cause unbound delays
Gateways introduce additional uncertainties
Industrial Automation

30

3.2 Field bus operation

Determinism and Medium Access In Busses

Although the moment an event occurs is not predictable, the communication


means should transmit the event in a finite time to guarantee the reaction delay.
Events are necessarily announced spontaneously: this requires a
multi-master medium like in a LAN.
The time required to transmit the event depends on the medium access
(arbitration) procedure of the bus.
Medium access control methods are either deterministic or not.

Deterministic

Non-deterministic

Central master,
Token-passing (round-robin),
Binary bisection,
Collision with winner.

Collision
(Ethernet)

Industrial Automation

31

3.2 Field bus operation

Events and Determinism


Although a deterministic medium access is the condition to guarantee delivery
time, it is not sufficient since events messages are queued in the devices.
events
producers
& consumers

input and
output queues
bus
acknowledgements

data packets

The average delivery time depends on the length of the queues, on the bus
traffic and on the processing time at the destination.
Often, the computers limit far more the event delay than the bus does.
Real-time Control = Measurement + Transmission + Processing + Acting

Industrial Automation

32

3.2 Field bus operation

Events Pros and Cons


In an event-driven control system, there is only a transmission or an operation
when an event occurs.
Advantages:

Can treat a large number of events - if not all at the same time
Supports a large number of stations
System idle under steady - state conditions
Better use of resources
Uses write-only transfers, suited for LANs with long propagation delays
Suited for standard (interrupt-driven) operating systems (Unix, Windows)

Drawbacks:

Requires intelligent stations (event building)


Needs shared access to resources (arbitration)
No upper limit to access time if some component not deterministic
Response time difficult to estimate, requires analysis
Limited by congestion effects: process correlates events
A background cyclic operation is needed to check liveliness

Industrial Automation

33

3.2 Field bus operation

Fieldbus: real-time communication model

3.1 Field bus types


Classes
Physical layer
3.2 Field bus operation
Centralized - Decentralized
Cyclic Operation
Event Driven Operation
Real-time communication model
Networking
3.3 Standard field busses

Industrial Automation

34

3.2 Field bus operation

Mixed Data Traffic

Process Data
represent the state of the plant

Message Data
represent state changes of the plant

short and urgent data items

infrequent, sometimes lengthy


messages reporting events, for:
Users: set points, diagnostics, status
System: initialisation, down-loading, ...

... motor current, axle speed, operator's


commands, emergency stops,...

-> Periodic Transmission


of Process Variables

-> Sporadic Transmission of


Process Variables and Messages

Since variables are refreshed periodically,


no retransmission protocol is needed to
recover from transmission error.

Since messages represent state


changes, a protocol must recover lost data in
case of transmission errors
basic period

basic period

event

time
sporadic
phase

periodic
phase

Industrial Automation

sporadic
phase

35

periodic
phase

3.2 Field bus operation

Mixing Traffic is a configuration issue

Cyclic broadcast of source-addressed variables is the standard solution in field busses


for process control.
Cyclic transmission takes a large share of the bus bandwidth and should be reserved
for really critical variables.
The decision to declare a variable as cyclic or event-driven can be taken late in a
project, but cannot be changed on-the-fly in an operating device.
A message transmission scheme must exist alongside the cyclic transmission to carry
not-critical variables and long messages such as diagnostics or network management

An industrial communication system should provide both transmission kinds.

Industrial Automation

36

3.2 Field bus operation

Real-Time communication stack


The real-time communication model uses two stacks, one for time-critical variables
and one for messages
time-critical
process variables

time-benign
messages

Management
Interface
7

Application

implicit

Presentation

Remote Procedure Call

Session

connection-oriented

Transport (connection-oriented)

Network (connectionless)

2"

Logical Link Control

medium access

2'

Link (Medium Access)

media

Physical

implicit

Logical Link
Control

connectionless
connectionless

common

Industrial Automation

37

3.2 Field bus operation

Application Sight Of Communication

Periodic Tasks
R1

R2

R3

Event-driven Tasks
R4

E1

Traffic
Memory

(Broadcast)

station

E3

Message Services

Variables Services

Process Data

E2

Queues

Supervisory
Data

Message Data
(destination-oriented)

bus controller

bus
Industrial Automation

38

3.2 Field bus operation

Field - and Process bus

Fieldbus

Process Bus

strictly deterministic

non - deterministic

controlled by a central master


(redundant for availability)

multi-master bus (Arbitration)


deterministic arbitration -> Token

cyclic polling

event-driven

number of participants limited by


maximum period

large number of participants

call/reply in one bus transfer


(read-cycle)
("fetch principle")

call/reply uses two different messages.


both parties must become bus master
("bring - principle")

cheap connection (dumb)

costly connection (intelligent)

only possible over a limited


geographical extension

also suited for open systems

Industrial Automation

39

3.2 Field bus operation

Cyclic or Event-driven Operation For Real-time ?


The operation mode of the communication exposes the main approach to
conciliate real-time constrains and efficiency in a control systems.
cyclic operation

event-driven operation

Data are transmitted at fixed intervals,


whether they changed or not.

Data are only transmitted when they


change or upon explicit demand.

Deterministic: delivery time is bound

Non-deterministic: delivery time vary widely

Worst Case is normal case

Typical Case works most of the time

All resources are pre-allocated

Best use of resources

(periodic, round-robin)

(aperiodic, demand-driven, sporadic)

object-oriented bus

message-oriented bus

Fieldbus Foundation, MVB, FIP, ..

Profibus, CAN, LON, ARCnet

Industrial Automation

40

3.2 Field bus operation

Fieldbus: Networking

3.1 Field bus types


Classes
Physical layer
3.2 Field bus operation
Data distribution
Cyclic Operation
Event Driven Operation
Real-time communication model
Networking
3.3 Standard field busses

Industrial Automation

41

3.2 Field bus operation

Networking field busses


Networking field busses is not done through bridges or routers,
because normally, transition from one bus to another is associated with:
- data reduction (processing, sum building, alarm building, multiplexing)
- data marshalling (different position in the frames)
- data transformation (different formats on different busses)
Only system management messages could be threaded through from end to end,
but due to lack of standardization, data conversion is today not avoidable.

Industrial Automation

42

3.2 Field bus operation

Networking: Printing machine (1)


MPS

Production

Plant-bus (Ethernet)
Operator bus (Ethernet)
Console,
Section Supervision

LS LS LS PM

LS LS LS PM

LS LS LS PM

LS LS LS PM

Printing Towers

Section Busses (AF100)

Section Control

D
SSB

SSC

SSD

SSE

Line bus (AF100)


Reelstand-Gateways

RPB

RPC

RPD

RPE

Reelstand bus (Arcnet)


Reelstands

multiplicity of field busses with different tasks, often associated with units.
main task of controllers: gateway, routing, filtering, processing data.
most of the processing power of the controllers is used to route data
Industrial Automation

43

3.2 Field bus operation

Networking: Printing Section (2)


to production preparation

(Ethernet)

bridge

standby

LS

LS

LS

PM

PM

standby

GW

GW

Pressmasterbus (Ethernet)
V-Sercos
IBG

V-Sercos
IBG

Section bus C

V-Sercos
IBG

V-Sercos
IBG

H-Sercos
H -steuerungen

IBG

IBG

IBG

Interbus

Interbus

Interbus

KT94

KT94

KT94

KT94

KT94

KT94

KT94

KT94

KT94

KT94

KT94

KT94

KT94

KT94

Service-Arcnet
Tower-ARCnet
Section bus B
Section bus C
Line bus

Turmsteuerung

AC160

Turmsteuerung

AC160

Turmsteuerung

AC160

Falz- und
Wendeturm- AC160
steuerung

Section bus D
Rollenwechslerkoppler I KT94

Oxydry-Arcnet

MR93

Sektions- SektionsAC160
steuerung steuerung

Rollenwechslerkoppler A

Interbus-S
KT94
ODC
Oxydry

Auro

ARCnet

Industrial Automation

44

3.2 Field bus operation

Transmission delay over a Trunk Bus (cyclic bus)


Trunk Bus

copying,
filtering &
marshalling
delay

gateway

gateway

Feeder Bus

copying,
filtering &
marshalling
delay

Feeder Bus

stop

speed

speed

stop

The actual delay is non-deterministic, but bounded


The worst-case delay for the transmission of all variables is the sum of 5 delays:
feeder bus delay
gateway marshalling delay
trunk bus delay
gateway marshalling delay
feeder bus delay

Industrial Automation

32 ms
16 ms
25 ms
10 ms (synchronized)
32 ms

45

= 100 ms

3.2 Field bus operation

2006 March, HK

Industrial Automation
Automation Industrielle
Industrielle Automation

Industrial Communication Systems


3.3

2005 April, HK

Field bus: standards


Bus de terrain standard
Standard-Feldbusse

ABB Research Center, Baden, Switzerland

Field busses: Standard field busses

3.1 Field bus types


Classes
Physical layer
Networking
3.2 Field bus operation
Centralized - Decentralized
Cyclic and Event Driven Operation
3.3 Field bus standards
International standard(s)
HART
ASI
Interbus-S
CAN
Profibus
LON
Ethernet
Automotive Busses
Industrial Automation

3.3 Standard Field Busses

Which field bus ?


A-bus
Arcnet
Arinc 625
* ASI
Batibus
Bitbus
* CAN
ControlNet
DeviceNet
DIN V 43322
DIN 66348 (Mebus)
FAIS
EIB
Ethernet
Factor
Fieldbus Foundation
FIP
Hart
IEC 61158

Industrial Automation

IEEE 1118 (Bitbus)


Instabus
* Interbus-S
ISA SP50
IsiBus
IHS
ISP
J-1708
J-1850
LAC
* LON
MAP
Master FB
MB90
MIL 1553
MODBUS
* MVB
P13/42
P14

Partnerbus
P-net
* Profibus-FMS
Profibus-PA
Profibus-DP
PDV
* SERCOS
SDS
Sigma-i
Sinec H1
Sinec L1
Spabus
Suconet
VAN
WorldFIP
ZB10
...

3.3 Standard Field Busses

Worldwide most popular field busses


Bus

User*

Application

Sponsor

CANs

25%

Automotive, Process control CiA, OVDA, Honeywell

Profibus (3 kinds)

26%

Process control

Siemens, ABB

Building systems

Echelon, ABB

LON

6%

Ethernet

50%

Plant bus

Interbus-S

7%

Manufacturing

Fieldbus Foundation, HART

7%

Chemical Industry

ASI

9%

Building Systems

Modbus

22%

obsolete point-to-point

ControlNet

14%

plant bus

*source: ISA, Jim Pinto (1999)

all
Phoenix Contact
Fisher-Rosemount, ABB
Siemens
many
Rockwell

Sum > 100%, since firms support more than one bus

European market in 2002: 199 Mio , 16.6 % increase (Profibus: 1/3 market share)

**source: Elektronik, Heft 7 2002

Industrial Automation

3.3 Standard Field Busses

Different classes of field busses


One bus type cannot serve
all applications and all device types efficiently...
Data Networks
Workstations, robots, PCs
Higher cost
Not bus powered
Long messages (e-mail, files)
Not intrinsically safe
Coax cable, fiber
Max distance miles

10,000

1000
frame size
(bytes)

100

Sensor Bus
Simple devices
Low cost
Bus powered (?)
Short messages (bits)
Fixed configuration
Not intrinsically safe
Twisted pair
Max distance 500m

Honeywell

PV 6000
SP 6000

AUTO
1

High Speed Fieldbus


PLC, DCS, remote I/O,
motors
$$ Medium cost
Non bus powered
Messages: values, status
Not intrinsically safe
Shielded twisted pair
Max distance 800m

10

10

100

Low Speed Fieldbus


Process instruments, valves
Medium cost
Bus-powered (2 wire)
Messages: values, status
Intrinsically safe
Twisted pair (reuse 4-20 mA)
Max distance 1200m

1000

poll time, milliseconds


Industrial Automation

10,000
source: ABB

3.3 Standard Field Busses

Field device: example differential pressure transducer


4..20 mA current loop

fluid

The device transmits its value by means of a current loop


Industrial Automation

3.3 Standard Field Busses

4-20 mA loop - the conventional, analog standard (recall)

The 4-20 mA is the most common analog transmission standard in industry

sensor
flow

transducer
i(t) = f(v)

RL1

reader

reader

R1

i(t) = 0, 4..20 mA

RL2
RL4

R2

voltage
source
10V..24V

RL3

R3

RL4

conductor resistance

The transducer limits the current to a value between 4 mA and 20 mA,


proportional to the measured value, while 0 mA signals an error (wire break)
The voltage drop along the cable and the number of readers induces no error.
Simple devices are powered directly by the residual current (4mA), allowing to
transmit signal and power through a single pair of wires.
Remember: 4-20mA is basically a point-to-point communication (one source)
Industrial Automation

3.3 Standard Field Busses

3.3.2 HART

Data over 4..20 mA loops

2005 April, HK

HART - Principle
HART (Highway Addressable Remote Transducer) was developed by Fisher-Rosemount to
retrofit 4-to-20mA current loop transducers with digital data communication.
HART modulates the 4-20mA
current with a low-level
frequency-shift-keyed (FSK)
sine-wave signal, without
affecting the average analogue
signal.
HART uses low frequencies
(1200Hz and 2200 Hz) to deal
with poor cabling, its rate is
1200 Bd - but sufficient.
HART uses Bell 202 modem
technology, ADSL technology
was not available in 1989, at
the time HART was designed
Transmission of device characteristics is normally not real-time critical

Industrial Automation

3.3 Standard Field Busses

HART - Protocol
Hart communicates point-to-point, under the control of a master, e.g. a hand-held device
Master

Slave
Indication

Request

time-out

Response
Confirmation

Hart frame format (character-oriented):


preamble

start

address

5..20
(xFF)

1..5

Industrial Automation

command bytecount
1

10

[status]

data

data

[2]
0..25
(slave response) (recommended)

checksum
1

3.3 Standard Field Busses

HART - Commands

Universal commands (mandatory):


identification,
primary measured variable and unit (floating point format)
loop current value (%) = same info as current loop
read current and up to four predefined process variables
write short polling address
sensor serial number
instrument manufacturer, model, tag, serial number, descriptor,
range limits,

Common practice (optional)


time constants, range,
EEPROM control, diagnostics,
total: 44 standard commands, plus user-defined commands
Transducer-specific (user-defined)
calibration data,
trimming,
Industrial Automation

11

3.3 Standard Field Busses

HART - Importance

Practically all 4..20mA devices come equipped with HART today

About 40 Mio devices are sold per year.

more info:

http://www.hartcomm.org/
http://www.thehartbook.com/default.asp

Industrial Automation

12

3.3 Standard Field Busses

3.3.3 ASI

Small installation bus

2005 April, HK

ASI (1) - Sensor bus Wiring


ASI = Actor-Sensor Interface
Very simple sensor bus for building automation, combining power and data on the same
wires, transmitting mostly binary signals

mechanically coded flat cable


- two wires for data and power
insulation piercing connectors
- simple & safe
- protection class up to IP67,
even after disconnecting

D0 = sensor 1
one connection

D1 = sensor 2

directly connected slaves


- sensors, actuators
- valve terminals
- electrical modules etc.

D2 = actuator 1
AS-Interface
Slave IC
1 module
enclosure

D3 = actuator 2
P0

Watchdog
energy

up to 4 sensors
or/and
4 actuators

vampire-connector
Industrial Automation

14

3.3 Standard Field Busses

ASI (2) - Data sheet

master-slave principle
up to 31 slaves on one line
cycle time < 5 ms

each slave can have up to


4 digital inputs + 4 digital outputs
additional 4 parameter bits / slave
Max. 248 digital Inputs and Outputs
also possible: analogue I/O (but ..)

controller

automatic address numbering


via bus connection

master

To Slave 1

To Slave 2

Slave 1

Slave 2

Industrial Automation

To Slave 31

Slave 31

To Slave 1

Slave 1

15

master calls
slave response

3.3 Standard Field Busses

ASI (3) - Topography

star

line

controller

controller

Master

controller

controller

Master

Master

Master
Slave

Slave

Slave
Slave

tree

branch lines

Slave

Slave

Slave

Slave

Slave

Slave
Slave

Slave

Slave

Slave

Slave

Slave

Slave
Slave

Slave
Slave

unshielded 2-wire cable

no terminating resistor necessary

data and power on one cable

free tree structure of network

extension: 100 m (300 m with extender)

protection class up to IP67

Industrial Automation

16

3.3 Standard Field Busses

3.3.4 Interbus-S

Discrete Manufacturing bus

2005 April, HK

Interbus-S (2) - Topology

Master
BA
remote "bus"
(ring)

optical fibres also available


localbus (flat cable)

BA

400 m between
devices

BC IO IO IO
5-wire

loop (2 wire, includes power)

bus coupler

Industrial Automation

18

3.3 Standard Field Busses

Interbus-S (4) - Analysis

+ standard in CENELEC

market centered on manufacturing

+ 1700 products, 270 manufacturers,


375.000 applications

limited number of variables (4096 bits)

+ good experience in field wiring


(intelligent wiring bar)

ring structure sensitive to disruptions

+ easy to engineer

sensitive to misplacement

+ easy to program (IEC 61131)

clumsy and slow message service

+ far extension (400m .. 13 km)

medium user community

+ good response time

few and costly tools

+ conformance test

strong ties to Phoenix Contact

Industrial Automation

19

3.3 Standard Field Busses

3.3.5 CAN

Automotive bus

2005 April, HK

CAN (1) - Data Sheet

Supporters
Standard
Medium
Medium redundancy
Connector
Distance
Repeaters
Encoding
User bits in frame
Mastership
Mastership redundancy
Link layer control
Upper layers
Application Protocols
Chips

Automotive industry, Intel/Bosch, Honeywell, Allen-Bradley


SAE (automotive), ISO11898 (only drivers), IEC 61158-x (?)
dominant-recessive (fibre, open collector), ISO 11898
none
unspecified
40m @ 1 Mb/s (A); 400m @ 100kb/s (B); 1000m @ 25kb/s (B)
unspecified (useless)
NRZ, bit stuffing
64
multi-master, 12-bit bisection, bit-wise arbitration
none (use device redundancy)
connectionless (command/reply/acknowledgement)
no transport, no session, implicit presentation
CAL, SDS, DeviceNet (profiles)
comes free with processor
(Intel: 82527, 8xC196CA; Philips: 82C200, 8xC592;
Motorola: 68HC05X4, 68HC705X32; Siemens: SAB-C167

Industrial Automation

21

3.3 Standard Field Busses

CAN (2) - Analysis

Unix" of the fieldbus world.

+ strong market presence, Nr 1 in USA


(> 12 Mio chips per year)
+ supported by user organisations
ODVA, Honeywell, AB.

limited product distance x rate (40 m x Mbit/s)


sluggish real-time response (2.5 ms)
non-deterministic medium access

+ numerous low cost chips, come free


with many embedded controllers

several incompatible application layers


(CiA, DeviceNet, SDS)

+ application layer definition

strongly protected by patents (Bosch)

+ application layer profiles

interoperability questionable (too many


different implementations)

+ bus analyzers and configuration tools


available
+ Market: industrial automation, automobiles
Industrial Automation

small data size and limited number of


registers in the chips.
no standard message services.
22

3.3 Standard Field Busses

3.3.6 Profibus

The process bus

2005 April, HK

Profibus - Family

PROFIBUS-DP (Distributed Processing)


Designed for communication between programmable logic controllers and
decentralized I/O, basically under the control of a single master
Replaces parallel signal transmission with 24 V or 0 to 20 mA by intelligent DIN rail
PROFIBUS-PA (Process Automation)
Permits data communication and power over the bus using 2-wire
Connects sensors and actors on one common bus line even in intrinsically-safe areas.
(chemical industry)
Physical Layer according to international standard IEC 61158-2.
PROFIBUS-FMS (Field Messaging Specification)
General-purpose for peer-to-peer communication at the cell level.
Can be used for extensive and complex communication tasks.
Academic approach (layer 7 services based on MMS, ISO 9506).
Disappearing

Industrial Automation

24

3.3 Standard Field Busses

Profibus - Stack

FMS
FMS
device
profiles

DP

PA

DP-profiles

PA-profiles

DP basic functions

Upper layers

Fieldbus
Messaging
Specification

Link
Phy

IEC interface
RS 485

Industrial Automation

Fibre optics

25

IEC 61158-2

3.3 Standard Field Busses

Profibus - Data sheet


Topography:
Medium:
Signaling:
Integrity
Collision
Medium redundancy
Medium Access
Communication chip
Processor integration
Cycle Time
Address space
Frame size (useful data)
Link Layer Services

Industrial Automation

bus
TWP @ 31.25 kbits/s (intrinsic safety), 10 devices (PA)
RS 485 @ 19.2 kbit/s.. 500 kbit/s (FMS)
RS 485 or fibres @ 1.5 Mbit/s (12 Mbit/s) (DP)
PA: Manchester II, preamble, delimiters
DP, FMS: UART 11 bit/character
CRC8, HD = 4
none under normal conditions
not supported by the controller
DP: central master, cyclic polling (see: 3.1.2)
FMS, PA: token passing
dedicated chips for 12 Mbit/s
can use UART interface on most processors directly
depends on number of slaves (cyclic, not periodic)
8 bit device address
up to 512 bits in Process Data, 2048 bits in messages
SDN
SDA
SRD
CSRD

Send Data with No acknowledgement


Send Data with Acknowledgement
Send and Request Data with reply
Cyclic Send and Request Data with reply
26

3.3 Standard Field Busses

Profibus - Analysis

MS-DOS of the fieldbus world


Standardized by CENELEC (EN 50 170-3)
Exists in four incompatible versions (FMS,
DP, PA, 12 Mbit/s), evolving specifications.
Wide support by Siemens
(Profibus DP is backbone of Simatic S7)
Most products do not implement all the
and active Profibus User Organization
Profibus functionality, interoperability is
(PNO) with >1000 companies.
questionable outside of one manufacturer
200,000 applications, > 2 Mio devices
Additional protocols exist within Siemens
Low entry price (originally simple UART
Weak physical layer (RS 485 at 1,5 Mb/s);
protocol at 500 kbit/s with RS 485 drivers)
to remedy this, a 12 Mb/s version has been
Several implementations based on most
developed (does not significantly improve
commons processors and micro controllers
response time, but limits distance).
(8051, NEC V25, 80186, 68302).
Development tools available (Softing, I-tec).
Extended Application Layer (FMS) and
Network Management (SM7, SM2)
Market: industry automation

Industrial Automation

Complex configuration - all connections


must be set up beforehand (except
network management): tools required.
Little used outside of Europe (identified in
USA / Asia with Siemens/Germany )
27

3.3 Standard Field Busses

3.3.7 LonWorks

The building automation bus

2005 April, HK

LON (1) - Data sheet

Communication chip
Medium redundancy:
Signalling:

bus
STP 150 Ohm @ 1.25 Mbit/s 300m, transformer-coupling
UTP 100 Ohm, @ 78 kbit/s, 1300m, transformer-coupling
reduced to 100m with free topology
power line carrier @ 9.6 kbit/s, limited by -55dB
radio @ 4.9 kbit/s
Neuron chip (Motorola, Hitachi)
none
Differential Manchester for STP, UTP

Medium access:
Response Time
Address space
Frame size (useful data)
Integrity
Higher-level protocols
Application
Support

p-persistent CSMA/CD
3 ms (single call/reply), 400 exchanges/s @ 1.25 Mbit/s
32385 stations
up to 1824 bits
CRC16, HD = 2 against steps, =1 against sync slips)
full 7-layer stack
programmed in Neuron-C
LONMark group (www.echelon.com)

Topography:
Medium:

Industrial Automation

29

3.3 Standard Field Busses

LON (2) - Stack


Application
network variable exchange,
application-specific RPC, etc..

network management

Session Layer
request-response

Transport Layer
acknowledged and unacknowledged, unicast and multicast

Authentication

server
Transaction Control Sublayer
common ordering and duplicate detection

Network Layer
connectionless, domain-wide broadcast,
no segmentation, loop-free topology, learning routers

Link Layer
connectionless frame transfer,
framing, data encoding, CRC error detection
MAC sublayer
predictive p-persistent CSMA: collision avoidance;
optional priority and collision detection
Physical Layer
multiple-media, medium-specific protocols (e.g. spread-spectrum)

Industrial Automation

30

3.3 Standard Field Busses

LON (3) - Analysis

"Macintosh" of the fieldbus world

sluggish response time: > 7ms per variable.

+ several media, products, protocols,


networking, support, starter kits, tools
and documentation.
+ easy, plug-and-play access.

cannot be used in a fast control loop such


as drives or substation protection.

+ low chip costs (10$), but a LON


subprint costs about 500$.

non-deterministic medium access


(p-persistent CSMA)

+ only fieldbus in industry (except for IEC's


TCN) which supports interoperability of
networks of different speeds.

low data integrity due to the use of


differential manchester encoding and
lack of frame delimiter / size field.

+ only fieldbus to provide authentication.

no conformance testing

+ standard network variable types


definition (SNVT).

can only be accessed through Echelon tools

+ standard device description


(LonMarks), access to IEC 1131.

strong ties to Echelon


(net profit in 01Q1: 20000 $)

+ market: building automation


Industrial Automation

31

3.3 Standard Field Busses

3.3.8 Ethernet

The universal bus

To probe further: "Switched LANs", John J. Roese, McGrawHill, ISBN 0-07-053413-b


"The Dawn of Fast Ethernet"
2005 April, HK

The Ethernet consortia


Ethernet/IP (Internet Protocol), Rockwell Automation
www.rockwellautomation.com

IAONA Europe (Industrial Automation Open Networking Alliance, (www.iaona-eu.com)


ODVA (Open DeviceNet Vendors Association, www.adva.org)
CIP (Control and Information Protocol) DeviceNet, ControlNet
ProfiNet
Siemens (www.ad.siemens.de), PNO (www.profibus.com)
Industrial Ethernet new cabling: 9-pin D-shell connectors
direct connection to Internet (!?)
Hirschmann (www.hirschmann.de)
M12 round IP67 connector

Fieldbus Foundation (www.fieldbus.org): HSE FS 1.0


Schneider Electric, Rockwell, Yokogawa, Fisher Rosemount, ABB
IDA (Interface for Distributed Automation, www.ida-group.org) Jetter, Kuka, AG.E, Phoenix Contact, RTI, Lenze, Schneider Electric, Sick
www.jetter.de

Industrial Automation

33

3.3 Standard Field Busses

Ethernet - another philosophy


Ethernet + Fieldbus
(classical)

SCADA
switch
Ethernet
PLC

cheap field devices


decentralized I/O
cyclic operation

PLC

PLC

Fieldbus
simple
devices

Ethernet as Fieldbus
(trendy)

SCADA

switch

Ethernet
costly field devices
Soft-PLC as concentrators
Event-driven operation

Soft-PLC

Soft-PLC

Soft-PLC

Soft-PLC

This is a different wiring philosophy.


The bus must suit the control system structure, not the reverse
Industrial Automation

34

3.3 Standard Field Busses

The "real-time Ethernet"


The non-determinism of Ethernet makes it little suitable for the real-time world.
Several improvement have been made, but this is not anymore a standard solution.
Method 1: Common clock synchronisation: return to cyclic.
Master clock

Method 2: IEEE 1588 (Agilent)


PTP precision time protocol
Method 3: Powerlink
B&R, Kuka, Lenze, Technikum Winterthur
www.hirschmann.de, www.br-automation.com, www.lenze.de, www.kuka.de

Method 4: Siemens Profinet V3


synchronization is in the switches
Industrial Automation

35

3.3 Standard Field Busses

Ethernet and fieldbus roles


Ethernet is used for the communication among the PLCs and for communication of the
PLCs with the supervisory level and with the engineering tools
Fieldbus is in charge of the connection with the decentralized I/O and for time-critical
communication among the PLCs.

local I/O

CPU

fieldbus
Ethernet
Industrial Automation

36

3.3 Standard Field Busses

Time- and safety-critical busses for cars


Contrarily to those who say fieldbus is dead, Ethernet takes it all
automobile manufacturers are developing several real-time busses for X-by-wire:

www.can.bosch.com

www.flexray-group.com

www.tttech.com
Industrial Automation

37

3.3 Standard Field Busses

Car network

extreme low cost, low data rate (100 kbit/s) for general use (power slides)
extreme reliability, excellent real-time behavior for brake-by-wire or drive-by-wire
Industrial Automation

38

3.3 Standard Field Busses

The automotive busses

Mbit/s
50.0

20.0
FlexRay (10 Mbit/s)

10.0

D28, MOST
Token-Ring
optical bus

byteflight
(10 Mbit/s)

5.0

TTP
TDMA, fault-tolerant
2 x 2 wire, 2 Mbit/s

2.0
1.0

CAN-A
2-wire
1 Mbit/s

0.5

MVB

CAN-B
fault-tolerant

0.2
0.1

J1850

0.05
0.02

LIN
Master-Slave
1-wire, not clocked

1
Industrial Automation

5
39

10

20 / node
3.3 Standard Field Busses

Wireless fieldbus

Increasingly, fieldbus goes wireless (802.11b, 802.11g. Bluetooth, ZigBee, WiMax


Advantages: mobility, no wiring

Disadvantages:
Base stations are still costly,
work in disturbed environments and metallic structures costs
mobile = batteries
distance = 30m in factories
lifetime > 5 years ?
privacy

Industrial Automation

40

3.3 Standard Field Busses

Wireless Technologies

costs
high
GPRS
medium
WLAN
low

bluetooth

0.1

10

100 Mbit/s
source: aktuelle Technik, 4/05

Industrial Automation

41

3.3 Standard Field Busses

Safety bus: The organisations

www.fieldbus.org

www.iec.ch

www.interbusclub.com

www.nfpa.org

www.odva.org

www.phoenixcon.com

www.pilz.com

www.profibus.com

www.roboticsonline.com

www.rockwellautomation.com

www.safetybus.com

www.tuv.org

Industrial Automation

42

3.3 Standard Field Busses

Future of field busses

Non- time critical busses are in danger of being displaced by LANs (Ethernet)
and cheap peripheral busses (Firewire, USB)
In reality, these "cheap" solutions are being adapted to the industrial environment
and become a proprietary solution (e.g. Siemens "Industrial Ethernet")
The cost objective of field busses (less than 50$ per connection) is out of reach for
LANs.

The cabling objective of field busses (more than 32 devices over 400 m) is out of reach
for the cheap peripheral busses such as Firewire and USB.
Fieldbusses tend to live very long (10-20 years), contrarily to office products.
There is no real incentive from the control system manufacturers to reduce the
fieldbus diversity, since the fieldbus binds customers.
The project of a single, interoperable field bus defined by users (Fieldbus Foundation)
failed, both in the standardisation and on the market.

Industrial Automation

43

3.3 Standard Field Busses

Fieldbus Selection Criteria

Installed base, devices availability: processors, input/output


Interoperability (how likely is it to work with a product from another manufacturer
Topology and wiring technology (layout)
Power distribution and galvanic separation (power over bus, potential differences)
Connection costs per (input-output) point
Response time

Deterministic behavior
Device and network configuration tools
Bus monitor (baseline and application level) tools
Integration in development environment

Industrial Automation

44

3.3 Standard Field Busses

Industrial Automation
Automation Industrielle
Industrielle Automation

4 Access to devices
4.3 OLE for Process Control (OPC)
4.3.1 Common elements

2006 May, HK

ABB Research Centre, Baden, Switzerland

Executive Summary
OPC is a set of standard commands collected in a software library (DLL) that can be called by
client applications, written in Visual Basic, C# or other Microsoft programming languages, that allow
to access automation devices (PLCs) in a uniform way, independently from their built or
manufacturer.
To that effect, the particularities of the automation devices are hidden by an OPC server running
either on the same machine as the client program or on another machine, by using DCOM. The
OPC Servers are supplied by the manufacturer of the PLC or by 3rd parties and can manage
several PLCs of the same type. Several servers can run in parallel.
The OPC library allows in particular to read and write process variables, read alarms and events
and acknowledge alarms, and retrieve historical data from data bases according to several criteria.
Automation platforms such as ABB's 800XA platform act as OPC clients to collect data from PLCs
or databases through third-party OPC servers. Several automation platforms act themselves as an
OPC server to publish their data, events and historical data.
OPC is the preferred connectivity for 78% of MES, 75% of HMI / SCADA, 68% of DCS / PLC and
53% or ERP /Enterprise system level applications (according to Arc Advisory Group, 2004)"

keep on reading even if you are not an executive....


Industrial Automation

2/32

4.3.1 OPC Common

OPC Common Overview

OPC Common
Overview: usage and specifications
OPC as an integration tool
Clients and Servers: configuration
Automation and Custom Interface
OPC Data Access
Overview: Browsing the server
Objects, Types and properties
Communication model
Simple Programming Example
Standard and components

OPC Alarms and Events Specification


Overview: definitions and objects
Events
Alarm Conditions
Automation Interface
OPC Historical Data Specification
Overview
Industrial Automation

3/32

4.3.1 OPC Common

What is OPC ?
OPC (formerly: "OLE1 for Process Control", now: "Open Process Control") is
an industry standard set up by the OPC Foundation
specifying the software interface (objects, methods) to a server that
collects data produced by field devices and programmable logic controllers.
interfaces
covered by the
OPC standard

application
(OPC client)

OPC server
X

OPC server
(simulator)

Ethernet
(not covered)

node
servers
OPC server
Y

Field bus
(not covered)

PLCs Brand X

PLCs Brand Y

Sensors/Actors
1) OLE (Object Linking and Embedding) is a Microsoft technology for connecting software components.
It has since been extended by the COM / DCOM technology. It corresponds to Java Beans.

Industrial Automation

4/32

4.3.1 OPC Common

Before OPC
visualization
history
data base

MasterBus
MMS driver

ABB PLCs
Industrial Automation

XWAY
driver

Profinet
driver

Tlmcanique PLCs
5/32

Siemens PLCs
4.3.1 OPC Common

With OPC: ABB Operator Workplace Connection


OperatorIT

Historian
(Information
Manager)

application software is
written independently from
the type of controller

the drivers still exist,


but the clients do not
see them anymore

ABB AC800M
Industrial Automation

AC800M
OPC server

Schneider
OPC server

Siemens
OPC server

MMS

XWAY

ProfiNet

Tlmcanique TSX
6/32

Siemens S7
4.3.1 OPC Common

Importance

OPC is the greatest improvement in automation since IEC 61131.


OPC is supported by the OPC foundation (http://www.opcfoundation.org/)
More than 150 vendors offer OPC servers to connect their PLCs, field bus devices,
displays and visualization systems.
OPC is also used for data exchange between applications and for accessing databases
OPC is available as DLL for Automation Interface (Visual Basic,..) and Custom (C++,..)
OPC consists of three major components:
1) OPC - DA = Data Access (widespread, mature)
2) OPC - AE = Alarms and Events (not yet much used)
3) OPC - HDA = Historical Data Access (seldom used)
and some profiles (batch,)

Industrial Automation

7/32

4.3.1 OPC Common

The main OPC Specifications

OPC
DX

OPC
Batch

OPC
HDA

batch
system

history
data base

OPC
Data Access

OPC
Alarms & Events
OPC
UA

Industrial Automation

8/32

4.3.1 OPC Common

Specification 1: OPC DA for Data Access


Process variables describe the plant's state, they are generated by the sensors or
calculated in the programmable logic controllers (PLCs).

Process variables can be sent upon a change, on demand or when a given time elapsed.
The OPC DA (Data Access) specification addresses collecting Process Variables.
The main clients of OPC DA are visualization and (soft-) control.

Industrial Automation

9/32

4.3.1 OPC Common

Specification 2: OPC AE for Alarms and Events

Events are changes in the process that need to be logged, such as "production start"
Alarms are abnormal states in the process that require attention, such as "low oil pressure"
OPC AE (Alarms and Events) specifies how alarms and events are subscribed, under
which conditions they are filtered and sent with their associated messages.
The main clients of OPC AE are the Alarms and Event loggers.
determine the exact time of change
(time stamping)
categorize by priorities
log for further use
acknowledge alarms
(events are not acknowledged)
link to clear text explanation

Industrial Automation

10/32

4.3.1 OPC Common

Specification 3: HDA for Historical Data Access


Historical Data are process states and events such as: process variables, operator actions,
recorded alarms,... that are stored as logs in a long-term storage for later analysis.
OPC HDA (Historical Data Access) specifies how historical data are retrieved from the logs
in the long-term storage, filtered and aggregated (e.g. compute averages, peaks).
The main client of OPC HDA are Trend Displays and Historians.

Industrial Automation

11/32

4.3.1 OPC Common

Specification 4: OPC Batch


based on:
IEC 61512-1 Batch Control Part 1: Models and Terminology
(ANSI/ISA S88.01 1995)
ISA-dS88.02-2000 draft 17 of May 2000
Procedure

consists of an
ordered set of

allows to access:

Unit
Procedure

equipment capabilities,
current operating conditions,
historical and
recipe contents

consists of an
ordered set of
Operation

consists of an
ordered set of
Phase

Industrial Automation

12/32

4.3.1 OPC Common

Beyond Microsoft: OPC UA

In a move to get more independence from Microsoft and use web technology,
a new specification called " Unified Architecture" (formerly. OPC XML) that uses web
services for all kinds of transactions: query, read, write, subscribe,...

The classical OPC DA, AE and HDA are implemented with XML / SOAP /WSDL
this allows encryption and authentication of process data.
This does not only standardize the interfaces, but also the transmitted data.

Industrial Automation

13/32

4.3.1 OPC Common

OPC as an integration tool


OPC Common
Overview: usage and specifications
OPC as an integration tool
Clients and Servers: configuration
Automation and Custom Interface
OPC Data Access
Overview: Browsing the server
Objects, Types and properties
Communication model
Simple Programming Example
Standard and components

OPC Alarms and Events Specification


Overview: definitions and objects
Events
Alarm Conditions
Automation Interface
OPC Historical Data Specification
Overview
Industrial Automation

14/32

4.3.1 OPC Common

OPC as a hub

OPC variables is also a convenient way to exchange data between applications


on the same machine. OPC data can be easily read in any Microsoft Office application

source: Siemens WinCC

Industrial Automation

15/32

4.3.1 OPC Common

OPC connection to databases


Tools such as LifeWires allow to build an OPC DA interface to any ODBC - equipped
database.
The database internal structure (exposed through queries) is reflected as a hierarchy
of OPC items.
This allows to give a unified access to simple items.

application
(OPC client)

OPC server
ODBC

DB

Industrial Automation

16/32

4.3.1 OPC Common

OPC for internal communication: AIP as example

ABB's Integration Platform (AIP) is at the same time an OPC server and an OPC client.
Components (aspects) within AIP expose their properties as OPC objects.
Internal (within AIP) and external communication takes place over OPC.
AIP
aspects
aspects
aspects
aspects

Asset
Optimizer

Enterprise
Historian

OPC server

process
data base

OPC
connections
OPC client

AC800M
OPC server
Industrial Automation

Schneider
OPC server
17/32

Siemens
OPC server
4.3.1 OPC Common

OPC Connection to Enterprise Resource Planning

Direct connection to SAP (BAPI) is provided by tools such as Matrikon's or Intellution's

Industrial Automation

18/32

4.3.1 OPC Common

Simulators and Explorer: which helps are available

Explorer:
Several tools are available on the market to browse OPC servers, especially:

- Matrikon OPC Explorer (no source code)


- TopServer Client (source code in VB available)
Simulator:
OPC data should be simulated before commissioning the real plant.
To this effect, commercial simulation servers allow to create, observe and change
variables by hand or according to time functions (ramp, random,).
Most PLC servers have also a simulation mode.
Freeware servers such as Matrikon have only limited number of variables
These explorers and simulators work with OPC DA, AE is yet seldom.

Industrial Automation

19/32

4.3.1 OPC Common

Client and Servers


OPC Common
Overview: usage and specifications
OPC as an integration tool
Clients and Servers: configuration
Automation and Custom Interface
OPC Data Access
Overview: Browsing the server
Objects, Types and properties
Communication model
Simple Programming Example
Standard and components

OPC Alarms and Events Specification


Overview: definitions and objects
Events
Alarm Conditions
Automation Interface
OPC Historical Data Specification
Overview
Industrial Automation

20/32

4.3.1 OPC Common

Server(s) and Client(s) in the same node


node
client application
(OPC client)

OPC server

devices

client application
(OPC client)

OPC server

devices devices

OPC server

devices

Clients and servers run as parallel processes

The OPC specification defines the interface between client and server in the form
of objects and methods.

Industrial Automation

21/32

4.3.1 OPC Common

Direct and Fieldbus access


direct connection
client application
(OPC client)
(local)
OPC server

fieldbus connection
client application
(OPC client)

clients and
servers run as
parallel
processes

(local)
OPC server
FB Manager
fieldbus
proprietary
protocol

I/O devices

The OPC server is running


all the time, as soon as at
least one client is present

Industrial Automation

can also be
a point-topoint link

22/32

fieldbus

fieldbus

FB agent

FB agent

PLC

PLC

4.3.1 OPC Common

Accessing a server in another node

client application
(OPC client)
stub
DCOM

TCP/IP
DCOM

Limitation:
does not work over firewalls.
Solution:
OPC XML (see later)

Industrial Automation

TCP/IP

TCP/IP

DCOM

DCOM

OPC
server

OPC server
FB Manager

fieldbus

23/32

4.3.1 OPC Common

Full-fledged COM/DCOM across multiple nodes


connectivity node
Ethernet

app3 TCP/IP

OPC server
for BrandZ

TCP/IP

node 1

application 2
(OPC client)

application 1
(OPC client)

OPC server
for BrandY

OPC server
for BrandX

Fieldbus
Y

Fieldbus X

panel
OPC server
for simulation

drivers

input / output to plant


The OPC servers supports multiple clients and servers on the same, or on remote nodes.
they run as separate processes (as soon as at least one client is requesting them)
Industrial Automation

24/32

4.3.1 OPC Common

Example: ABB AC800 OPC Server


Process Portal
(client)

Matrikon
client

separate
processes

IEC 61131
Programming
Environment

config
files

(Control Builder)

user panels

AC800
OPCserver

OPCServer
config

MMS

MMS Panel

TCP/IP

by FTP or internal
Ethernet

TCP/IP
MMS

PLC variables

The variables are defined in the server, not in the PLC.


Industrial Automation

25/32

4.3.1 OPC Common

OPC Technology
OPC Common
Overview: usage and specifications
OPC as an integration tool
Clients and Servers: configuration
OPC Technology, client and custom interface
OPC Data Access
Overview: Browsing the server
Objects, Types and properties
Communication model
Simple Programming Example
Standard and components

OPC Alarms and Events Specification


Overview: definitions and objects
Events
Alarm Conditions
Automation Interface
OPC Historical Data Specification
Overview
Industrial Automation

26/32

4.3.1 OPC Common

COM/DCOM quick intro


1) same process

client

2) different processes
same computer

client

3) different computers

client

library
(DLL)

stub

proxy

local
procedure
call

local
procedure
call

stub
remote
procedure
call

COM/DCOM (COM+) maintains


the same interface regardless of
the location of the components
Industrial Automation

memory

TCP/IP

27/32

proxy

network

library

library

remote
procedure
call
TCP/IP

4.3.1 OPC Common

OPC technologies

ActiveX
Object Linking and
Embedding (OLE)

OLE for Process


Control (OPC)

(Distributed) Component Object Model


(COM / DCOM)
only between
nodes

Transport
(TCP-IP, UDP, Queued)
Ethernet

OPC bases on Microsoft's COM/DCOM technology (i.e. it only works on Windows platforms).
Effort to port it to other platforms (Linux) and web transport protocols (XML) are in progress.
Advantages are the direct integration into all applications, such as Excel.

Industrial Automation

28/32

4.3.1 OPC Common

Three-tiers Active-X components

graphical interface

business logic

storage and communication

Industrial Automation

29/32

4.3.1 OPC Common

Structure of an OPC server

OPC/COM Interfaces
OPC Group & Item Management

Item Data Optimization and Monitoring


Device Specific Protocol Logic
Hardware Connection Management

Industrial Automation

30/32

4.3.1 OPC Common

Automation vs. Custom interface


The OPC specifications define two interfaces: "custom" and "automation".
custom is the native C++ interface of COM.
automation is the interface offered in Visual Basic, used in Word, Excel,..
The interface is defined by a Type Library (distributed by the OPC Foundation)
Functionality is roughly the same in both models, automation is easier to use,
but "custom" gives a more extended control.
"Automation" client

(Visual Basic, Excel,)

"Custom" client
(C++,.)

OPC Automation
wrapper

custom interface

custom interface
server

server
Industrial Automation

server

31/32

4.3.1 OPC Common

Industrial Automation
Automation Industrielle
Industrielle Automation

4 Access to devices
4.3 OLE for Process Control (OPC)
4.3.2 Data Access Specification

2005 May, HK

ABB Research Centre, Baden, Switzerland

OPC DA: Overview


OPC Common
Overview: usage and specifications
OPC as an integration tool
Clients and Servers: configuration
OPC Technology, client and custom interface
OPC Data Access
Overview: Browsing the server
Objects, Types and properties
Communication model
Simple Programming Example
Standard and components

OPC Alarms and Events Specification


Overview: definitions and objects
Events
Alarm Conditions
Automation Interface
OPC Historical Data Specification
Overview
Industrial Automation

2/48

4.3.2 OPC DA

To probe further.
OPC Foundation:
Specifications http://www.opcfoundation.org
SoftwareToolbox
Examples in Visual Basic
http://www.softwaretoolbox.com/Tech_Support/TechExpertiseCenter/OPC/opc.html

The Code Project


OPC and .NET
http://www.codeproject.com/useritems/opcdotnet.asp

Matrikon
Free client and server:
http://www.matrikon.com

WinTech
Toolkit for an OPC server
http://www.win-tech.com/html/opcstk.htm

NewAge Automation
Toolkit for an OPC server
http://www.newageautomation.com

Industrial Automation

3/48

4.3.2 OPC DA

OPC DA: Scope of specification

OPC DA Client
e.g. visualization

OPC DA Client
e.g. performance
indicator

OPC DA
specified
interface
OPC DA Server

An OPC DA Server
is configured using
the information
coming from the
development tools
for the controllers
Variables defined
in the controllers
are mirrored to the
OPC DA server

e.g. Ethernet

tags

controllers
controller

controller
field bus

plant
measurement
points

Industrial Automation

field devices

4/48

4.3.2 OPC DA

OPC DA: Example of access to a variable

controller development

OPC application

Reactor_1.Program2

ReadItem
("OPC:Reactor1:
Program2.MotorSpeed")

Value: 112

OPC
server

load
symbol
table

MW%1003

MotorSpeed

MW%1004

Temperature

symbols
code

Get (192.162.0.2), MW%1003)

Return (MW%1003, 112)

Network
Reactor_1
Marker: MW%1003

analog input to : IXD.11.2.1

Industrial Automation

Oven controller

5/48

4.3.2 OPC DA

OPC DA: Objects as viewed by the OPC server


An OPC server is structured as a directory with root, branches and leaves (items)

Process Line 1

Tag Name

Controller 1
Controller 2
Controller_3.Prog_1
Controller_3.Prog_2

TAG

Level_1

TAG

Level_2

TAG

Ramp4

An item is identified by its


"fully qualified ItemID",
e.g.
"Process_Line_1.Controller_2.Level_2"

Cell 1

the hierarchical position may differ from


the fully qualified ItemID
this will be detailed under browsing

Machine 2

Branches may contain other branches and items


The structure may also be flat instead of hierarchical
This structure is defined during engineering of the attached devices and sensor/actors.
(Intelligent servers could configure themselves by reading the attached devices)

Industrial Automation

6/48

4.3.2 OPC DA

OPC DA: Browsing - methods


An OPC DA server presents an interface that allows the client to explore its structure,
with the methods:
MoveDown
MoveUp
MoveToRoot

showBranches
showLeafes *
GetItemID : retrieves the fully qualified item ID (see later)
Optional:
GetAccessPath: retrieves the access path for items that can be accessed over different ways.
The Access Path is an optional information that the client may provide regarding how to get to the
data, where several possibilities exist. Its use is highly server specific. Do not confound with
hierarchical path.
(*the English error is unfortunate)

Industrial Automation

7/48

4.3.2 OPC DA

OPC DA: Browsing: Fully Qualified ItemID and hierarchy


A server has internally two ways to access the items:
1) the path shown when exploring the tree, and
2) the fully qualified ItemID, which is the internal name used by the server.

Example:
an item reached as:
needs to be accessed internally as:

Root.SimulatedItems.UserDefined.Ramp.Ramp1
UserDefined!Ramp.Ramp1

Clients usually look for an item though the hierarchical way.


They position the browser on the corresponding branch and retrieve the fully qualified
item ID, which is the name of the item as the server understands it.
The fully qualified name is only used at configuration time, afterwards, objects are
accessed over client handles and server handles (see later)

Industrial Automation

8/48

4.3.2 OPC DA

OPC DA: Objects as viewed by the OPC client


Each client structures its items by groups,
independently from the server.

clients

Initially, the client browses the server structure to


check if the items it is interested in exist.
A client registers its groups and items at the server.
The server keeps the structure of all its clients.
Server root

Client1

GroupX

Client2

GroupZ

Item1 Item2 Item3 Item1 Item2

server

Area 1
TAG

Temperature

TAG

Heat_On

TAG

Level

Area 2

TAG

Empty_Valve

Area 51

TAG

Fill_Valve

Oven_1

Tank_1

Industrial Automation

9/48

4.3.2 OPC DA

OPC DA: Client Handle and Server handle


client 1
group1

client 2
group2

1, 76584
2, 87689
3, 23443

3, 53664
4, 43222

client1
The fully qualified item
is not sufficient to identify
an item, a client may
subscribe the same item
in different groups

3, 54
2, 1201

group1
1, 1
2, 2
3, 3

client2
x
2, 2

3, 1202
1,1
2, 2

The pair { ClientHandle, ServerHandle } uniquely identifies an item.

Industrial Automation

10/48

4.3.2 OPC DA

OPC DA: Object Types and properties


OPC Common
Overview: usage and specifications
OPC as an integration tool
Clients and Servers: configuration
OPC Technology, client and custom interface
OPC Data Access
Overview: browsing the server
Objects, types and properties
Communication model
Simple Programming Example
Standard and components

OPC Alarms and Events Specification


Overview: definitions and objects
Events
Alarm Conditions
Automation Interface
OPC Historical Data Specification
Overview
Industrial Automation

11/48

4.3.2 OPC DA

OPC DA: Item properties


The process data are represented by three dynamic properties of an item:
value:

numerical or text

time-stamp:

the time at which this data was transmitted from the PLC to the server
this time is UTC (Greenwich Winter time), not local time.

quality:

validity of the reading (not readable, dubious data, o.k.)

(when writing, only the value is used)

Industrial Automation

12/48

4.3.2 OPC DA

OPC DA: Item types


Each item value has a type:

Boolean,
Character,
Byte,
(1 byte)
Word, (2 bytes)
Double Word, (4 bytes)
Short Integer (2 bytes)
Integer (4 bytes)
Long Integer:
Long Unsigned Integer
Single Float (4 bytes)
Double Float (8 bytes)
Currency,
Date,
String,
Array of "the above"

Industrial Automation

When accessing an item, the client may request


that it is returned with a specific type, which could
be different from the server's type.
(The server's type is returned by browsing)
Type conversion is left to the server, there are no rules
whether and how a server does the conversion.
(use with caution)
Care must be taken that the data types in the
programming language or in the database match those
of the OPC Server.
Items also may have engineering units, but this option
is not often used.

13/48

4.3.2 OPC DA

OPC DA: Communication Model


OPC Common
Overview: usage and specifications
OPC as an integration tool
Clients and Servers: configuration
OPC Technology, client and custom interface
OPC Data Access
Overview: browsing the server
Objects, types and properties
Communication model
Simple Programming Example
Standard and components

OPC Alarms and Events Specification


Overview: definitions and objects
Events
Alarm Conditions
Automation Interface
OPC Historical Data Specification
Overview
Industrial Automation

14/48

4.3.2 OPC DA

OPC DA: Write Communication Models (per group)

client
myGroup.SynchWrite()

server
Call

client
myGroup.AsyncWrite()

Reply

server
Call
Reply

myGroup_AsyncWriteComplete()

The OPC interface accesses only groups, not individual items.


However, the "automation interface" allows to access individual items,
but this does not give rise to a communication

Industrial Automation

15/48

4.3.2 OPC DA

OPC DA: Read Communication Models (per group)


synchronous
client
myGroup.SynchRead()

asynchronous
server

client

Call

myGroup.AsyncRead()

Reply

server
Call
Reply

myGroup_AsyncReadComplete()

client
myGroup.IsSubscribed

on change
("subscription-based")

server

Subscribe

Notify
myGroup_DataChange()
Notify
myGroup_DataChange()

Industrial Automation

16/48

4.3.2 OPC DA

OPC DA: Transmission by subscription (events)


client
myGroup.IsSubscribed

server

Subscribe
Notify

myGroup_DataChange()
Notify

myGroup_DataChange()
myGroup.Refresh()
Notify
myGroup_DataChange()

The server notifies the client if an item changed


- in a particular group (myGroup_DataChange) or
- in any of the groups (myGroups_GlobalDataChange)
In the second case, only the group in which the item changed will be sent.
Industrial Automation

17/48

4.3.2 OPC DA

OPC DA: "Cache" or "Device" ?


"SynchRead" reads the data either from
cache (local to the PC) or
reads synchronous from the device.

client application
(OPC client)

"Write" is always to device


(DA 3.0 allows write to cache)

OPC server

synchronous call over


the field bus to the end
device (takes a while)

cache
server samples items
(at the RequestedUpdateRate)
and puts them into cache

FB manager
fieldbus
proprietary
protocol

fieldbus connection

no need for device access when


fieldbus operates cyclically

Industrial Automation

fieldbus

fieldbus

device

device

FB agent

FB agent

18/48

4.3.2 OPC DA

OPC DA: When are subscribed data transmitted ?


A group has two properties to control when a data change is to be transmitted:
myGroup.Refreshrate:
the rate at which the server samples the values, expressed in seconds ! (1/rate)
earliest interval between changes of value (throttles changes, but may miss some)
myGroup.Deadband
applied only to analog values: deadband = % the range (in Engineering Units).
value is transmitted if the difference since last transmission exceeds deadband.
Problem: applies to whole group without considering individual items, seldom implemented.
= refresh rate
max

range
deadband
min

time
Industrial Automation

19/48

4.3.2 OPC DA

OPC DA: communication paradigm


OPC DA works according to the shared memory paradigm.
This means that a newer value overwrites the older one, no queues or history are kept.
The server does not guarantee that different clients see the same snapshot of the plant.
The server does not guarantee that all changes to variables are registered,
changes may be missed if the polling period is too low.
OPC DA Client

OPC DA Client

OPC DA Server

Industrial Automation

20/48

4.3.2 OPC DA

OPC DA: Programming Example


OPC Common
Overview: usage and specifications
OPC as an integration tool
Clients and Servers: configuration
OPC Technology, client and custom interface
OPC Data Access
Overview: browsing the server
Objects, types and properties
Communication model
Simple Programming Example
Standard and components

OPC Alarms and Events Specification


Overview: definitions and objects
Events
Alarm Conditions
Automation Interface
OPC Historical Data Specification
Overview
Industrial Automation

21/48

4.3.2 OPC DA

OPC DA: Object hierarchy at the client


Description

OPCServer
OPCGroups (collection)

OPCGroup
OPCGroup
OPCItems (collection)

An instance of an OPC Server. You must create an OPCServer


object before you can get references to other objects. It contains
the OPCGroups Collection and creates OPCBrowser objects.
A collection containing all of the OPCGroup objects this client has
created within the scope of the OPCServer that the Automation
Application has connected to via OPCServer.Connect()
An instance of an OPCGroup object. this object maintains state
information and provides the mechanism to access data for the
OPCItems Collection object that the OPCGroup object references.
A collection containing all of the OPCItem objects this client has
created within the scope of the OPCServer, and corresponding
OPCGroup object that the Automation Application has created.

OPCItem
OPCItem
OPCItem

An automation object that maintains the items definition, current


value, status information, last update time. Note the Custom
Interface does not provide a separate Item Object.

OPCBrowser

An object that browses item names in the servers configuration.


There exists only one instance of an OPCBrowser object per
instance of an OPC Server object.

Industrial Automation

22/48

4.3.2 OPC DA

OPC DA: Automation interface summary

Industrial Automation

23/48

4.3.2 OPC DA

OPC DA: Program - initialising a connection


find out existing OPC servers

myDummyServer.GetOPCServers

create an OPCServer object

myServer = new OPCServer

connect to that OPC server

myServer.Connect

create an OPCBrowser object


create an OPCGroups object

Set myBrowser = myServer.Browser


Set myGroups = myServer.Groups

Set myGroup1 = myGroups.Add


Set MyItems = MyGroup1.OPCItems

create an OPCGroup object


build array of items
checking with the browser that
these items exist in this server

next
group

add item array to the group

myGroup1.AddItems
myGroup1.IsActive
myGroup1.IsSubscribed

activate and subscribe group

Industrial Automation

FQItems1[1] = "Device1.Temp1"
ClientHandle1[1] = 101
ReDim ServerHandle1(nrItems)
ReDim ServerErrors1(nrItems)
ReDim Value1(nrItems)

24/48

4.3.2 OPC DA

OPC DA: Program - Declarations

Option Base 1
Dim WithEvents MyServer
Dim WithEvents MyGroups
Dim WithEvents MyGroup
' items
Dim nrItems
As
Dim MyItems
Dim MyItem
Dim ItemsID(2)
Dim ClientHandles(2)
Dim ServerHandles()
Dim ServerErrors()

As OPCServer
As OPCGroups
As OPCGroup
Integer
As OPCItems
As OPCItem
As String
As Long
As Long
As Long

'OPC
'OPC
'OPC
'OPC

arrays indices start with 1


Server Object (Events optional)
Group Collection (Events opt.)
Group Object

'OPC Item Collection Object


'OPC Item Object
'fully qualified items (see later)
' must be a dynamic array
' must be a dynamic array

Reference: "OPC Automation 2.0" must be included into Visual Basic or C#


(if missing: copy opcdaauto.dll to C:\WINNT\System32\opddaauto)
and register it: C:\>regsvr32 C:\WINNT\System32\opddaauto.
A simple way to do it: install Software Toolbox's TopServer (freeware)
Industrial Automation

25/48

4.3.2 OPC DA

OPC DA: Program - Finding the OPC servers

The GetOPCServers function applied to a dummy Server object allow to list the existing
servers on this node or on another node (over DCOM - security must be set correctly).
The information about which OPC servers exist is taken from the registry, where it has been p
by each server at its installation time
Private Sub ShowServers(netNodeName As String)
Dim dummyServer As OPCServer
Dim Servers As Variant
Dim cntServers As Integer

' this is an array of strings

Set dummyServer = New OPCServer


Servers = dummyServer.GetOPCServers(netNodeName)

' create a dummy server object


' returns all available servers

For cntServers = LBound(Servers) To UBound(Servers)


MsgBox Servers(cntServers)
Next cntServers

' display the names

Set Getserver = Nothing


Exit Sub

Industrial Automation

' delete this object (was created by New)

26/48

4.3.2 OPC DA

OPC DA: Program - Connecting to the OPC server


Set MyServer = New OPCServer
' create server object
MyServer.Connect ("Matrikon.OPC.Simulation") ' connect to Matrikon server

Before connecting, it is safe to check the name of the server from the server's list.
Also, it is preferable to include the connection in a separate routine since it can fail:
Function ServerGetCare(Name As String, ServerNode As String) As OPCServer
On Error GoTo ServerGetCareErr
Dim MyOPCServer As New OPCServer
MyOPCServer.Connect ServerName, ServerNode ' connect risky
Set ServerGetCare = MyOPCServer
Exit Function
ServerGetCare_Err:
Err.Clear
MsgBox "Could not connect"
Set MyServer = Nothing
Exit Function

Industrial Automation

' error handler if connect fails

27/48

4.3.2 OPC DA

OPC DA: Program - Browsing the server


The object OPCBrowser (of type "collection") acts as a pointer to the server's tree:
Dim MyServer As OPCServer
Dim MyBrowser As OPCBrowser
Dim vName As Variant
MyServer.Connect "Matrikon.OPC.Simulation", "Orion"

'server and node name (DCOM)

Set MyBrowser = MyServer.CreateBrowser

' create an OPC browser

MyBrowser.ShowBranches
For Each vName In MyBrowser
MsgBox "Branch: " & vName
Next vName

' show the branches

MyBrowser.ShowLeafs
For Each vName In MyBrowser
MsgBox "Leaf: " & vName
Next vName

' explore the leaves

Industrial Automation

' display the branch name

' display the leaves's name

28/48

4.3.2 OPC DA

OPC DA: Navigating

MyBrowser.MoveDown (strBranch)

' go down the selected branch tree

MyBrowser.MoveUp

' go up the selected branch tree

Server root

server

Site A

TAG

site properties

Tank

Machine Room

TAG

Level

TAG

Temperature

TAG

Valve_On

Wash Room
Grinder
Climate
Store

There may be leaves at every branch, since a branch may have properties

Industrial Automation

29/48

4.3.2 OPC DA

OPC DA: Program - get the Fully Qualified ItemID

To get the "fully qualified itemID", one positions the browser at the place where the
leaf is attached to the branch and calls GetItemID

myOPCBrowser.MoveDown("TankArea")
myOPCBrowser.MoveDown("Tank1")
FQI = myOPCBrowser.GetItemId ("Level")

e.g. FQI could be "Controller1;Tanks!Level"


Of course, one can write an Item ID directly when defining a group, but it is safer to
browse the server and get the FQI from there, since the delimiter depends on the server.

Industrial Automation

30/48

4.3.2 OPC DA

OPC DA: Program - Creating OPCGroups and OPCItems


Set MyGroups = MyServer.OPCGroups
Set MyGroup1 = MyGroups.Add("GRP1")
Set MyItems = MyGroup1.OPCItems

' create groups collection


' add group, name private
' define the OPCItems of group

FQItemIDs(1) = "Area2.Tank1.Level"
ClientHandles(1) = 5
FQItemIDs(2) = "Area2.Tank1.Temperature"
ClientHandles(2) = 6
nrItems = 2

'
'
'
'

fully qualified itemID


arbitrary
fully qualified itemID
arbitrary (but different)

MyItems.AddItems _
nrItems, _
FQItemIDs, _
ClientHandles, _
ServerHandles, _
ServerErrors

'
'
'
'
'
'

adds the items to collection


input parameter
input fully qualified ID
input ClientHandles
return parameter ServerHandles
return parameter ServerErrors

MyGroup1.ClientHandle = 1
MyGroup1.IsActive = True
MyGroup1.IsSubscribed = True

' handle of the group (no s) !


' now ready to send and receive
' and to generate events

The role of the ServerHandles and ClientHandles will be explained later


Industrial Automation

31/48

4.3.2 OPC DA

OPC DA: Data structures at the client


The client prepares data structures for its items and gives the server the corresponding
pointers so the server can update them.
Items to be written and read can be mixed in the same group.
The type of the item (Boolean, Float,) is implicit, but known at the server
communicated to server by
registering group
FullyQualifiedItemID

returned by server
when registering

dynamic changes
(refreshed on change)

ClientHandle ServerHandle ServerError

Value

Quality TimeStamp

"Channel1.Device1.Temp1"

100

34543

123.4

OK

12:09.234

"Channel1.Device1.Speed1"

102

22532

999.8

OK

12:02.214

"Channel1.PLC2.Door"

203

534676

OK

12:03.002

"Channel1.PLC2.Valve3"

204

787234

OK

12:02.345

"Channel1.PLC2.CloseDoor"

205

58432

BAD

12:02.345

..

..

..

..

..

..

Note: OPC indices start with 1 !


Industrial Automation

32/48

4.3.2 OPC DA

OPC DA: Synchronous Read of a group


Dim
Dim
Dim
Dim
Dim
Dim

thisGroup As OPCGroup
cntItems As Integer
source As Integer
serverHandles(2) As Long
values() As Variant
errors() As Long

serverHandles(1) =
serverHandles(2) =

client
myGroup.SynchRead()

server
Call

Reply
ServerHandle(11) ' copy from global variables
ServerHandle(14)

source = OPCcache
thisGroup.SyncRead
source,
nrItems,
serverHandles,
values,
errors

' could also be OPCDevice

' identifies the items to be read !


' returns be a dynamic array
' returns a dynamic array

For cntItems = LBound(serverHandles) To UBound(serverHandles) ' 1..n


MsgBox CStr(cntItems) & " : " & values(cntItems)
Next cntItems

Industrial Automation

33/48

4.3.2 OPC DA

OPC DA: Asynchronous read of single Items


Dim WithEvents MyGroup
...
MyGroup.AsyncRead
nrItems,
ServerHandles,
ServerErrors,
TransactionID,
CancelID

server

client
AsyncRead()

Call

Reply

AsyncReadComplete()
Private Sub Mygroup_AsyncReadComplete (
ByVal TransactionID As Long,
ByVal NumItems As Long,
ClientHandles() As Long,
ItemValues() As Variant,
Qualities() As Long,
Asynchronous read separates Call and Reply.
TimeStamps() As Date,
Errors() As Long)

Call supplies the ServerHandles

MsgBox ("Async Read Complete")


End Sub

Industrial Automation

Reply returns the corresponding ClientHandles

34/48

4.3.2 OPC DA

OPC DA: Transaction ID


server

client
Call

AsyncRead (source= device)


AsyncRead (source= cache)
AsyncRead (source = device)

Reply

AsyncReadComplete()
AsyncCancel ()
AsyncCancelComplete ()
Although the AsynchReadComplete carries the ClientHandle of each item,
it does not tell which AsynchRead caused the AsynchReadComplete event to fire.
Call and Reply are linked by the TransactionID: this ID is returned in AsynchReadComplete
It can also be used to cancel the operation
Industrial Automation

35/48

4.3.2 OPC DA

OPC DA: Reading (by events) the OPC group


Dim WithEvents MyGroup
...
Private Sub MyGroup_DataChange( _
ByVal TransactionID As Long, _
ByVal NrItems As Long, _
ClientHandles() As Long, _
ItemValues() As Variant, _
Qualities() As Long, _
TimeStamps() As Date)
Dim cntItems As Integer
For cntItems = LBound(ClientHandles)
TextValue(cntItems - 1).Text
TextTimeStamp(cntItems - 1).Text
TextQuality(cntItems - 1).Text
Next cntItems

' returned by the server to the client

To UBound(ClientHandles)
' index 1..n
= ItemValues(cntItems)
' display
= DateAdd("h", 9, TimeStamps(cntItems))
= Qualities(cntItems)

End Sub

This function is called each time an item in the group changes


The ClientHandles (here: 5 and 6) identifies the variables, not the fully qualified itemID
The values are displayed in the TextValue, TextTimeStamp and TextQuality fields.
The refresh rate is given in the group definition.
Industrial Automation

36/48

4.3.2 OPC DA

OPC DA: Groups Events

Although transmission by groups is more efficient than AsyncRead, it can be improved


by using Groups Events (Global Data Change)

This event is fired whenever a variable of a group changes.


If the group is subscribed also to a Group Event (DataChange), I.e. if the group is
declared WithEvents, then both Events will be fired.
The application must sort out the groups and the items.

Industrial Automation

37/48

4.3.2 OPC DA

OPC DA: GlobalDataChange


Dim WithEvents MyGroups As OPCGroups
...
Private Sub MyGroups_GlobalDataChange(
ByVal TransactionID As Long,
' =0 if called by Refresh
ByVal GroupHandle As Long,
ByVal NumItems As Long,
ClientHandles() As Long,
' identifies the items
ItemValues() As Variant,
' value of the items
Qualities() As Long,
' value of the items
TimeStamps() As Date)
' timestamps of the items
Select Case GroupHandle
Case 1
' treat group 1
Case 2
' treat group 2

' depending on the group ...

The GlobalDataChange event is fired when any item in a group changed.


(if Groups is also with events, the corresponding Group_DataChange will also be called)

Industrial Automation

38/48

4.3.2 OPC DA

OPC DA: Server Events


Dim WithEvents MyServer As OPCServer
' define the event
.. ..
Private Sub MyServer_ServerShutDown(ByVal Reason As String)
MsgBox "my OPC Server " & MyServer.ServerName & " quit"
End Sub

This event signals to the client that the server shut down.
The client must declare its server WithEvents and provide the corresponding event
Subroutine
This should stop all actions, otherwise exceptions will occur.

Industrial Automation

39/48

4.3.2 OPC DA

OPC DA: Do not forget cleanup !


To speed up connection/disconnection, an OPC server remembers its groups and clients
when a client disconnects.
To do this, an OPC server initialises its structures with a client counter of 2, instead of 1.
Therefore, it is imperative to shut down explicitly the server, otherwise links will subside
(and you will have kill the server to clear them).

Private Sub ServerShutdown


Dim dummyServer As OPCServer
Dim Servers As Variant
Dim cntServers As Integer

' this is an array of strings

Set myGroup1 = Nothing


Set myGroups = Nothing
MyServer.Remove
MyServer.RemoveAllGroups
MyServer.Disconnect
Set MyServer = Nothing

Industrial Automation

' create a dummy server object


' returns all available servers

' delete this object (was created by New)

40/48

4.3.2 OPC DA

OPC DA: Standard and components


OPC Common
Overview: usage and specifications
OPC as an integration tool
Clients and Servers: configuration
OPC Technology, client and custom interface
OPC Data Access
Overview: browsing the server
Objects, types and properties
Communication model
Simple programming example
Standard and components

OPC Alarms and Events Specification


Overview: definitions and objects
Events
Alarm Conditions
Automation Interface
OPC Historical Data Specification
Overview
Industrial Automation

41/48

4.3.2 OPC DA

OPC DA: Libraries


The OPC DA specification is not formal, conformance can hardly be checked against this
document.
To ensure that the standard is observed, the OPC foundation distributes on its website
the DLLs (opcdaauto.dll, opccomn_ps,) that contain the type libraries to access the
OPC server.
The vendors are not compelled to implement all features. For instance, the description of
the variables is seldom used. Calling unimplemented functions causes exceptions that
must be caught in Visual Basic with "On Error " statements.

There exist three versions of DA, 1.0, 2.0 and 3.0, that behave differently, however, older
servers do not have a property indicating which version they support.

Industrial Automation

42/48

4.3.2 OPC DA

OPC DA: Custom Interface


While the Automation Interface is easy to use and quite powerful, some OPC functions
are missing and special operations can only be done in Visual C++ using the custom
COM interface.
This is only recommended for experienced programmers.
IOPCCommon
IOPCServer
IConnectionPointContainer
IOPCItemProperties
[IOPCServerPublicGroups]
IConnectionPointContainer
[IOPCBrowseServerAddressSpace]
IPersistFile

Industrial Automation

IOPCDataCallback
IOPCServerShutdown

OPC
client

OPC
server
IOPCItemMgt
IOPCGroupStateMgt
[IOPCPublicGroupSteatMgt]
IOPCSyncIO
IOPCAsyncIO2
IConnectionPointContainer
IEnumOPCItemAttributes
IOPCSyncIO
IDataObject

43/48

OPC
group

4.3.2 OPC DA

OPC DAOPCGroup Custom Interface: comparison (1)


This checklist for experienced programmers (custom interface) shows the differences between the DA versions
Required Interfaces

DA 1.0

DA 2.0

DA 3.0

OPCGroup
IUnknown

Required

Required

Required

IOPCItemMgt

Required

Required

Required

IOPCGroupStateMgt

Required

Required

Required

IOPCGroupStateMgt2

N/A

N/A

Required

IOPCPublicGroupStateMgt

Optional

Optional

N/A

IOPCSyncIO

Required

Required

Required

IOPCSyncIO2

N/A

N/A

Required

IOPCAsyncIO2
IOPCAsyncIO3

N/A Required
N/A

Required
N/A

Required

IOPCItemDeadbandMgt

N/A

N/A

Required

IOPCItemSamplingMgt

N/A

N/A

Optional

IConnectionPointContainer

N/A

Required

Required

IOPCAsyncIO
IDataObject

Required
Required

Optional
Optional

N/A
N/A

Industrial Automation

44/48

4.3.2 OPC DA

OPC DA OPCServer 1.0, 2.0 & 3.0 comparison (2)


This checklist for experienced programmers (custom interface) shows the differences between the DA versions

Required Interfaces

1.0

2.0

3.0

OPCServer
IOPCServer

Required

Required

Required

IOPCCommon
IConnectionPointContainer

N/A Required
N/A

Required
Required

Required

IOPCItemProperties
IOPCBrowse

N/A Required
N/A

N/A
N/A

Required

IOPCServerPublicGroups

Optional

Optional

N/A

IOPCBrowseServerAddressSpace

Optional

Optional

N/A

IOPCItemIO

N/A

N/A

Required

The differences do not yet appear in the automation interface

Industrial Automation

45/48

4.3.2 OPC DA

Industrial Automation
Automation Industrielle
Industrielle Automation

4 Access to devices
4.3 OLE for Process Control (OPC)
4.3.3 Alarms & Events

2005 May, HK

ABB Research Centre, Baden, Switzerland

AE: Overview
OPC Common
Overview: usage and specifications
OPC as an integration tool
Clients and Servers: configuration
OPC Technology, client and custom interface
OPC Data Access
Overview: browsing the server
Objects, types and properties
Communication model
Simple Programming Example
Standard and components

OPC Alarms and Events Specification


Overview: definitions and objects
Events
Alarm Conditions
Automation Interface
OPC Historical Data Specification
Overview
Industrial Automation

2/32

4.3.3 OPC A&E

To probe further.
OPC Foundation:
Specifications http://www.opcfoundation.org
SoftwareToolbox
Examples in Visual Basic
http://www.softwaretoolbox.com/Tech_Support/TechExpertiseCenter/OPC/opc.html

The Code Project


OPC and .NET
http://www.codeproject.com/useritems/opcdotnet.asp

Matrikon
Free client and server:
http://www.matrikon.com

WinTech
Toolkit for an OPC server
http://www.win-tech.com/html/opcstk.htm

NewAge Automation
Toolkit for an OPC server
http://www.newageautomation.com

Industrial Automation

3/32

4.3.3 OPC A&E

AE: Configuration

OPC AE Client
e.g. event logger
OPC A&E
specified
interface

OPC AE Client
e.g. alarm printer

OPC AE Server

An OPC AE Server
is configured using
the information
coming from the
development tools
for the controllers
Events defined in
the controllers are
mirrored to the
OPC AE server

event notification
e.g. Ethernet

events

controllers
controller

controller
field bus

plant
measurement
points

Industrial Automation

field devices

4/32

4.3.3 OPC A&E

AE: Purpose
The controllers (PLC) generate events in response to changes in the plant variables.
together with their precise time of occurrence, type, severity and associated message for
the human operator.
An OPC Event server registers these events and makes them available to several clients
A particular class of events are the alarms, which are detailed events that may require
acknowledgement.

The OPC Alarms & Events Interface gives access to the OPC Event server, allowing to:
- browse the OPC A&E Server for predefined events.
- enable or disable alarms and events
- subscribe to alarms and events of interest
- receive the event and alarm notifications with the associated attributes
- acknowledge alarms

Industrial Automation

5/32

4.3.3 OPC A&E

AE: Definitions
An event is a general change of state that is relevant to the OPC server.
An event signal a change:
1) in the field device ("production started")
2) in the OPC server ("alarm acknowledged")
3) in the application ("operator action")
An alarm is a state of the process that requires attention and is relevant to the OPC server.
An alarm is represented by an alarm condition, (or short: condition), a state machine
indicating if the alarm has been enabled, triggered or acknowledged.
An event or an alarm does not transmit analogue process values,
but they transmit information about their origin, the time of their occurrence and a message
intended for a human operator.
Alarms and events may not get lost
(contrarily to OPC DA, which does not guarantee completeness)

Alarms and event are precisely time-stamped by their source,


(contrarily to process variables, which are time-stamped by the receiving OPC server).

Industrial Automation

6/32

4.3.3 OPC A&E

AE: communication paradigm


OPC AE works according to the message passing paradigm, contrarily to OPC DA, that
works according to the "shared memory" paradigm.
This means that an event is kept in a queue until all clients have read it (or timed out).
The server guarantees that different clients will see all events in the same sequence.

OPC AE Client

OPC AE
Client

OPC AE
Server
12:34 23.114
12:34 32.334

Industrial Automation

7/32

4.3.3 OPC A&E

AE: Displaying Alarms and Events


Alarms and events are usually displayed differently on an operator screen.
- Events are displayed in an event list that can become quite long (typically 1000 entries),
entries are not cleared when the source of the event returns to normal
- Alarms are displayed in a short list (typically 50 alarms)
appearance changes when the alarm is acknowledged,
an alarm line is cleared when the alarm signal is cleared.

Ack
checkbox

Industrial Automation

8/32

4.3.3 OPC A&E

AE: Server Organization


A2
branches

leaves

Areas

A23

Sources
(objects)

Events

A24

S1

E1

S2

S3

E2

E1

E2

E2

E3

simple

tracking

condition
related

condition
related

condition
related

C2

C2

C2

properties
Conditions (alarms only)

Subconditions (alarms only)

SC1

SC1

SC3

SC1 SC1 SC3

SC1

An event is identified by a source (owner object in the controller) and an event name
this combination must be unique in the AE Server.
Industrial Automation

9/32

4.3.3 OPC A&E

AE: Browsing the AE Server

root

Area 1
Source 1
Area 2
Source 2
Area 5
Source 3
Area 51
Area 52

Alarms and Event are organized by area, which themselves may contain other areas.
Contrarily to branches in OPC DA, area and sources have properties that allow to
disable or enable events or alarms by area or by source, corresponding to parts of the
plants, rooms or specific equipment of the plant.

Industrial Automation

10/32

4.3.3 OPC A&E

AE: Browsing methods

Like all other OPC Servers, an OPC A&E presents an interface that allows the client to
browse the server to explore its structure, with the methods:
BrowseOPCArea
ChangeBrowsePosition (up, down, root)
GetQualifiedAreaName
GetQualifiedSourceName

There is no "GetQualifiedItemID, since the condition name is known from the source.

Industrial Automation

11/32

4.3.3 OPC A&E

AE: Events
OPC Common
Overview: usage and specifications
OPC as an integration tool
Clients and Servers: configuration
OPC Technology, client and custom interface
OPC Data Access
Overview: browsing the server
Objects, types and properties
Communication model
Simple Programming Example
Standard and components

OPC Alarms and Events Specification


Overview: definitions and objects
Events
Alarm Conditions
Automation Interface
OPC Historical Data Specification
Overview
Industrial Automation

12/32

4.3.3 OPC A&E

AE: Events kinds

OPC AE defines three kinds of events:

1.

simple: process control system related events (change of a boolean variable)

2.

condition-related: notifies a change of an alarm condition (CLEARED, ACKNOWLEDGED),


(see later)

3.

tracking-related: origin outside of the process (e.g. operator intervention)

Industrial Automation

13/32

4.3.3 OPC A&E

AE: Event- identification


An event is identified by
- its source (the object that generates the event. e.g. Tank1) and
- the event name (which can be the same as in another object, e.g. HiLevelCond)

HiLevelCond

event

HiLevelCond

event

LoLevelCond LoLevelCond

event
Tank1

Industrial Automation

Tank2

event

HiLevelCond

event
LOLevelCond

event

Tank3

14/32

4.3.3 OPC A&E

AE: Event PLC Function block


Simple Event function blocks in a controller are used to signal a simple event.
The event is identified by the concatenation of the name of the containing object
(SrcName) and the event handling function block name (here: SimpleEventDetector_1).
The source name can be that of the containing code module (owner object), assuming
that a plant object is represented by a code module.
name of the event
event signal (boolean expression)
is an external signal to be used ?
signal name for external signal (20 characters)
name of the source (30 characters)
message (60 characters)

Industrial Automation

15/32

4.3.3 OPC A&E

AE: Events - Notification

AE Client

Tank1LevelHigh_SimpleEvent
(source, timestamp, message,
severity, category)

OPC AE
Server
queue

event notification
message
timestamp

Controller
Event
FB

Tank1
Plant

Level Switch

Industrial Automation

16/32

4.3.3 OPC A&E

AE: Events - Time Stamp

There are three places where events can be time-stamped:


- at the device that originally produced the data (external event - low-level event)
allowing Sequence-Of-Events with a high resolution, down to microseconds
- at the controller, (internal event) using the controller's clock to time-stamp messages
giving precision not greater than the period of the tasks, about 1 ms.
- at the OPC Server, when an event message arrives (tracking events)
not more precise than DA, about 10 ms)
The OPC server can be configured to register the time stamp at the instant of the
event transition (positive or negative) and the instant of the acknowledgement.

Industrial Automation

17/32

4.3.3 OPC A&E

AE: Properties of an Event-object

all events

condition
-related
events

Property
Source
Time
Message
EventCategory
Severity
OPCEventAttribute

Meaning
source object (area + source)
time of occurrence
associated message for the operator
user-defined
priority (1..1000)

ConditionName
SubCondition
ChangeActiveState
ChangeAckState
ChangeEnableState
ChangeQuality
ChangeSeverity
ChangeSubCondition
ChangeMessage
ChangeAttribute
ConditionAction
ConditionAcknowleddged
Quality
AckRequired
ActiveTime
Cookie
ActorID

name of the condition within the source


name of the active subcondition (subconditions are exclusive)

Industrial Automation

server handle used for acknowledgement of alarms


identified who acknowledged the alarm (for client-side acknowledgement)

18/32

4.3.3 OPC A&E

AE: Alarm conditions


OPC Common
Overview: usage and specifications
OPC as an integration tool
Clients and Servers: configuration
OPC Technology, client and custom interface
OPC Data Access
Overview: browsing the server
Objects, types and properties
Communication model
Simple Programming Example
Standard and components

OPC Alarms and Events Specification


Overview: definitions and objects
Events
Alarm Conditions
Automation Interface
OPC Historical Data Specification
Overview
Industrial Automation

19/32

4.3.3 OPC A&E

AE: Alarms - Condition Definition


An (alarm) condition is a named state machine that describes the state of an alarm
The condition state is defined by three variables:
Enabled:

the condition is allowed to send event notifications

Active:

the alarm signal is true

Acknowledged:

the alarm has been acknowledged

Alarm signal
(e.g. FIC101.PV > 100 AND FIC101.PV < 150)

Condition

Acknowledgement signal
(a positive transition of a boolean variable)

Condition state

Enable (positive transition)


Disable (positive transition)

Industrial Automation

20/32

4.3.3 OPC A&E

AE: Alarms - Acknowledgement


An alarm condition becomes active when the PLC produces an alarm signal describing
an abnormal state (e.g. the level of the tank is too high).
The operator is expected to acknowledge this condition (client ack)
Alternatively, a local operator may press a button that the PLC reads (field ack)
AE Client
Tank1Level_ConditionEvent
event notification

client ack (acknowledger ID)


OPC AE
Server

Network or field bus


message
LevelHigh

Condition

timestamp
controller
AckButton
(field ack)

Alarm Signal
Industrial Automation

21/32

4.3.3 OPC A&E

AE: Alarms - Condition states and acknowledgement


event notification
alarm signal

acknowledgement
condition state

Inactive
Acked

Active
Active
Unacked Acked

Inactive
Acked

Active
Inactive
Unacked Unacked

Inactive
Unacked

Inactive
Acked

alarm_signal
Enabled
Inactive
Acked

condition state
transitions
(here: always
enabled)

Ack

alarm_signal
alarm_signal

Enabled
Inactive
Unacked

Enabled
Active
Unacked

Ack

Enabled
Active
Acked

alarm_signal

An event is generated each time the alarm signal changes state, or is acknowledged
Industrial Automation

22/32

4.3.3 OPC A&E

AE: Alarms - Condition properties

Name

Name, unique within Server, assigned to the condition

Active

alarm expression is in the state represented by the condition

ActiveSubCondition

If condition active, name of SubCondition (see later)

Quality

quality of data upon which condition is computed

Enabled

condition may become active

Acked

alarm has been acknowledged

LastAckTime

last time that alarm was acknowledged

SubCondLastActive

last time that subcondition became active (see later)

CondLastActive

last time that condition became active

LastInactive

last time that condition became inactive

AcknowledgerID

who acknowledged the alarm

Comment

Industrial Automation

23/32

4.3.3 OPC A&E

AE: Alarms - Subconditions

A condition may be subdivided into mutually exclusive subconditions


This allows to signal an alarm identified by the object name and give details in the
subcondition.
(for instance: level high, level very high, overflow)

Name

Name, unique within the condition, assigned to the sub-condition

Definition

An expression that defines the sub-state

Severity

priority (different subconditions may have different severity levels)

Description

Text string to be included in the event notification

An alarm condition has at least one subcondition, that defines the severity.

Industrial Automation

24/32

4.3.3 OPC A&E

AE: Alarms : Example of Function Block (AC800)


name of the condition

Tank1AlarmCond

alarm signal (boolean expression)


is an external signal to be used ?
external signal name (20 characters)

active, acked,..

name of the source (30 characters)


message (60 characters)
(= Priority, 1..1000)
User defined (1..9999)
invert signal
acknowledgement method
shortest condition considered (0..3600)
enable detection (state)
field acknowledgement (positive edge)
disable condition (positive edge)
enable condition (positive edge)

This function block has only one subcondition

Industrial Automation

25/32

4.3.3 OPC A&E

AE: Summary alarms and events


Event

Alarm

AE Client

AE Client

OPC AE
Server

event notification (source, timestamp, message)

OPC AE
Server
alarm notification (source, timestamp, message,
condition, subcondition, severity, type)

message
timestamp

Event
FB

message

controller

Industrial Automation

Condition

controller

26/32

4.3.3 OPC A&E

AE: Automation Interface


OPC Common
Overview: usage and specifications
OPC as an integration tool
Clients and Servers: configuration
OPC Technology, client and custom interface
OPC Data Access
Overview: browsing the server
Objects, types and properties
Communication model
Simple Programming Example
Standard and components

OPC Alarms and Events Specification


Overview: definitions and objects
Events
Alarm Conditions

Automation Interface
OPC Historical Data Specification
Overview
Industrial Automation

27/32

4.3.3 OPC A&E

AE: Object hierarchy


OPCEventServer
OPCEventSubscriptions (col)

OPCEventSubscription
OPCEventSubscription
OPCEventAreaBrowsers

OPCEventAreaBrowser
OPCEvents (col.)
OPCEvent
OPCEvent
OPCEventCondition
OPCSubConditions (col.)
OPCSubCondition
OPCSubCondition
Industrial Automation

An instance of an OPC AE Server.


A collection containing all OPCEventSubscription objects this client
has created

An object that maintains state information and provides the


mechanisms for events and alarms notification
A collection of browsers for the server
(only one instance of an OPCBrowser object per instance of an OPCServer object.)

An object that browses items in the servers configuration. It


accesses the arrays of OPCAreas and OPCAreaSources
A collection that holds the OPCEvents objects.
When the Automation Wrapper receives a callback from the AE Server, it forwards
the response as an OPCEvents collection object.

An object that represents one specific event of a subscription


An object that holds the current state of a condition instance, identified
by its Source and Condition Name
A collection that holds the subconditions associated with the event
condition

represents one subcondition associated with the event condition

28/32

4.3.3 OPC A&E

AE: Automation Interface (Summary 1/2)


Methods

Event Server

Event Subscription Mgt

Industrial Automation

29/32

4.3.3 OPC A&E

AE: Automation Interface (Summary 2/2)


Enums

Classes

Types

Constants

Industrial Automation

30/32

4.3.3 OPC A&E

Industrial Automation
Automation Industrielle
Industrielle Automation

4 Access to devices
4.3.4 OLE for Process Control (OPC)
Historical Data Access

ABB Research Centre, Baden, Switzerland


2005 May, HK

HDA: Overview
OPC Common
Overview: usage and specifications
OPC as an integration tool
Clients and Servers: configuration
OPC Technology, client and custom interface
OPC Data Access
Overview: browsing the server
Objects, types and properties
Communication model
Simple Programming Example
Standard and components
OPC Alarms and Events Specification
Overview: definitions and objects
Events
Alarm Conditions
Automation Interface
OPC Historical Data Specification
Overview

Industrial Automation

2/32

4.3.4 OPC HDA

To probe further.
OPC Foundation:
Specifications http://www.opcfoundation.org
SoftwareToolbox
Examples in Visual Basic
http://www.softwaretoolbox.com/Tech_Support/TechExpertiseCenter/OPC/opc.html

The Code Project


OPC and .NET
http://www.codeproject.com/useritems/opcdotnet.asp

Matrikon
Free client and server:
http://www.matrikon.com

WinTech
Toolkit for an OPC server
http://www.win-tech.com/html/opcstk.htm

NewAge Automation
Toolkit for an OPC server
http://www.newageautomation.com

Industrial Automation

3/32

4.3.4 OPC HDA

Historians: An introduction
The role of HDA will become clearer
after a first glance at historians

The process database


decouples the plant from the analysis tools.
It contains recent and historical data.

Invensys (Wonderware) Archestra


Industrial Automation

4/32

4.3.4 OPC HDA

Historians Example
GE Fanuc/Intellution iHistorian (iFix...)
Questions to the historian:
What was the value of FIC101 last week ?
What was the flow average during October ?
Which were the daily averages in October ?
What was the total flow in each month ?
How much fuel did we use for the batch ?

Give the answer in form of tables,


pie diagrams, spreadsheet, reports

Features:
Unlimited Point Collection
Sub-Second Data Collection Rates
Enhanced Data Compression
True Thin Client Administration
Fault Tolerant Architecture
Industrial Automation

data collection, archiving and retrieval


report generation
computations (e.g. VBScript)
secure access (FDA 21 CFR 11)
20'000 actions/ s,
up to 100'000 data points
5/32

4.3.4 OPC HDA

Historians: Market

2003 Global Information Management Market by Industry


2%

11%
21%

1%

6%

13%
13%
12%

Chemical
Food and Beverage
Petroleum
Pulp and Paper
Pharmaceuticals
Power
Textiles
Waste and Water
Other

21%

Industrial Automation

7/32

4.3.4 OPC HDA

Historians: Players
ABB

Information Manager (formerly Enterprise Historian, bases on Oracle)

AIP/PPA (embedded) Historian is another product (small player)


AspenTech

InfoPlus.21

Complete offering with wide range of accompanying applications and services


Very good user interface

OSISoft PI 3.4
Largest installed base (perceived as de facto standard)
Easy-to-use
Perceived low cost (PI 3.4: 1 Mio data points / 80'000 /s)

GE-Fanuc Intellution iHistorian


Relatively new to market. Product created with Mountain Systems
Causing a stir for OSIsoft, AspenTech on pricing

Some small players


Honeywell (POMS) Uniformance
Invensys (Wonderware) IndustrialSQL 8.0
Rockwell Automation (RSBizWare) Historian
Siemens (WinCC) Historian (bases on MS SQL Server)

Industrial Automation

8/32

4.3.4 OPC HDA

Historian implementation
application
OPC HDA
ODBC/SQL and OPC HDA are
complementary

log organisation
"SQL"

history
database
collector
corrections

operator actions
"OPC"
field data
Industrial Automation

9/32

4.3.4 OPC HDA

HDA: Historical Data Access

HDA Clients

e.g. Trend Analysis

independent
processes

e.g. Event Logger

OPC HDA
Server

hidden
calculations

history
database

raw and
ordered data

collector

proprietary
data acquisition

OPC DA Server

Field device

Industrial Automation

Field device

10/32

4.3.4 OPC HDA

HDA: Purpose
An OPC HDA server gives access to a historical data base (logs) in which data from the
process have been collected and time-stamped, possibly through an OPC DA interface.

The OPC HDA interface clients, such as trend analysis, product tracking or data mining,
that require ordered access these data logs.
The OPC HDA interface allows to:

- browse the historical data base


- retrieve data through proper filtering, e.g. by date range, by identity, by property
- build aggregates over the retrieved data, such as average, minimum, maximum.
- enter new entries, correct entries or remove entries
- enter / delete annotations in the history data base

Industrial Automation

11/32

4.3.4 OPC HDA

HDA: Raw log


12.3.02 13:40
12.3.02 13:40
12.3.02 13:40
12.3.02 13:40
12.3.02 13:41
12.3.02 13:41
12.3.02 13:41
12.3.02 13:41
12.3.02 13:41
12.3.02 13:41
12.3.02 13:41
12.3.02 13:42
12.3.02 13:42
12.3.02 13:42

Gpcpt2ofpbonne
Cpt2bac
Gpcpt2bac
Gpcptbe2
Gpcpt1bac
Gpcpt1ofpbonne
Gpcptae2
Cpt1bac
Gpdefr2
Gpvoydef
Gpr3tempscycleprd
Gpstn1e1
Gpalarme1
Gpalarme2

4824
50
70
45
151
4826
45
49
64
2
318
16
0
0

12.3.02 13:43 Gpetatmodemarche

2
1346
1
16
0
317
0
0
0
1
1992
435
1
1
0
4823

12.3.02 13:43
12.3.02 13:43
12.3.02 13:43
12.3.02 13:43
12.3.02 13:43
12.3.02 13:43
12.3.02 13:43
12.3.02 13:43
12.3.02 13:44
12.3.02 13:44
12.3.02 13:44
12.3.02 13:44
12.3.02 13:44
12.3.02 13:44
12.3.02 13:44

Gptpscycle
Gpetatmodemarche
Gpdefgene1
Gpetatmodemarche
Gptpscycle
Gpdefr2
Gpvoydef
Gpdefgene1
Gpetatmodemarche
Gpr2tempscycleprd
Gptpscycle
Gpalarme3
Gpalarme4
Gpalarme3
Gpcpt2ofpbonne

Industrial Automation

By definition, values are registered when they change.


(even if data are acquired by periodic polling)
Data in the historical database are identified by their
itemID (here, represented by their name),
value, (of the respective type)
quality (good, stale, bad), and
timestamp (UTC).

12/32

4.3.4 OPC HDA

HDA: How to reduce raw data (even before HDA comes into play)

Tag values are sent to the OPC DA server when they change (on events).
The collector records these data in a log that is organized cyclically.
Since a log has a limited storage capacity, data are reduced by several means:
1) if a variable is received more often than the log's minimal storage interval (e.g. 1s),
the log keeps the latest of all values of the interval
2) if (and only if) a received variable changed by more than the "exception deviation"
(e.g. 5%, analog values only), it is entered into the log.
3) if a variable changed by less than the exception deviation, it may nevertheless be
forced into the log after the log's maximum storage interval (e.g. 4 s) elapsed.
Two situations can occur:
- the time scale of the log is smaller than that of the trend display in this case, values have to be
interpolated to be displayed correctly
min time

max time

max time

max time

max
exception
deviation
min

time
= process value (event)
Industrial Automation

13/32

= log entry
4.3.4 OPC HDA

HDA Application: Trend Display

Parameters:
log: how were data sampled
time scale (with possible offset, zoom, pan)
amplitude scale (low range, high range, scale units)
style: smoothed, stepped, filled (several ways to display the same data)
extrapolate: how to display values not received (e.g. because they did not yet change)
Industrial Automation

14/32

4.3.4 OPC HDA

HDA: More logs

A log registers only one data point !


log 2.1

log 1

log 2.2

(log templates can be used for


several datapoints)

log 2

Data in the log may be:


Measured values (original, from the OPC DA)
Calculated values
Corrected values (replaced or inserted)
Annotations (explanation strings)

raw log
Collector
(OPC DA Client)
other servers

OPC DA Server

Field device

XML / CSV

Field device

Industrial Automation

15/32

4.3.4 OPC HDA

HDA: Hierarchical logs


long-term log
1 hour_forever
5.2 MB / Year

3 27 28 29 30
september octobre

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
october

1 mn_7 days log


6 MB
d-7

1s_24 hours log:


50 traces @ 12 B
52 MB

23

24

d-6

d-5

d-4

10

d-3

11

12

13

A hierarchical log is built on the data contained in the parent log.


To reduce the log size, several aggregations can be applied:
- record only maximum, minimum, average over a period, etc...
Industrial Automation

16/32

d-2

14

15

16

yesterday

17

18

19

today

20

21

22

Actual data

4.3.4 OPC HDA

HDA role
An HDA server allows to browse the logs and filter the logs to be read.
It can filter them according to their attributes, such as
name of the datapoints, type of the datapoint, engineering units,....

An HDA server then selects the logs to be read.


An HDA can then read the logs, defining a certain period
(Start time, End Time, and the maximum number of entries to be retrieved.

When reading the log, the HDA server can process the log by applying aggregations
The "min time", "deviation", "max time" rules used to collect raw data is also used
as an aggregation to build new logs.
Therefore, hierarchical logs can be built out of a raw log by an OPC HDA service.

Do not confound aggregates and attributes.....

Industrial Automation

17/32

4.3.4 OPC HDA

HDA: Server
The client can query the HDA server for its capabilities, and in particular:
- which LocaleID (national languages) the server supports (as in DA and AE servers)

- which attributes the server supports (the attributes of its items is a subset thereof)
- which aggregates the server support (and the client can request)
- if the server supports correction / deletion of data (synchronous and/or asynchronous)
- if the server supports insertion of annotations (synchronous and/or asynchronous)
Many capabilities of the HDA server are optional.

Industrial Automation

18/32

4.3.4 OPC HDA

HDA: Browsing: structure


Like the DA and AE interfaces, OPC HDA server offers a browser with methods allowing
to navigate up and down, and to retrieve branches and leaves at each position.
If filters are defined at its creation time, an HDA browser only browse for items with
specific attributes (e.g. Engineering Units = m/s). The filtering attributes are additive.
HDA (contrarily to DA and AE) allows several browsers, each with its different filter.

root
Leaves
Object
Log 1
Object
Log 2
Area 5

Log 3
Area 51
Area 52

Industrial Automation

19/32

4.3.4 OPC HDA

HDA Browsing and filtering


The filter criteria are based on attributes (see the following slides).
Attributes cannot be modified afterwards.
Set MyOPCHDABrowser = MyOPCHDAServer.Createbrowser
(NumCriteria, AttributeIDs, operatorCode, Filters, Errors

MyOPCHDABrowser.MoveDown (MyOPCHDABrowser.OPCHDABranches(1))
Items = MyOPCHDABrowser.OPCHDAItems
.... list these items

Industrial Automation

20/32

4.3.4 OPC HDA

HDA: General attributes of the items


Code Attributes

Description

1
2
3
4

DATA_TYPE
DESCRIPTION
ENG_UNITS
STEPPED

5
6
7

ARCHIVING
DERIVE_EQUATION
NODE_NAME

PROCESS_NAME

SOURCE_NAME

10

SOURCE_TYPE

11

NORMAL_MAXIMUM

12

NORMAL_MINIMUM

13

ITEMID

data type for the item. See the definition of a VARIANT for valid values (VT_R4, etc.)
text that describes the item.
label to use in displays to define the units for the item (e.g., kg/s).
whether data from the history repository should be displayed as interpolated (sloped lines
between points) or stepped (vertically-connected horizontal lines between points) data.
whether historian is recording data for this item (0 means no).
equation to be used by a derived item to calculate its value. This is a free-form string.
machine which is the source for the item. This is intended to be the broadest category for
defining sources. For an OPC Data Access Server source, this is the node name or IP
address of the server. For non-OPC sources, the meaning of this field is server-specific.
process which is the source for the item. This is intended to the second-broadest category
for defining sources. For an OPC DA server, this would be the registered server name.
For non-OPC sources, the meaning of this field is server-specific.
name of the item on the source. For an OPC DA server, this is the ItemID.
For non-OPC sources, the meaning of this field is server-specific.
sort of source produces the data for the item. For an OPC DA server, this would be "OPC".
For non-OPC sources, the meaning of this field is server-specific.
upper limit for the normal value range for the item, is used for trend display default scaling
and exception deviation limit calculations, should be the normal high value for the item.
lower limit for the normal value range for the item, is used for trend display default scaling
and exception deviation limit calculations, should be the normal low value for the item.
item identifier. This is used to allow filtering in the CreateBrowse method.

Industrial Automation

21/32

4.3.4 OPC HDA

HDA: Attributes that affect how data are archived


Code Attributes

Data Type

Description

14

Max Time Interval

VT_FILETIME

15

Min Time Interval

VT_FILETIME

16

Exception Deviation

VT_R8

17

Exception Deviation Type

VT_I2

18

High Entry Limit

VT_R8

19

Low Entry Limit

VT_R8

Specifies the maximum interval between data points in the


history repository regardless of their value change.A new value
shall be stored in history whenever OPCHDA_MAX_TIME_INT
seconds have passed since the last value stored for the item.
Specifies the minimum interval between data points in the
history repository regardless of their value change.A new value
shall be not be stored in history unless
OPCHDA_MIN_TIME_INT seconds have passed since the last
value stored for the item.
Specifies the minimum amount that the data for the item must
change in order for the change to be reported to the history
database. See OPCHDA_EXCEPTION_DEV_TYPE for the
specific meaning of this field.
Specifies whether the OPCHDA_EXCEPTION_DEV is given
as an absolute value, percent of span, or percent of value. The
span is defined as OPCHDA_HIGH_ENTRY_LIMIT OPCHDA_LOW_ENTRY_LIMIT.
Specifies the highest valid value for the item. A value for the
item that is above OPCHDA_HIGH_ENTRY_LIMIT cannot be
entered into history. This is the top of the span.
Specifies the lowest valid value for the item. A value for the
item that is below OPCHDA_LOW_ENTRY_LIMIT cannot be
entered into history. This is the zero for the span.

Industrial Automation

22/32

4.3.4 OPC HDA

HDA: Selecting the items


Each server has only one group of items, the collection OPCHDAItems.
By adding an OPCHDAItemID to that collection, the client defines its client handle and
receives the server's server handle.

The OPCHDAItemID (a string) should be retrieved by using the browser (like in DA or


AE), since entering a string directly is unsafe.
The server handle is used to access the log.

Read operations are applied to the whole collection OPCHDAItems.

....

Set colOPCHDAItems = MyOPCHDAServer.OPCHDAItems


colOPCHDAItems.AddItem OPCHDAItemID ClientHandle
colOPCHDAItems.SyncReadRaw .....

Industrial Automation

23/32

4.3.4 OPC HDA

HDA: Reading the data


When reading the data, the client has the choice to read synchronously or
asynchronously (if the server permits the latter).
The client specifies the time interval (Start time and end time) and whether the end
values of that interval shall be included.
The client has the choice to read the raw data or to apply an aggregation to the read
data. The aggregations (see next slides) allow to reduce data.

Industrial Automation

24/32

4.3.4 OPC HDA

HDA: Aggregates
Symbol
0 NoAggregate
1 Interpolative
2 Total
3 Average
4 TimeAverage
5 Count
6 StDev
7 MinimumActualTime
8 Minimum
9 MaximumActualTime
10 Maximum
11 Start
12 End
13 Delta
14 RegSlope
15 RegConst
16 RegDev
17 Variance
18 Range
19 DurationGood
20 DurationBad
21 PercentGood
22 PercentBad
23 WorstQuality
24 Annotations

Description
Do not retrieve an aggregate (use only start time - stop time and filtering).
Get interpolated values.
Get the totalized value (time integral) of the data over the resample interval.
Get the average data over the resample interval.
Get the time weighted average data over the resample interval.
Get the number of raw values over the resample interval.
Get the standard deviation over the resample interval.
Get the minimum value in the resample interval and the timestamp of the minimum value.
Get the minimum value in the resample interval.
Get the maximum value in the resample interval and the timestamp of the maximum value.
Get the maximum value in the resample interval.
Get the value at the beginning of the resample interval (time stamp).
Get the value at the end of the resample interval (time stamp of end of the interval).
Get the difference between the first and last value in the resample interval.
Get the slope of the regression line over the resample interval.
Get the intercept of the regression line over the resample interval, (time start of interval).
Get the standard deviation of the regression line over the resample interval.
Get the variance over the sample interval .
Get the difference between the minimum and maximum value over the sample interval.
Get the duration (in seconds) of time in the interval during which the data is good.
Get the duration (in seconds) of time in the interval during which the data is bad.
Get the percent of data (1 = 100 %) in the interval which has good quality.
Get the percent of data (1 = 100 %) in the interval which has bad quality.
Get the worst quality of data in the interval.
Get the number of annotations in the interval.

Industrial Automation

25/32

4.3.4 OPC HDA

HDA interpolation
interpolation is an aggregate used when the time scale of the derived log is smaller than
that of the parent log.
= parent log
= filtered log

resample interval of the new log

time

This is useful to display smoothly trend diagrams.

Industrial Automation

26/32

4.3.4 OPC HDA

HDA corrections and annotations

These features are seldom implemented.


Basically, the values are accessed using the server handles that
OPCHDAItems.AddItem returned.

Industrial Automation

27/32

4.3.4 OPC HDA

HDA Automation Model


OPC Common
Overview: usage and specifications
OPC as an integration tool
Clients and Servers: configuration
OPC Technology, client and custom interface
OPC Data Access
Overview: browsing the server
Objects, types and properties
Communication model
Simple Programming Example
Standard and components
OPC Alarms and Events Specification
Overview: definitions and objects
Events
Alarm Conditions
Automation Model
OPC Historical Data Specification
Overview
Automation Model
Industrial Automation

28/32

4.3.4 OPC HDA

HDA: Automation Interface summary


OPCHDAServer

An instance of an OPC HDA Server. An OPCHDAServer object must be


created to can get references to other objects.

OPCHDAItems (col)

A collection containing all the OPCHDAItem objects this client has


created within the scope of the OPCHDAServer object

OPCHDAItem
OPCHDAItem

An object that maintains the items definition. Note the Custom Interface
does not provide a separate Item Object.

OPCHDABrowsers

An object that browses item names in the servers configuration.

OPCHDAHistory

An collection containing a series of either OPCHDAValue or


OPCHDAEntry objects, representing historical values of an item.

OPCHDAValue
OPCHDAValue

An object that represents a discrete historical value for an item or an


attribute.

OPCHDAEntry
OPCHDAEntry

An object that extends the OPCHDAValue object to include additional


information

Industrial Automation

29/32

4.3.4 OPC HDA

HDA: Object Interfaces (1)

Industrial Automation

30/32

4.3.4 OPC HDA

HDA: Object Interfaces (2)

Industrial Automation

31/32

4.3.4 OPC HDA

You might also like