Bus systems and communications -...

29
2014-11-14 1 Bus systems and communications CHRISTIAN ANTFOLK Announcement Assignment 1 Hand in on Monday Kursombud Data Lab 2 will be Onsdag den 26.11.2014 13-17 eller Torsdag den 27.11.2014 kl 8-12 or 13-17. Lecture 9 on 5.12.2014 will be held in E:1145

Transcript of Bus systems and communications -...

Page 1: Bus systems and communications - LTHbme.lth.se/.../Courses/Datorbaserade_maetsystem/EEMN10_Lect4_Da… · 2014-11-14 1 Bus systems and communications CHRISTIAN ANTFOLK Announcement

2014-11-14

1

Bus systems and communicationsCHRISTIAN ANTFOLK

Announcement

• Assignment 1 Hand in on Monday

• Kursombud Data

• Lab 2 will be Onsdag den 26.11.2014 13-17 eller Torsdag den 27.11.2014 kl 8-12 or 13-17.

• Lecture 9 on 5.12.2014 will be held in E:1145

Page 2: Bus systems and communications - LTHbme.lth.se/.../Courses/Datorbaserade_maetsystem/EEMN10_Lect4_Da… · 2014-11-14 1 Bus systems and communications CHRISTIAN ANTFOLK Announcement

2014-11-14

2

Structure of a measurement system

• pressure

• temperature

• speed

• angular velocity

• luminosity

• force

Physicalquantity

Measurementsystem

Presentation(and control)

• Signal conditioning

• DAQ-cards

• Bus control of instruments• GPIB (parallel)

• RS232 (serial)

• Bus systems with integrated and standardized instruments• VXI/PXI

• Real time controllers

• Field buses

• Graphical programming• LabVIEW

• Agilent VEE

• DASYlab

• Textual programming• LabWindows CVI

• Measurement Studio

• Visual Basic

• Visual C/C++

• Matlab

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

What is a computer bus?

• A collection of wires which transfer digital data according to a specific protocol between separate units.

• There are several standards to allow seamless connectivity of instruments from a number of different vendors.

• E. g. PCI, USB, GPIB, Firewire, SATA, Ethernet, etc

• E. g. of entire systems with specific computer buses incorporated in each unit are fieldbuses, VXI-systems, PXI-systems, real-time controllers etc.

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Page 3: Bus systems and communications - LTHbme.lth.se/.../Courses/Datorbaserade_maetsystem/EEMN10_Lect4_Da… · 2014-11-14 1 Bus systems and communications CHRISTIAN ANTFOLK Announcement

2014-11-14

3

General Purpose Interface Bus

• Introduced by HP 1965 (HP-IB)

• 1 MB/s

• Requires special cables and och plug-in cards

• Max 20 m total cable length and 15 instruments

• Still very much used for instrument control in both industry and research environments, probably due to the rugged connectors

• IEEE-488 / IEEE-488.2

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

General Purpose Interface Bus

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

GPIB-busGPIB-instrumentoch controller

Software control

Generalizerad instrument control

IEEE-488

IEEE-488.2

SCPI

VISA

Formalized the mechanical, electrical, and basic protocol parameters of GPIB.

Basic syntax and format conventions, device-independent commands, data structures, error protocols.

Standards for syntax and command for control ofinstruments.

Makes it possible to programs independent of hardware interface (GPIB, serial, VXI…)

Page 4: Bus systems and communications - LTHbme.lth.se/.../Courses/Datorbaserade_maetsystem/EEMN10_Lect4_Da… · 2014-11-14 1 Bus systems and communications CHRISTIAN ANTFOLK Announcement

2014-11-14

4

Connecting GPIB units

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Star

Daisy chain

GPIB system

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

• Three types of instruments (Controller, Talker , Listener)

• 31 primary addresses (Talker resp. Listener)

• 8 bit parallel data transfer

• Max. 2 m cable per instrument connected to the bus

• Negative true logic

Page 5: Bus systems and communications - LTHbme.lth.se/.../Courses/Datorbaserade_maetsystem/EEMN10_Lect4_Da… · 2014-11-14 1 Bus systems and communications CHRISTIAN ANTFOLK Announcement

2014-11-14

5

GPIB system

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Handshake & Bus management lines• Handshake

– DAV - Data Valid – used by the Talker to indicate that the eight data lines are settled and valid

– NRFD - Not Ready For Data – used by receiving unit (Listener)

– NDAC – Not Data Accepted - used by receiving unit (Listener)

• Bus management

– ATN - Attention – used by the controller

– IFC - Interface Clear - used by the controller, resets all connected units

– REN - Remote Enable - used by the controller, puts units in a remotely controlled state

– EOI - End Or Identify - used by the talker or the controllers. Talker : indicates the end of a message. Controller : start a parallell poll.

– SRQ - Service Request - used by the talkers to notify the controller that somethig is wrong

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Page 6: Bus systems and communications - LTHbme.lth.se/.../Courses/Datorbaserade_maetsystem/EEMN10_Lect4_Da… · 2014-11-14 1 Bus systems and communications CHRISTIAN ANTFOLK Announcement

2014-11-14

6

Two types of commands

• ATN is true (= low level = 0) – bus commands can be sent

– E.g. put unit in Listener mode

• ATN is false (= high level = 1) – data is sent to and from units through the DIO 1-8 lines

– The data can be instrument commands or measurementdata

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Handshaking protocol

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

0

1

2

4

5

6

73

Page 7: Bus systems and communications - LTHbme.lth.se/.../Courses/Datorbaserade_maetsystem/EEMN10_Lect4_Da… · 2014-11-14 1 Bus systems and communications CHRISTIAN ANTFOLK Announcement

2014-11-14

7

Handshaking protocol

• By transferring data in this way the data is placed onto the bus at a rate which is suitable for the talker, and it is held until the slowest listener has accepted it. In this way the optimum data transfer rate is always used, and there are no specifications and interface problems associated with the speeds at which data must be transferred.

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Bus commands

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Page 8: Bus systems and communications - LTHbme.lth.se/.../Courses/Datorbaserade_maetsystem/EEMN10_Lect4_Da… · 2014-11-14 1 Bus systems and communications CHRISTIAN ANTFOLK Announcement

2014-11-14

8

Example of instrument control over GPIB

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Mätdator : talaradress U / lyssnaradress 5Spänningsaggr: lyssnaradress 3Voltmeter: talaradress Q / lyssnaradress 1

Example of instrument control over GPIB continued

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Mätdator : talaradress U / lyssnaradress 5Spänningsaggr: lyssnaradress 3Voltmeter: talaradress Q / lyssnaradress 1

Page 9: Bus systems and communications - LTHbme.lth.se/.../Courses/Datorbaserade_maetsystem/EEMN10_Lect4_Da… · 2014-11-14 1 Bus systems and communications CHRISTIAN ANTFOLK Announcement

2014-11-14

9

Example in LabVIEW

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Errors

• What is an error?

– An unknown command is sent

– Overflow (measurement out of range)

• What happens?

– The instrument activates the SRQ control line

– The instrument puts bits in the its status register

• What if you want the controller to handle the error?

– Poll

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Page 10: Bus systems and communications - LTHbme.lth.se/.../Courses/Datorbaserade_maetsystem/EEMN10_Lect4_Da… · 2014-11-14 1 Bus systems and communications CHRISTIAN ANTFOLK Announcement

2014-11-14

10

Polling

• Serial polling

– The controller addresses the units sequentially and theyreply by sending back a status byte

• Parallel polling

– Each instrument is assigned one of the eight data lines. When the controller activated EOI (with ATN line set totrue) the instrument(s) which generated a SRQ assertsits line.

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Bus commands IEEE 488.1

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Universal commands - unaddressed

LLO - Local Lock Out – Turns off the instruments front panelDCL - Device Clear – Resets all units on the busPPU - Parallell Poll Unconfigure – Turns off the parallel poll function in units with that functionSPE - Serial Poll Enable – Activates serial poll function in units with that functionSPD - Serial Poll Disable – Turns off serial poll function in units with that function

UNL - Unlisten - Recalls all Listeners on the busUNT - Untalk – Recalls all Talkers on the bus

Addressed commands

GET - Group Execute Trigger – Eg. starts a measurement in an instrumentSDC - Selected Device Clear – Resets a specific deviceGTL - Go To Local – Activates front panel on a specific devicePPC - Parallell Poll Configure – Prepares a listener for configuring of parallel pollTCT - Take Control – Gives control to a specific device, device needs to have controller capability

Page 11: Bus systems and communications - LTHbme.lth.se/.../Courses/Datorbaserade_maetsystem/EEMN10_Lect4_Da… · 2014-11-14 1 Bus systems and communications CHRISTIAN ANTFOLK Announcement

2014-11-14

11

Serial buses

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Standards for serial communication

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

• RS-232

– Unbalanced (one ground wire + one active wire)

– Point-to-point

– Up to 19,2 kbit/s at 15 m cable

• RS-422

– Balanced (both wires are active but in opposite phase)

– Point-to-point

– Up to 2 Mbit/s

• RS-485

– Balanced (both wires are active but in opposite phase)

– Multiple units are connected in parallel, however the communication is serial (Multidrop)

– Up to 10 Mbit/s

• USB, FireWire, Ethernet, SPI, I2C

Page 12: Bus systems and communications - LTHbme.lth.se/.../Courses/Datorbaserade_maetsystem/EEMN10_Lect4_Da… · 2014-11-14 1 Bus systems and communications CHRISTIAN ANTFOLK Announcement

2014-11-14

12

Comparison RS232 – RS422

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Tx

GNDRS232

Tx-

Tx+

RS422/RS485

0

1

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Page 13: Bus systems and communications - LTHbme.lth.se/.../Courses/Datorbaserade_maetsystem/EEMN10_Lect4_Da… · 2014-11-14 1 Bus systems and communications CHRISTIAN ANTFOLK Announcement

2014-11-14

13

SPI

• Serial Peripheral Interface

• Typical serial communicationbetween a AD converter and microcontroller

• ”Hardware” addressing

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

I2C

• Inter-Integrated Circuit

• 7 or 10 bit addressing

• Device need unique address

• Speeds up to 5 Mbit/s

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Page 14: Bus systems and communications - LTHbme.lth.se/.../Courses/Datorbaserade_maetsystem/EEMN10_Lect4_Da… · 2014-11-14 1 Bus systems and communications CHRISTIAN ANTFOLK Announcement

2014-11-14

14

Serial communication

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

• USB, FireWire, Ethernet

– 5 m cable for USB,

– 5 Gbit/s (USB 3),

• FireWire

– 72 m cable

– 3.2 Gbit/s

• Ethernet

– 72 m cable

– 10 Gbit/s

• SATA 3

– 8 m cable

– Up to 6 Gbit/s

– Designed to send data quickly to harddrives

Drawbacks

• From an industrial perspective

– No (standard) secure locking mechanism on the connector

– Cables (usually) not specified for (heavy) industrial use

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Page 15: Bus systems and communications - LTHbme.lth.se/.../Courses/Datorbaserade_maetsystem/EEMN10_Lect4_Da… · 2014-11-14 1 Bus systems and communications CHRISTIAN ANTFOLK Announcement

2014-11-14

15

Connectors on a instrument

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Universal Serial Bus - USB• Host controlled (computer controls how

connected units communicates)

• A host can address up to 127 units

• 1,5, 12 and 480 Mbit/s

• Available on most (if not all) modern computers

Lund University | Faculty of Egineering | Dept. of Biomedical Engineering

A

B

Page 16: Bus systems and communications - LTHbme.lth.se/.../Courses/Datorbaserade_maetsystem/EEMN10_Lect4_Da… · 2014-11-14 1 Bus systems and communications CHRISTIAN ANTFOLK Announcement

2014-11-14

16

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Example of a USB based system

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Example of a USB based system

Page 17: Bus systems and communications - LTHbme.lth.se/.../Courses/Datorbaserade_maetsystem/EEMN10_Lect4_Da… · 2014-11-14 1 Bus systems and communications CHRISTIAN ANTFOLK Announcement

2014-11-14

17

USB – Data transmission1. The USB-unit is connected

2. Host/Controller gives the unit an address

3. A ”reset” command is sent to the unit

4. The data transfer speed of the unit is checked

– Low speed = 1.5 Mbit/s

– Full speed = 12 Mbit/s

– High speed = 480 Mbit/s (USB 2)

– SuperSpeed = 5 Gbit/s (USB 3)

– SuperSpeed+ = 10 Gbit/s (USB3.1)

5. The different ”endpoints” of the unit is checked, how much power it usesetc.

6. The internal clock of the unit is synchronized to the host

7. ”Token packets” are sent before the command/data packets are sent

8. Data packets are always followed by handshake packets

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

USB – Data Transmission

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

• Token packet

• Data packet (optional)

• Handshake packet

Page 18: Bus systems and communications - LTHbme.lth.se/.../Courses/Datorbaserade_maetsystem/EEMN10_Lect4_Da… · 2014-11-14 1 Bus systems and communications CHRISTIAN ANTFOLK Announcement

2014-11-14

18

USB – Data transmission

• Packet IDs

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Enumeration : a ”host” give a ”device” an address 1-127, the device sens a device descriptor

FireWire – IEEE 1394

• Daisy chain topology

• Support peer-to-peer (no controller needed)

• Up to 63 devices

• Bitrate : 400-3200 Mbit/s (FireWire 400 - S3200)

• Many computers do not have FireWire

– License fee

– Complexity of devices = less devices on the market

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Page 19: Bus systems and communications - LTHbme.lth.se/.../Courses/Datorbaserade_maetsystem/EEMN10_Lect4_Da… · 2014-11-14 1 Bus systems and communications CHRISTIAN ANTFOLK Announcement

2014-11-14

19

LAN & LXI (LAN eXtension for Instrumentation

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Rackinstruments – VXI & PXI

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Page 20: Bus systems and communications - LTHbme.lth.se/.../Courses/Datorbaserade_maetsystem/EEMN10_Lect4_Da… · 2014-11-14 1 Bus systems and communications CHRISTIAN ANTFOLK Announcement

2014-11-14

20

VXI – VMEbus eXtensions for Instrumentation

• Faster & more compact thanGPIB (160 MB/s)

• Open standard (1987). Backed by more than 250 manufacturers

• Can use MXI (Multisystem eXtension Interface) or GPIB iftraditional instrument are alsoused in the same setup

• FireWire (IEEE-1394), USB, LAN etc

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

The PCI bus in a PC

• The PCI-bus, 32 bits, 133 MB/s, 33 MHz

• ”Peripheral Component Interconnect”

• The PCI-e bus, ”PCI-express”, 64 bits, 256 MB/s per line (total of 20 lines), 2 GHz

• Full duplex = to send and receive data at the same time => 512 MB/s

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Page 21: Bus systems and communications - LTHbme.lth.se/.../Courses/Datorbaserade_maetsystem/EEMN10_Lect4_Da… · 2014-11-14 1 Bus systems and communications CHRISTIAN ANTFOLK Announcement

2014-11-14

21

PXI – PCI eXtensions for Instrumentation

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

PXI – PCI eXtensions for Instrumentation

• PCMCIA/PC card/PC express card to laptop

• MXI-buss to stationary PC

• Between two PXI system

• Fastest with an embeddedcontroller

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Page 22: Bus systems and communications - LTHbme.lth.se/.../Courses/Datorbaserade_maetsystem/EEMN10_Lect4_Da… · 2014-11-14 1 Bus systems and communications CHRISTIAN ANTFOLK Announcement

2014-11-14

22

PXI Express

• Bandwidth > 6 Gbyte/s

• Vectorsignalgenerators (up to 6,6 GHz)

• Vectorsignalanalyzer

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Fieldbuses

• Used to interconnect automation devices in a network

• Heavily used in industry

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Page 23: Bus systems and communications - LTHbme.lth.se/.../Courses/Datorbaserade_maetsystem/EEMN10_Lect4_Da… · 2014-11-14 1 Bus systems and communications CHRISTIAN ANTFOLK Announcement

2014-11-14

23

Fieldbuses

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Fieldbuses

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Page 24: Bus systems and communications - LTHbme.lth.se/.../Courses/Datorbaserade_maetsystem/EEMN10_Lect4_Da… · 2014-11-14 1 Bus systems and communications CHRISTIAN ANTFOLK Announcement

2014-11-14

24

Examples of Fieldbuses• FIP (Factory Information Protocol)

• Three transmission speeds : 31.25 kbit/s, 1 Mbit/s, 2.5 Mbit/s• Max 255 units per segment• The ”bus arbitrator” sends an address and the• corresponding device answers by outputting a value

• Profibus• RS-485 or optical• Max 122 units• 500 kbit/s• ”Token bus”: the active units pass around a token,• passive units only listen

• CAN-bus (Controller Area Network)• Developed by Bosch for vehicles• Max 1 Mbit/s at 40 meter• Bus organization: no superior node, messages lack address – each node

is programmed to receive a message of a specific typeLund University | Faculty of Engineering | Dept. of Biomedical Engineering

The CAN bus in cars

• The expenses for the electronic circuitry in today’s cars can be up to a fourth of the construction costs

• Advanced cars: up to 4 km cable… (Apollo 11 1969: 150 kBmemory…)

• Weight and power consumption effect the gasoline/diesel consumption

• Cars of today have a number of different buses of different data transmission rates

– < 125 kbit/s - comfort (seats, windows, AC etc)

– < 1 Mbit/s more real time demanding functions like ABS and cruise control

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Page 25: Bus systems and communications - LTHbme.lth.se/.../Courses/Datorbaserade_maetsystem/EEMN10_Lect4_Da… · 2014-11-14 1 Bus systems and communications CHRISTIAN ANTFOLK Announcement

2014-11-14

25

Why use fieldbuses

• Distributed intelligence gives:

• Less cabling, especially over long distances

• Measurement cells can be made self calibrating or be calibrated remotely through the bus

• Self diagnostic systems

• Flexible system when transducer units are exchanged

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Buses

• Local

• Regional

• National

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Page 26: Bus systems and communications - LTHbme.lth.se/.../Courses/Datorbaserade_maetsystem/EEMN10_Lect4_Da… · 2014-11-14 1 Bus systems and communications CHRISTIAN ANTFOLK Announcement

2014-11-14

26

Local bus

• SPI

• I2C

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Regional bus

• USB

• GPIB

• PXI

• etc

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Page 27: Bus systems and communications - LTHbme.lth.se/.../Courses/Datorbaserade_maetsystem/EEMN10_Lect4_Da… · 2014-11-14 1 Bus systems and communications CHRISTIAN ANTFOLK Announcement

2014-11-14

27

National bus

• Ethernet

• Fieldbus

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Comparisons

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Page 28: Bus systems and communications - LTHbme.lth.se/.../Courses/Datorbaserade_maetsystem/EEMN10_Lect4_Da… · 2014-11-14 1 Bus systems and communications CHRISTIAN ANTFOLK Announcement

2014-11-14

28

Comparison

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Projects 2014

• Project:

– Build a measurement system (room E:1309B)

– Choose project week 4 of the course

– Short project description and suggested approach tosolution Monday 01.12.2014

– Short oral presentation Friday 19.12.2014 + written report

– Report hand-in Friday 19.12.2014

– 3 students per group

• Gear : PC with LabVIEW and Matlab

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering

Page 29: Bus systems and communications - LTHbme.lth.se/.../Courses/Datorbaserade_maetsystem/EEMN10_Lect4_Da… · 2014-11-14 1 Bus systems and communications CHRISTIAN ANTFOLK Announcement

2014-11-14

29

Example projects

• FPGA/CompactRIO-based measurements (industry)

• Automated Voltage vs. Frequency measurement for an acoustophoresis setup (BME)

• Control of pneumatic actuators for stimulation in an fMRI environment. (Radiation Physics / BME)

Lund University | Faculty of Engineering | Dept. of Biomedical Engineering