5

Click here to load reader

Microcontroller-Based Serial Data Transfer to PC

Embed Size (px)

DESCRIPTION

serial data transfer

Citation preview

Page 1: Microcontroller-Based Serial Data Transfer to PC

Circuits ∨ Careers Videos ∨ Features ∨ Technical Articles ∨ Special ∨

Lighting Solar Automation ∨ Communication ∨ Automotive Defence & Aerospace Consumer Electronics Medical Power

Related Articles

Microcontroller-Based Tachometer Microcontroller-Based Tachometer

Temperature Indicator-CUM-Controller Temperature Indicator-CUM-Controller

EEPROM Interface for Beginners

Subscribe to Electronicsforu.com

0

ELECTRONICS ZONE Engineer's Corner Business Corner Daily News Yellow Pages Jobs eZines & Publications

Login | Register | Advertise | About Us | Contact Us

M C U P R O J E C T S

Microcontroller-Based Serial Data Transfer To PC

T. Shankar And S. Thangamani

Communication from or to a computer has become almost essential in our day-to-day lives.

Though we can execute many programs within a computer itself, it will not be of much use

without outside communication.

Author’s prototype

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

Control Circuit Relay

www.globalspec.com

Search Thousands of Catalogs for Control Circuit Relay

Microcontroller-Based Serial Data Transfer to PC http://www.electronicsforu.com/electronicsforu/circuitarchives/view_arti...

1 of 5 8/24/2013 9:30 PM

Page 2: Microcontroller-Based Serial Data Transfer to PC

transfer is made through a serial link between the micrcontroller and the PC using RS-232C.

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.

Fig.1. Serial Waveform

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.

Circuit description

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.

Fig.2:Circuit for microcontroller-based serial

data transfer to a PC

Microcontroller-Based Serial Data Transfer to PC http://www.electronicsforu.com/electronicsforu/circuitarchives/view_arti...

2 of 5 8/24/2013 9:30 PM

Page 3: Microcontroller-Based Serial Data Transfer to PC

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.

The MAX232 has two internal charge-pumps that convert +5V into ±10V (unloaded) for RS-232 driver operation. The first

converter uses capacitor C7 to double the +5V input to +10V on capacitor C9 at pin 2. The second converter uses capacitor

C8 to invert +10V to -10V on capacitor C10 at pin 6.

All the serial communication is controlled through special function register SCON. This register contains mode-selection bits,

ninth data bit for transmit and receive (TB8 and RB8), and serial-port interrupt bits (TI and RI). Serial communication

requires standard baud rate. Timer 1 is configured in the auto-reload mode to generate the baud rate. The baud rate is

determined as:

Baud rate = (2SMOD

× Oscillator frequency)/( 32×12×(256 - TH1))

To derive the power supply, the 230V AC mains is stepped down by transformer X1 to deliver the secondary output of 9V,

300 mA. The transformer output is rectified by a full-wave bridge rectifier comprising diodes D1 through D4, filtered by

capacitor C1 and then regulated by IC 7805 (IC3). Capacitor C2 bypasses the ripples present in the regulated 5V power

supply. LED1 acts as the poweron indicator and resistor R1 limits the current through LED1.

Construction and testing

An actual-size, single-side PCB for microcontroller-based serial data transfer circuit is shown in Fig.3(View as PDF) and its

component layout in Fig.4(View as PDF). Assemble the circuit on the PCB to minimise assemble the components and double-

check for any overlooked error. Connect the assembled circuit to the COM port available at the back side of a computer. The

information stored in the microcontroller is sent to the PC through the COM port using the HyperTerminal program.

Microcontroller-Based Serial Data Transfer to PC http://www.electronicsforu.com/electronicsforu/circuitarchives/view_arti...

3 of 5 8/24/2013 9:30 PM

Page 4: Microcontroller-Based Serial Data Transfer to PC

Fig.5: HyPerterminal window

for name and icon

To open the HyperTerminal program, go to Start → Programs → Accessories → Communications → HyperTerminal. You will

see a window as shown in Fig. 5. Type in the desired name and click ‘ok.’ Select a COM port (refer Fig.6) while ignoring the

other options and click ‘ok.’

Fig.6: HyPerterminal window for COM port selection

Now select the baud rate as ‘9600,’ data bits as ‘8,’ parity as ‘none,’ stop bits as ‘1’ and flow control as ‘none,’ and click ‘ok’

(refer Fig.7).

Fig.7: HyPerterminal window for selection of baud

rate, data bits, parity, stop bits and flow control

When you press switches S1 through S8, the microcontroller sends the stored message and you will see the message

appear on the screen as shown in Fig.8.

Fig.8: Message on HyPerterminal screen

Microcontroller-Based Serial Data Transfer to PC http://www.electronicsforu.com/electronicsforu/circuitarchives/view_arti...

4 of 5 8/24/2013 9:30 PM

Page 5: Microcontroller-Based Serial Data Transfer to PC

0

Post Comment | 1 Comments3 6 5

MANOJ SHARMA 72 days ago

DEAR SIRi WANT TO BUILT A PROJECT IN WHICH I HAVE TO DISPLAY THE VOLTAGE AND SPEED ON THECOMPUTER BY 89S52 CONTROLLER. THE VOLTMETER IS BUILT AROUND 89S52 AND SPEEDOMETER IS BUILTAROUND 89C2051 BUT BOTH USE 16X2 LCD DISPLAY. CAN THE ABOVE CIRCUIT DISPLAY THE SAME ONCOMPUTER?

Reply

Industry hopeful of meeting BIS deadline

India offers $ 78.5 million in subsidies for off-grid solar PV, solar thermal in 2012-13

AP government helps consumers become self sufficient in power

Electronic surveillance of Indians �Unacceptable�: Sibal

Flat panel display (FPD) TV market in India estimated to grow to USD 6.39 billion By 2015: Frost & Sullivan

Software

The software for this project is given at the end of this article. It is written in ‘C’ language and compiled using Keil μ Vision3

compiler. The finally obtained ‘.hex’ file is downloaded to the microcontroller using a suitable programmer. The source

program is well commented and easy to understand.

In the software, first enable timer and serial interrupts. Then configure the timer by mode and reload value to give the

correct speed (9600 bits per second). Next, make the transmit interrupt 1 (TI) move the data to SCON. SCON will give the

necessary UART signal and your data will be sent serially.

EFY note. The source code of this article is included in the link give below:

http://www.efymag.com/admin/issuepdf/PCSerialCommunicationTester.zip

Related Articles

Microcontroller-Based Tachometer

Posting Date: July 11, 2013 | Views: 1295

Microcontroller-Based Tachometer

Posting Date: July 11, 2013 | Views: 1295

Temperature Indicator-CUM-Controller

Posting Date: July 11, 2013 | Views: 725

Temperature Indicator-CUM-Controller

Posting Date: July 11, 2013 | Views: 725

EEPROM Interface for Beginners

Posting Date: June 20, 2013 | Views: 1214

Electronics Buzz

Magazines

Electronics for You

LINUX for You

Facts for You

Electronics Bazaar

Portals

electronicsforu.com

efytimes.com

bpotimes.com

linuxforu.com

Directories

Electronics Annual

Guide

Events

EFY EXPO

EFY Awards

EduTech Expo

OSIWEEK Expo

News Verticals

Electronics

Infotech

Linux & Open

Source

Consumer

Electronics

Science &

Technology

BPO

Educational Institute

EFY Techcenter

Kitsnspares.com

© Copyright 2012 EFY Enterprises Pvt. Ltd. All rights reserved.

Reproduction in whole or in part in any form or medium without written permission is prohibited. Usage of the content from the web site is subjectT etor ms and Conditions

Microcontroller-Based Serial Data Transfer to PC http://www.electronicsforu.com/electronicsforu/circuitarchives/view_arti...

5 of 5 8/24/2013 9:30 PM