Professional Documents
Culture Documents
Interface 2 - Protokol Komunikasi Serial
Interface 2 - Protokol Komunikasi Serial
Heri Subagiyo
Low Cost: The cost of serial link is less in comparison to parallel links
What is Protocol?
Protocol is just like a common language that system uses to understand the data
Serial
Communication
Protocols
Asynchronous Synchronous
type type
https://circuitdigest.com/sites/default/files/ https://circuitdigest.com/sites/default/files/inlineimages/
inlineimages/u1/Synchronous-Serial-Communication.png u1/Asynchronous-Serial-Communication.png
Other Terms (1)
Baud Rate
• Rate at which the data is transferred between the transmitter and receiver in bits per
second (bps)
• The most commonly used baud rate is 9600. Others: 1200, 2400, 4800, 57600, 115200
• The baud rate has to be same for both transmitter and receiver
Framing
• The number of data bits to be sent from transmitter to receiver
• Most of the application uses 8 bits as the standard data bits
Other Terms (2)
Synchronisation
• It tells the start and end of the data bits
• The transmitter will set start and stop bits to the data frame and the receiver will identify it
Error Control
• The parity bits are used
• If the data frame contains the even number of 1’s then it is known as even parity and the
parity bit in the register is set to 1
• If the data frame contains odd number of 1’s then it is known as odd parity and clears the
odd parity bit in the register
UART Protocol (1)
Universal Asynchronous Receiver/Transmitter (UART)
Term UART, refers to the onboard hardware that manages packaging & translation of serial data
The wiring involved with setting up UART communication is very simple, only two-wired:
➢ one line for transmitting data (TX),
➢ one line for receiving data (RX)
https://circuitdigest.com/sites/default/files/inlineimages/u/
SPI-communication.png
SPI Protocol (2)
• MOSI (“Master Out Slave In”): Data transmission line
from master to slave
• SCK (“Clock”): Clock line defining transmission speed
and transmission start/end characteristics
• SS (“Slave Select”): Line for master to select a
particular slave to communicate with
• MISO (“Master In Slave Out”): Data transmission line
from slave to master
https://www.deviceplus.com/wp-content/uploads/2016/
12/image011.jpg
SPI Implementation on the Arduino (1)
SPI implementation on the Arduino
using the Arduino as the master
device (use library SPI.h)
Select the slave device attached to this GPIO pin digitalWrite(10, LOW);
digitalWrite [ Drive the pin high afterwards to de-select the …
slave ] [ digitalWrite(10, HIGH); ]
https://www.deviceplus.com/wp-content/uploads/
2016/12/image019.jpg
I2C Implementation on the Arduino (1)
On the Arduino, I2C implementation
occurs through the Wire library
(Wire.h)
Initiate the library and join the I2C bus as either a master
begin Wire.begin();
or slave
write Write the byte data over the I2C bus Wire.write(0x6B);
read To read two bytes from the buffer, this method must Wire.read();
be called twice, Example:
Wire.requestFrom(0x68, 2, true);
Wire.read();
Wire.read();