INP Lab1 UART Serial Protocol

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 28

UART serial communication protocol

TP1

Dr. Kim Bunthern


I4EA – Electronic and Automation
Institute of Technology of Cambodia

October, 2023
Content: Pratical Lab (TP)

1. TP1: UART protocol


• Tinkercad simulation
2. TP2: I2C protocol
• Tinkercad simulation
3. TP3: Internet protocol (IP) (I)
4. TP4: IP protocol (II)
5. TP5: Modbus TCP protocol

Dr. Kim Bunthern Industrial Automation October, 2023


Content: Pratical Lab (TP)

❑ Group ? -> individual work


❑ Laptop + internet
❑Evaluation:
✓ Interview at the end of each subject.
✓ 1 Written report.

• Room B316’s PCs:


• Admin account: password = cea_2022_b316

Dr. Kim Bunthern Industrial Automation October, 2023


Objective

• The objective of this lab is to provide practical


knowledge on communication protocol based on
wired connection.
• Duration: 4h

• Platform: Tinkercad (Arduino simulation)

Dr. Kim Bunthern Industrial Automation October, 2023


Tasks

• Using Arduino UNO modules (1 & 2).


1. Test sending from Arduino 1 to Arduino 2 (and
vice visa) using UART.
2. Using the Oscilloscope to observe the waveform
of the signal on the pin Tx/Rx.
3. Explain the waveform.
4. What happen if we want to add a third Arduino
to the network using the same two pins (Tx/Rx)?
5. Design a protocol so that the 3 Arduino can
communicate with one another.

Dr. Kim Bunthern Industrial Automation October, 2023


• Setup:

Dr. Kim Bunthern Industrial Automation October, 2023


Dr. Kim Bunthern Industrial Automation October, 2023
Types of Protocols

• There are different ways of categorizing protocols


• First Categorization :

Serial Mode Parallel Mode


Transfer Transfer

• Second Categorization :

Synchronous Asynchronous
Mode Transfer Mode Transfer

Dr. Kim Bunthern Industrial Automation October, 2023


Serial and Parallel Mode

SENDER SENDER

RECIEVER RECEIVER

PARALLEL MODE SERIAL MODE

Dr. Kim Bunthern Industrial Automation October, 2023


Serial and Parallel Mode

Parameter Serial Mode Parallel Mode

Reliability Reliable Unreliable


Speed Slow Fast
Power Low High
Cost Low High
Complexity High Low
Range Long Short

Dr. Kim Bunthern Industrial Automation October, 2023


Need of Synchronization

•Synchronous
Sender sends a clock signal along with data at every
transmission
rising / falling edge of the clock, the data value is
read by the receiver.

SENDER
0 1 0 1

SENDER CLOCK

RECIEVER 0 1 0 1
Dr. Kim Bunthern Industrial Automation October, 2023
Need of Synchronization

Suppose Sender sends data with a Time Period of T

What if Receiver doesn’t know the speed and assume it to be say T/2

T
1 1 1 1
SENDER

0 0 0

The Data received will be

Dr. Kim Bunthern Industrial Automation October, 2023


Asynchronous Mode

• There is no clock signal.


• The receiver and the sender communicate at a
predetermined speed (bauds or bits per second).
• Baud Rate : Baud Rate is a measurement of transmission
speed in asynchronous communication. The devices that
allows communication must all agree on a single speed of
information - 'bits per second'.

Dr. Kim Bunthern Industrial Automation October, 2023


Transmission Modes

SENDER RECIEVER
Simplex

Only one way transmission takes place

Dr. Kim Bunthern Industrial Automation October, 2023


Transmission Modes

SENDER RECIEVER

Half-Duplex

Two way transmission takes place but only one


end can communicate at a time

Dr. Kim Bunthern Industrial Automation October, 2023


Transmission Modes

SENDER RECIEVER

Full-Duplex

Two way transmission takes place and both end


can communicate simultaneously

Dr. Kim Bunthern Industrial Automation October, 2023


UART

• UART is a simple full-duplex, asynchronous, serial


protocol.
• Simple communication between two equivalent
nodes.
• Any node can initiate communication.
• Since connection is full-duplex, the two lanes of
communication are completely independent.

Dr. Kim Bunthern Industrial Automation October, 2023


Format of uart packet

Dr. Kim Bunthern Industrial Automation October, 2023


Connections for uart

Rx Tx
Device 1 Tx Rx Device 2
Gnd Gnd

Dr. Kim Bunthern Industrial Automation October, 2023


Connections for uart

Rx Tx
Device 1 Tx Rx Device 2
Gnd Gnd

Dr. Kim Bunthern Industrial Automation October, 2023


Connections for uart

Rx Tx
Device 1 Tx Rx Device 2
Gnd Gnd

Dr. Kim Bunthern Industrial Automation October, 2023


UART Characteristics

• The speed of communication (measured in bauds)


is predetermined on both ends.
• A general rule of thumb is to use 9600 bauds for
wired communication.
• UART implements error-detection in the form of
parity bit.

Dr. Kim Bunthern Industrial Automation October, 2023


Parity bit

Parity bit is HIGH when number of 1’s in the Data is


odd (if bit parity is even).
• Respectively, it is LOW when number of 1’s in the
Data is even (if parity is even).

Dr. Kim Bunthern Industrial Automation October, 2023


UART in AtMega16

Dr. Kim Bunthern Industrial Automation October, 2023


Connecting AtMega16’s with UART

Dr. Kim Bunthern Industrial Automation October, 2023


MAX-232 and USB-Serial

Dr. Kim Bunthern Industrial Automation October, 2023


Dr. Kim Bunthern Industrial Automation October, 2023
End

Dr. Kim Bunthern Industrial Automation October, 2023

You might also like