The basic elements of a communication are:
1. A sender (source) that creates the message to be transmitted
2. A medium that carries the message
3. A receiver (sink) that receives the message
There are two types of communications— parallel and serial. Parallel data transfer can be made through an 8-bit data line for faster communication.
Serial communication is often used to control or receive data from a microcontroller. It is a form of input/output (I/O) in which the bits of a byte being transferred appear one after the other in a timed sequence on a single wire. Serial data transfer is made through a serial link between the micrcontroller and the PC using RS-232C.
Fig.1 show the waveform on a single conductor to transmit a byte (say, 0x41) serially. The upper waveform is the TTL-level waveform at the transmit pin of the microcontroller (AT89S52). The lower waveform is the same waveform converted by the RS-232 driver (MAX232) into RS-232C level. The to assure error-free transmission over greater distances than would be possible with TTL levels.
Each byte is preceded by a start bit and followed by a stop bit. The start and stop bits are used to synchronise the serial receivers. The data byte is always transmitted with least-significant bit (LSB) first. For error checking, it is possible to include a parity bit as well, just prior to the stop bit.
The bits are transmitted at specific time intervals determined by the baud rate of the serial signal. The baud rate is the reciprocal of the time to send one bit. Error-free serial communication requires the baud rate, number of data bits, number of stop bits, and presence or absence of a parity bit to be the same at the transmitter and receiver ends.
Fig.2 shows the circuit for microcontroller- based serial data transfer to a PC. It comprises microcontroller AT89S52, RS-232 driver MAX232, regulator 7805 and a few discrete components.The microcontroller detects the switch pressed and the message is transmitted to the computer through the RS-232 driver.
The AT89S52 is a low-power, high performance CMOS 8-bit microcontroller. It has 8 kB of Flash, 256 bytes of RAM, 32 I/O lines, a watchdog timer, two data pointers, three 16-bit timers/counters, a six-vector two level interrupt architecture, a full-duplex serial port, and on chip oscillator and clock circuitry. In addition, the AT89S52 is designed with static logic for operation down to zero frequency and supports two software-selectable power-saving modes. The idle mode stops the CPU while allowing the RAM, timers/counters, serial port and interrupt system to continue functioning. The power – down mode saves the RAM contents but freezes the oscillator, disabling all other chip functions until the next interrupt or hardware reset.
Port pins P2.0 through P2.7 are pulled high by resistor network RNW1 and also connected to switches S1 through S8, respectively. An 11.0592MHz crystal is used for providing the basic clock frequency. All I/O pins are reset to ‘1’ as soon as RST pin goes high. Holding RST pin high for two machine cycles while the oscillator is running, resets the device. Power-on reset is derived from resistor R2 and capacitor C6. Switch S9 is used for manual reset.
The microcontroller provides a transmit channel and a receive channel for serial communication. The transmit data pin (TXD) is specified at port pin P3.1, and the receive data pin (RXD) is at port pin P3.0. RXD and TXD pins of the microcontroller are connected to TOUT (pin 7) and RIN (pin 8) of the MAX232, respectively. TIN (pin 10) and ROUT (pin 9) of IC2 are connected to pins 2 and 3 of the COM port connector, respectively. The signals provided on these pins are TTL-level and must be boosted and inverted through a MAX232 converter to comply with the RS-232 standard.