Serial Communication With Arduino

by embeddedbymedhavi in Circuits > Arduino

127 Views, 1 Favorites, 0 Comments

Serial Communication With Arduino

serial2.png

SERIAL COMMUNICATION:

  • Serial Communication uses single data line making it much cheaper
  • Enables two computers in different cities to communicate over the telephone
  • byte of data must be converted to serial bits using a parallel-in-serial-out shift register and transmitted over a single data line
  • Receiving end there must be a serial-in-parallel-out shift register
  • if transferred on the telephone line, it must be converted to audio tones by modem
  • for short distance the signal can be transferred using wire
  • how PC keyboards transfer data to the motherboard
  • 2 methods, asynchronous and synchronous
  • Synchronous method transfers a block of data (characters) at a time
  • Asynchronous method transfers a single byte at a time
  • Uses special IC chips called UART (universal asynchronous receiver-transmitter) and USART (universal synchronous asynchronous receiver-transmitter)

Half- and Full-duplex Transmission

serial3.png

  • if the data can be transmitted and received, it is a duplex transmission
  • simplex transmissions the computer only sends data
  • duplex transmissions can be half or full duplex
  • depends on whether or not the data transfer can be simultaneous
  • If one way at a time, it is half duplex
  • If can go both ways at the same time, it is full duplex
  • full duplex requires two wire conductors for the data lines (in addition to the signal ground)

Asynchronous Serial Communication and Data Framing

  • data coming in 0s and 1s
  • to make sense of the data sender and receiver agree on a set of rules
  • Protocol ·
  • how the data is packed ·
  • how many bits/character ·
  • when the data begins and ends

Start and Stop Bits

seriel 4.png

Start and stop bits

  • asynchronous method, each character is placed between start and stop bits · called framing · start bit is always one bit
  • stop bit can be one or two bits
  • start bit is always a 0 (low)
  • stop bit(s) is 1 (high) ·
  • LSB is sent out first
  • in modern PCs one stop bit is standard
  • when transferring a text file of ASCII characters using 1 stop bit there is total of 10 bits for each character
  • 8 bits for the ASCII code (1 parity bit), 1 bit each for the start and stop bits · for each 8-bit character there are an extra 2 bits, which gives 20% overhead ·

Data transfer rate:

  • rate of data transfer bps (bits per second)
  • widely used terminology for bps is baud rate
  • baud and bps rates are not necessarily equal
  • baud rate is defined as the number of signal changes per second

RS232 Standards

serial 4.png
serrial 5.png

  • most widely used serial I/O interfacing standard
  • input and output voltage levels are not TTL compatible
  • 1 bit is represented by -3 to -25 V
  • 0 bit is +3 to +25 V ·
  • -3 to +3 is undefined
  • to connect RS232 to a microcontroller system must use voltage converters such as MAX232 to convert the TTL logic levels to the RS232 voltage levels, and vice versa
  • MAX232 IC chips are commonly referred to as line drivers

Data Communication Classification

serial6.png

  • DTE (data terminal equipment)
  • DCE (data communication equipment)
  • DTE - terminals and computers that send and receive data
  • DCE - communication equipment responsible for transferring the data
  • simplest connection between a PC and microcontroller requires a minimum of three pins, TxD, RxD, and ground

Baud Rate

serial9.png

Write a Program to Transmit Data on the PC

serial trans.png

Simulation of transmit data from the PC is given in above.

C Code of Serial Transmit:

Downloads

Write a Program to Receive Data From the PC.

serail receive.png

Simulation of receive data from the PC is given in above.

C Code of Serial Receive:

Downloads

Any Query related Embedded System , IOT and Raspberry PI go to My Blog:

embeddedbymedhavi