Thursday, March 7, 2019

FMA Unit 4.6 RS 232



RS-232
·        In communication, RS232, (Recommended Standard 232) is standard introduced in 1960 for serial communication transmission of data.
  • An RS232 serial port was once a standard feature of a personal computer, used for connections to modems, printers, mica, data storage,   uninterruptible power supply, and other peripheral devices.
  •  In RS232 standard a bit 0 is represented by +3 to +25 V, while a bit 1 is represented by -3 to -25 V.
  • Hence, for connecting any RS232 to micro-controller voltage converters like MAX232 are required.
  • MAX232 is a line driver (Voltage converter) that converts TTL logic level to RS232 voltage level and vice versa.
  • This communication is useful for point to point communication at slow speed.   Ex. COM1 port in PC can be used for mouse, COM2 port in PC can be used for modem.



RS232 male connector


Pin Description DB-9 Connector:
PIN No.
Pin Name
1
DCD (Data Carrier Detect)
2
RxD (Received Data)
3
TxD (Transmitted Data)
4
DTR (Data Terminal Ready)
5
GND (Signal ground)
6
DSR (Data Set Ready)
7
RTS (Request to Send)
8
CTS (Clear to Send)
9
RI (Ring Indicator)

Signal Specifications
RS232 works on the two-way communication that exchanges data to one another. There are two devices connected to each other, (DTE) Data Transmission Equipment & (DCE) Data Communication Equipment.

The Data Terminal Equipment (DTE) wants to send data to Data Communication Equipment (DCE). The following signals are used.

        1.     DTR (Data Terminal Ready)
·        The DTE alerts the DCE for communication by sending this signal.
        2.     DSR (Data Set Ready)
·        The DCE send this signal to the DTE to inform DTE that DCE prepares itself for the communication.
        3.     RTS (Request to Send)
·        Once DTE receives the DSR signal, it prepares itself for the data transfer.
·        DTE send the RTS signal to DCE to inform that it is ready for the data transfer.
         4.     DCD (Data Carrier Detect)
·        In response to RTS, DCE tries to make contact with the remote MODEM.
·        If the carrier is detected it informs the DTE about it through the DCD signals.    
         5.     CTS (Clear to Send)
·        Once a stable contact is established with the remote MODEM, the DCE sends the CTS to DTE.
·         Due to this transmission begins.


Interfacing PC to 8051 using RS232 standard.
·        The PCs are based on 8086, 80286, 80386, 80486 and Pentium microprocessor.
·        Generally PCs have two COM ports, COM1 and COM2 . Both the ports have RS232 type connection.
·        The COM1 is used for mouse and COM2 is used for connecting devices like MODEM.




MAX232
The Max-232 IC is started by the maxim integrated products in 1987. It is an integrated circuit which converts the signals from the RS232 serial port to the proper signal which are used in the TTL compatible digital logic circuits. The MAX232 can convert the signals like RX, TX, CTS, and RTS and it is a dual driver/receiver.
The MAX-232 IC is an integrated circuit which consists of 16 pins and it is a resourceful IC mostly used in the voltage level signal problems. Generally, the MAX-232 IC is used in the RS232 communication system for the conversion of voltage levels on TTL devices that are interfaced with the PC serial port and the Microcontroller. This IC is used as a hardware layer converter like to communicate two systems simultaneously. The image of MAX232 is shown below.



The MAX232 consist of 16 pins with 3 major blocks. The power supply of this integrated circuit is 5V which is compatible with most of the embedded system. In the three major blocks, the first block is a voltage doubler by using the IC switched capacitor techniques are used to make the voltage doubler. If once the voltage is doubled, then the second block is converted to +10V and      -10V. The main function of voltage level is converted in the 3rd block which consists of the two transistors and 2 receivers. The following diagram shows the construction of the MAX232.


Monday, March 4, 2019

FMA_Unit_4.4 8051 Serial Communications registers


BAUD RATE: The transmitter and receiver are configured to communicate at some data transfer rate before communication starts. This data transfer rate or number of bits transmitted per second is called baud rate for handling serial communication.

UART: It stands for Universal Asynchronous Receiver-Transmitter. A UART generates its internal data clock to the microcontroller. It synchronizes that clock with the data stream by using the start bit transition. The receiver needs the baud rate to know ahead of time to properly receive the data stream.

C. 8051 Serial Communications registers
1. SBUF Register (Serial Buffer register)
  •  Buffer which is used for holding the data before sending / after receiving is called Serial Buffer.
  •  In 8051 Micro-controller there are two 8 bits serial buffer register.
  • One is write only and is used to hold data is to be transmitted from micro-controller via the TxD pin P3.1.
  • While other is read only and used to hold data that is received from the external source via the RxD pin P3.0.






2. SCON Register (Serial Control register)
D7
D6
D5
D4
D3
D2
D1
D0
SM0
SM1
SM2
REN
TB8
RB8
TI
RI

Bit 7 & 6: SM0 & SM1 (Serial Mode control Bits)
These bits are serial mode bits and are used for selecting the operating modes of serial port.
SM0
SM1
Mode
Description
Baud Rate
0
0
0
8 bit Shift Register
Fixed Baud Rate (fosc / 12)
0
1
1
8 bit UART
Variable Baud Rate
1
0
2
9 bit UART
Fixed Baud Rate (fosc / 12 or focs/32)
1
1
3
9 bit UART
Variable Baud Rate
Mode 0 and Mode 1 used for one serial port
Mode 2 and Mode 3 used for one serial port

Bit 5: SM2 (Multiprocessor control bit)
In 8051, there is only one serial port. So this is don’t care condition.
SM2 = 1, Multiprocessor serial port (Two serial Port used)
SM2 = 0, Uniprocessor serial port (One serial Port used)

Bit 4: REN (Receiver enable bit)
This bit allows the data from external peripheral device to micro-controller.
                    REN = 1, receiver is enable
                    REN = 0, receiver is disable

Bit 3: TB8 (Consider when serial Mode 2 and serial Mode 3 is used)
In 8051, there is only one serial port. So this is don’t care condition.
It is the 9th programmable transmitted bit along with data byte in multiprocessor mode.
                    TB8 = 1, the byte transmitted is data bit
                    TB8 = 0, the byte transmitted is address bit

Bit 2: RB8 (Consider when serial Mode 2 and serial Mode 3 is used)
In 8051, there is only one serial port. So this is don’t care condition.
It is the 9th received programmable bit along with data byte in multiprocessor mode.
                    RB8 = 1, the byte received is data bit
                    RB8 = 0, the byte received is address bit

Bit 1: TI (Transmit Interrupt flag)
TI = 1, When one byte of data transmission is completed
TI = 0, When one byte of data transmission is not completed

Bit 0: RI (Receive Interrupt flag)
RI = 1, When one byte of data reception is completed
RI = 0, When one byte of data reception is not completed


3. PCON Register (Power Control register)
D7
D6
D5
D4
D3
D2
D1
D0
SMOD
--
--
--
GF1
GF0
PD
IDL

Bit 7: SMOD (Serial Mode selection bit)
Speed of serial communication is decided by this SMOD bit.
When SMOD is reset then it is indicated that data is transmitted or received by microcontroller at defined baud rate.  (Baud Rate = fosc/64)
When SMOD is set then it is indicated that data is transmitted or received by microcontroller at double the defined baud rate. (Baud Rate = fosc/32)

Bit 6, 5 & 4: Reserve bit

Bit 3 & 2: GF1 and GF0 (General purpose flags)
          These flags are used by the programmer to indicate the status of the various conditions

Bit 1: PD (Power Down)
          When PD is set, internal oscillator stops and power is reduced to 2V from 5V for power saving purpose.

Bit 0: IDL (Power saving mode)
When IDL is set, the clock signal is stopped to CPU, but is supplied to interrupt, timer and serial port blocks. It can be reset by hardware interrupt.


Friday, March 1, 2019

FMA Unit 4.3 Serial Transmission format


B.   Serial Transmission format
1   1.  Asynchronous Data Transfer
     



·        It is “Character” oriented data transfer.
·        One data bit is transferred at a time.
·   When data is not transferred the output line of transmitter is High i.e. Marking State.
·  The start of data is indicated by a low start bit, which is used to synchronized transmitter and receiver. After the start bit, data bits are transfer serially.
·     The data bits are followed by a one or more high stop bits. After the stop bits same logical level is maintained on output lines.
·      The receiver will check for marking state. When it detects low on data line then it is treated as valid start bit.
·       After start bit receiver will start accepting data bits D0 to D7. At the end it will check stop bits and go back to initial marking state.
·        The asynchronous data transfer format consists of a start bit, data bits and stop bits called as Frame.
·   The clock to both transmitter and receiver are separate. But operating frequency for both is maintained same.






 2.  Synchronous Data Transfer




·        It is “Block of data” oriented data transfer.
·        The block of data bytes transferred serially one after the other.
·    Before sending data, special characters are transferred by transmitter to receiver to achieve synchronization between transmitter and receiver. This special character called as Sync Character.
·  To start transmission, the Sync Character bits are sent by transmitter followed by data bits.
·   When data is not transferred the output line of transmitter is High i.e. Marking State.
·     The receiver will go on checking input lines; and comparing whatever data received with Sync Character.
·     When match occurs then it is consider as the receiver is in synchronization with transmitter.
·      When the receiver is synchronized, then it will go on accepting data bits in the same sequence.
·     The clock of both transmitter and receiver is same to avoid wrong data bits.



FMA Unit 4.2 Serial Communication

Serial Communication in 8051 Micro-controller
               
Micro-controllers need to communicate with external devices such as sensors, computers and so on to collect data for further processing. Data communication generally done by means of two methods:
1.    Parallel data transfer and
2.    Serial data transfer
Parallel data transfer
Serial data transfer



8 data lines are needed to transfer a byte of data.
1 data lines are needed to transfer a byte of data.
8 bit data is transferred at a time
Only 1 bit data is transferred at a time
Time required to transfer the data is less.
Time required to transfer the data is more.
Data transfer is fast
Data transfer is slow.
More advantageous over small distance.
More advantageous over long distance.
Cost of connecting two distance point is high for long distance.
Cost of connecting two distance point is low for long distance.

Fig. Transfer of data serially


A.   Types of communication

The communication links are classified on the basis of transmission:                                1) Simplex and  2) Duplex                                                                                                                 
1     1)    Simplex:
·        The simplex is one way transmission.
·        The data will be transmitted only in one direction

2      2)    Duplex
·        The simplex is two way transmissions.
·        Half Duplex: Half duplex means data will be transmitted in both directions but at one time, only one device can transmit. This means that the line has to turn around after communication is complete in one direction.


·      Full Duplex: full duplex means data may be transmitted in both directions at one time, while one device is transmitting, it can also receive data transmitted from other device at same time.


The transmitter and receiver are configured to communicate at some data transfer rate before communication starts. This data transfer rate or number of bits transmitted per second is called baud rate for handling serial communication.