26

Komunikasi Serial RS-232

Embed Size (px)

Citation preview

Page 1: Komunikasi Serial RS-232
Page 2: Komunikasi Serial RS-232

Serial KomunikasiKode Morse

Page 3: Komunikasi Serial RS-232

RS232C

• RS-232 is a standard that describes a common method of serial signaling using a voltage that switches between a positive level for logic "0" and a negative level for logic "1". Per the standard,– +2.5 to +15V = logic 0 – -2.5 to -15V = logic 1

• An international standard for serial communication ( 1960s).

Page 4: Komunikasi Serial RS-232

• RS-232 voltages are inverted with respect to normal logic. – That is, we normally represent a logic 1 using the higher voltage in

a given circuit, say 5V. – In RS-232 it's the opposite: a "1" is the lower, or negative supply

voltage. • When an RS-232 line is powered up but idle (not

conveying data) it is in its lower voltage state, be that approximately 0V or negative.

• When data is to be sent, RS-232 jumps to its higher voltage state momentarily to alert the receiver. This is called a start bit (figure 1).

• So, if you're checking a serial line for proper operation, a quick check with a multimeter should show an idle state of close to 0V or negative.

Page 5: Komunikasi Serial RS-232

Mekanisme dan Pewaktuan• Let's walk through the transmission of one byte of data. Per figure 1,

the serial line starts off low, in its idle or stop-bit state. It can stay in this state forever--the receiving device understands this to mean that no data is available. When there is data to send, the following sequence of events occurs (from the perspective of the sender):

• The sender outputs a high level for one bit time1--the start bit • At intervals of 1 bit time, the sender outputs the data bits in inverted

form (i.e., with a high voltage meaning "0" and a low or negative voltage meaning "1"). The data bits are sent in order from least-significant bit (lsb)2 to most-significant bit (msb)2.

• After the final data bit, the msb, is sent, the sender returns to the low/stop-bit state for at least one bit time. After this, it may send another byte or remain idle.

Page 6: Komunikasi Serial RS-232
Page 7: Komunikasi Serial RS-232

Pengiriman Data Serial

Page 8: Komunikasi Serial RS-232

Notes:1. A bit time is defined as 1/bps. For

example, at 9600 bps the bit time is 1/9600 = 104 microseconds.

2. The "significance" of a bit or digit is its relative value. When we write numbers, the most-significant bit/digit is the one furthest to the left.

Page 9: Komunikasi Serial RS-232

Baudrate

• The rate of transmission of a data bit stream in bits per second (bps or b/s) is called the bit rate.

• Standard bit rates are– 110 ( the old teletype or TTY rate),– 300 (early PC modems),– 1200, 2400, 9600, 14.4K, 19.2K, 28.8K,

38.4K, 57.6K, and115.2 bps.

Page 10: Komunikasi Serial RS-232

Signaling

• Idle line in “mark” state (logic 1 - -15V)

• Baud means number of signal changes on the line per second. Commonly equal to bits per second (bps).

Page 11: Komunikasi Serial RS-232

• The asynchronously transmitted character is composed of– 5 to 8 data bits,– an optional parity bit, and– either 1, 1.5, or 2 stop bits.

Page 12: Komunikasi Serial RS-232

• The most used form of character encoding is the American Standard Code for Information Interchange (ASCII).

• This is a seven bit code which allows for 128 characters.• Codes that are less than 20H are not alpha-numeric characters

but control codes such as carriage return or backspace.– numbers 0 - 9 are encoded as 30H -39H.– capitol letters A - Z have codes 41H - 5AH , and– lower case letters a - z are 61H - 7FH.

• When start and stop bits and a parity bit are added to– the ASCII code, 9 to 11 bits are transmitted.

• The rate of transmission of a data bit stream inbits per second (bps or b/s) is called the bit rate.

Page 13: Komunikasi Serial RS-232

Sinkronisasi• Since digital data are transmitted as a stream

of bits, synchronization is required between the source and destination of the data.– Asynchronous communication transmits one

character at a time by adding start and stop bits to the character code.

– Synchronous transmission transmits a block of data and a clock signal or known known bit pattern that can be used for synchronization.

• A block number and check sum are also transmitted.

Page 14: Komunikasi Serial RS-232

Sinkronisasi

• There is no common clock between sender and receiver. How does receiver know when to test levels?

• A1: Synchronus mode — rarely used. Continuous stream of characters.

• A2: Asynchronus mode — start bit is known to be logic 0. Falling (rising?) edge triggers a local clock in the receiver.

Page 15: Komunikasi Serial RS-232

Multiplexing

• Terms:• Simplex One sender and one receiver.• Half Duplex One side can send at a time.• Full Duplex Both sides can send at same

time.• Typical serial communication today is Full

Duplex.

Page 16: Komunikasi Serial RS-232

Simplex

Page 17: Komunikasi Serial RS-232

Half Duplex

Page 18: Komunikasi Serial RS-232

Full Duplex

Page 19: Komunikasi Serial RS-232

Wiring

• Minimum 3 wires:– TX (transmit)– RX (receive)– gnd (V=0 reference)

• Maximum 23 wires!

Page 20: Komunikasi Serial RS-232

Connections

• Must have:• TX → RX• RX ← TX• Cables are easier to make if pins are

“straight through”. i.e. pin n connects to pin n.

Page 21: Komunikasi Serial RS-232

Connectors• 23 pin (ancient, un-needed)• 9 pin (IBM PC standard)

– Two connector wiring types– DTE: pin 2 = RX, pin 3 = TX “Data Terminal Equipment”– DCE: pin 2 = TX, pin 3 = RX “Data Communications Equipment”

• Thus, DCE can talk to DTE with a “straight through” cable.

• DTE, DCE are ancient names from time sharing days.• Typical today:

– PC == DTE– modem, printer, etc, == DCE

Page 22: Komunikasi Serial RS-232

Null Modem

• What if you want to connect a DTE to another DTE (such as PC-PC)?– Use a special cable which connects all lines

“straight through” except– pin 2 → pin 3 and– pin 3 ← pin 2

Page 23: Komunikasi Serial RS-232

Flow Control• Sometimes a slow device cannot handle data as fast as sender

(even at same baud rate).• Receiver needs a way to stop and start sender.• Hardware solution: Additional wires:

– RTS “Request to Send”. DTE sets this to mark to allow data to be sent to it by DCE.

• CTS “Clear to Send”. DCE sets this to mark to allow data to be sent to it by DTE.

• Hardware flow control can be enabled/disabled.• Software solution: Special Control Characters:

– XON (ctl Q) Start Transmitting– XOFF(ctl S) Stop Transmitting

• Note: If you use Hardware Flow control, then “null modem” cable must also cross the RTS

• and DTS wires (pins 7,8 on 9-pin IBM standard).

Page 24: Komunikasi Serial RS-232

Error Control

• Unfortunately, serial communication is subject to errors. Sources:– Electrical interference– Long wire lengths– Ground potential differences between

communicating systems.– Timing errors between sender and receiver

clocks (should be within 1%).

Page 25: Komunikasi Serial RS-232

Solutions

• Character Parity 9th data bit. Very weak and bandwidth hog.

• Checksum Add up a group of bytes. Send sum at end of packet. Compare.

• Parity Send parity of some group of bits (rows or colums) in the packet.

• CRC Use theory of binary polynomials. Send a code so that combined message is divisible by

• some known polynomial.

Page 26: Komunikasi Serial RS-232