18
Real-time Embedded Systems Lecture 6 Embedded Communication Part I Prof. Dr. Amitava Gupta Department of Power Engineering Jadavpur University, India Real-time Embedded Syste ms- Lecture 06 

REAL TIME EMBEDDED SYSTEM_Lec6

Embed Size (px)

Citation preview

Page 1: REAL TIME EMBEDDED SYSTEM_Lec6

8/7/2019 REAL TIME EMBEDDED SYSTEM_Lec6

http://slidepdf.com/reader/full/real-time-embedded-systemlec6 1/18

Real-time Embedded Systems

Lecture 6

Embedded CommunicationPart I 

Prof. Dr. Amitava Gupta

Department of Power Engineering

Jadavpur University, India

Real-time Embedded Systems- Lecture 06 

Page 2: REAL TIME EMBEDDED SYSTEM_Lec6

8/7/2019 REAL TIME EMBEDDED SYSTEM_Lec6

http://slidepdf.com/reader/full/real-time-embedded-systemlec6 2/18

Real-time Embedded Systems- Lecture 06 

Formalizing the requirements of RT communications

Determinism

Composability 

Flexibility 

Fault Tolerance

Page 3: REAL TIME EMBEDDED SYSTEM_Lec6

8/7/2019 REAL TIME EMBEDDED SYSTEM_Lec6

http://slidepdf.com/reader/full/real-time-embedded-systemlec6 3/18

Real-time Embedded Systems- Lecture 06 

Flow Control: Explicit and Implicit

Explicit Flow Control:

The sender and the receiver , each has a client associated with it.

The sender sends a message and awaits an acknowledgement from the receiver after starting 

a timeout counter and a retry counter.

If the acknowledgement is received within the timeout value, it informs its client and the send 

task is assumed to have been complete. Else, it checks if the maximum number of retry attemptshave been exceeded or not and attempts another send. A failure is intimated to the client once

the max. number of retries is exceeded.

The receiver , on receiving a message, first checks if the message has already been received or 

not. If it has been received, it sends an acknowledgement to the sender only. Otherwise, it sends

the message to its client and sends an acknowledgement to the sender.

Thus, the error detection is at the sender end only.

Page 4: REAL TIME EMBEDDED SYSTEM_Lec6

8/7/2019 REAL TIME EMBEDDED SYSTEM_Lec6

http://slidepdf.com/reader/full/real-time-embedded-systemlec6 4/18

Real-time Embedded Systems- Lecture 06 

Flow Control: Explicit and Implicit contd..

Implicit Flow Control:

The receiver is programmed to receive messages from the sender at some pre-designated 

instants only.

No explicit acknowledgment is sent.

Reliability is ensured by sending the message through multiple links.

Thus, the error detection is at the receiver end only.

Q. Which flow control do you think is more suited for RT communication

requirements?

Page 5: REAL TIME EMBEDDED SYSTEM_Lec6

8/7/2019 REAL TIME EMBEDDED SYSTEM_Lec6

http://slidepdf.com/reader/full/real-time-embedded-systemlec6 5/18

Real-time Embedded Systems- Lecture 06 

Media Access Control

Binary

CountdownCSMA/CD TDMA

Protocol Implementations

High Level Standards

Representative Applications

CAN

Automotive

Fieldbus Profibus, ModbusEthernet, LonTalk

Building Automation Factory Automation

DATAC

Real-time communication abstractions

Token Passing

Devi

ce Net

Page 6: REAL TIME EMBEDDED SYSTEM_Lec6

8/7/2019 REAL TIME EMBEDDED SYSTEM_Lec6

http://slidepdf.com/reader/full/real-time-embedded-systemlec6 6/18

Real-time Embedded Systems- Lecture 06 

Media Access: Basic coding techniques for data transmission

Manchester Coding:

0 is encoded by a transition from Hi to Lo

1 is encoded by a transition from Lo to Hi

0 1

Q. How would the Byte 11010001 be encoded?

Page 7: REAL TIME EMBEDDED SYSTEM_Lec6

8/7/2019 REAL TIME EMBEDDED SYSTEM_Lec6

http://slidepdf.com/reader/full/real-time-embedded-systemlec6 7/18

Real-time Embedded Systems- Lecture 06 

Media Access: Basic coding techniques for data transmission contd..

Non-return to zero encoding

Send a 0 as Lo

Send a 1 as Hi

Uses a end bit and a sync bit ± having opposite signs

Thus 11010001 shall be coded as:

END

SYNC

1 1 0 1 0 0 0 1

END

SYNC

Page 8: REAL TIME EMBEDDED SYSTEM_Lec6

8/7/2019 REAL TIME EMBEDDED SYSTEM_Lec6

http://slidepdf.com/reader/full/real-time-embedded-systemlec6 8/18

Media Access

Polling: Master polls the slave nodes which send messages when polled.

Slaves communicate amongst one another through the master 

TDMA: Master synchronizes the clocks of all slaves. Each node transmits

during a pre-designated time slot.

Master  Node 1 Node 2 Node 3 Node 4

time slots

1 2 3 4 5

Real-time Embedded Systems- Lecture 06 

Page 9: REAL TIME EMBEDDED SYSTEM_Lec6

8/7/2019 REAL TIME EMBEDDED SYSTEM_Lec6

http://slidepdf.com/reader/full/real-time-embedded-systemlec6 9/18

Token passing- Explicit and Implicit

Explicit Token Passing: A token or a signal is passed from node to node across the

network (forming a virtual ring). Only the owner (token holder)

can transmit at any given instant.

Tokens are piggy-backed on data bearing messages.

Message prioritization is possible.  A token could be a number 

indicating which node should transmit next.

Recovery mechanism has to be devised- node bearing the tokengoes down.

Node#1 Node#2 Node#3

2 3

Advantages: Determinism (bounded latency), Easy re-configurability

Real-time Embedded Systems- Lecture 06 

Page 10: REAL TIME EMBEDDED SYSTEM_Lec6

8/7/2019 REAL TIME EMBEDDED SYSTEM_Lec6

http://slidepdf.com/reader/full/real-time-embedded-systemlec6 10/18

Token passing- contd«

Implicit Token Passing:

TDMA is a typical example of this. Another example is CSMA/CA( Collision Sense

Multiple Access/Collision Avoidance)

CSMA/CA

Real-time Embedded Systems- Lecture 06 

Page 11: REAL TIME EMBEDDED SYSTEM_Lec6

8/7/2019 REAL TIME EMBEDDED SYSTEM_Lec6

http://slidepdf.com/reader/full/real-time-embedded-systemlec6 11/18

Media Access contd..

CSMA/CD (Collision Sense Multiple Access/ Collision Detect)

�This is a system where each computer listens to the cable before sending anything through

�the network.

�If the network is clear, the computer will transmit.

�Else, If some other node is already transmitting on the cable, the computer will wait and try again

� when the line is clear.

�A collision occurs when two modes try to transmit at the same instant.

�Each computer then backs off and waits a random amount of time before attempting� to retransmit, when a collision occurs.

More on this in the section: Ethernet as a communication protocol for 

RT systems.

Real-time Embedded Systems- Lecture 06 

Page 12: REAL TIME EMBEDDED SYSTEM_Lec6

8/7/2019 REAL TIME EMBEDDED SYSTEM_Lec6

http://slidepdf.com/reader/full/real-time-embedded-systemlec6 12/18

Media Access contd..

Binary Countdown

�Each node has a unique identification number.

�Each node willing to transmit a signal send a string of bits representing the binary value of its

identification number.

� as soon as a node transmits a 0, the bus is in the dominant state.

� the bus is in the recessive state if all the nodes transmit a 1.

�A node drops out of competition if it detects a dominant state while trying to transmit a

recessive state

Real-time Embedded Systems- Lecture 06 

Page 13: REAL TIME EMBEDDED SYSTEM_Lec6

8/7/2019 REAL TIME EMBEDDED SYSTEM_Lec6

http://slidepdf.com/reader/full/real-time-embedded-systemlec6 13/18

Media Access contd..

Binary Countdown Explained

Lets say that nodes 4 and 5 start competing for the network at the same instant. This

is

what happens:

Node 4 transmits a 1 (Hi) & Node 5 transmits a 1 (Hi)

The bus is now in a recessive state and both are xmitting 1,

so this goes through

Node 4 transmits a 0(Lo) & Node 5 transmits a 0(Lo)

The bus is now in a dominant state and none of the nodes xmit 

1, so this goes through

Node 4 transmits a 0(Lo) & Node 5 transmits a 1(Hi)

The bus is now in the dominant state as node 4 xmits a 0, and therefore, node 5 

fails to xmit a 1 (recessive bit) and hence opts out.

Real-time Embedded Systems- Lecture 06 

Page 14: REAL TIME EMBEDDED SYSTEM_Lec6

8/7/2019 REAL TIME EMBEDDED SYSTEM_Lec6

http://slidepdf.com/reader/full/real-time-embedded-systemlec6 14/18

Central issues in Embedded Networking

�Local and Global Message priority 

Messages in a node are transmitted according to a local priority (highest priority message in

a node xmitted first) or a global priority (across all nodes). The global priority of a message

may be a function of the node¶s inherent priority.

�Latency 

�Determinism( depends largely on media access )

�Efficiency 

Real-time Embedded Systems- Lecture 06 

Page 15: REAL TIME EMBEDDED SYSTEM_Lec6

8/7/2019 REAL TIME EMBEDDED SYSTEM_Lec6

http://slidepdf.com/reader/full/real-time-embedded-systemlec6 15/18

Message Latency

It is the time interval from the instant the message is enqueued for transmission to the instant

the last bit is received. The message has to be enqueued before the arbitration slot i.e. before

the node starts transmitting.

Latency reduction techniques:

Queue the messages just in time.

Schedule tasks in the order of priority of their output messages.

Real-time Embedded Systems- Lecture 06 

Page 16: REAL TIME EMBEDDED SYSTEM_Lec6

8/7/2019 REAL TIME EMBEDDED SYSTEM_Lec6

http://slidepdf.com/reader/full/real-time-embedded-systemlec6 16/18

Efficiency

Message Efficiency : How many messages are actually useful at protocol level?

Total number of useful messages

Total number of messages sent 

Bit-wise Efficiency: (  Total number of useful data bits including portions of header 

used for identifying )/(Total nos. bits transmitted)

Clearly both are protocol dependent

Q. Which of the two protocols viz. token passing and CAN has a higher message

efficiency?

Q. What is channel efficiency and how are these related to it?

Real-time Embedded Systems- Lecture 06 

Page 17: REAL TIME EMBEDDED SYSTEM_Lec6

8/7/2019 REAL TIME EMBEDDED SYSTEM_Lec6

http://slidepdf.com/reader/full/real-time-embedded-systemlec6 17/18

Real-time Embedded Systems- Lecture 06 

Controller Area Network

Physical Layer 

Data Link

Application Layer 

Transceiver 

CAN Controller 

Host Controller 

Application

CAN Bus

Twisted pair with differential drivers &120 ohm terminators

Uses NRZ coding with bit stuffing

SOF

11 BIT IDENTIFIER

RTR

IDE

r0

DLC

PAYLOAD

0-8 BYTESCRC

ACK

EOF

IFS

Indicates priority.

Lower value, higher priority

Page 18: REAL TIME EMBEDDED SYSTEM_Lec6

8/7/2019 REAL TIME EMBEDDED SYSTEM_Lec6

http://slidepdf.com/reader/full/real-time-embedded-systemlec6 18/18

Real-time Embedded Systems- Lecture 06 

Physical Medium: Differential Drivers with Twisted pairs(120 ohm terminators)

Fibre Optic cables

Optical isolators

Media access: Uses NRZ coding and binary countdown (bit dominance)

Uses bit stuffing for long messages ( an opposite stuff bit

every 5 identical bits)

Q. How does the bit string 1111 1111 0000 0000 get coded with

stuff bits?

Q. Why is bit stuffing necessary?

Data stuffing impairs error detection.

Controller Area Network contd.