Anda di halaman 1dari 5

Microcontroller-Based Serial Data Transfer to PC

http://www.electronicsforu.com/electronicsforu/circuitarchives/view_arti...

ELECTRONICS ZONE

Engineer's Corner

Business Corner

Daily News
Login

Yellow Pages

Jobs
Advertise

eZines & Publications

Register

About Us

Contact Us

Circuits
Lighting

Careers
Solar

Videos

Features

Technical Articles
Automotive

Special
Consumer Electronics Medical Power

Automation

Communication

Defence & Aerospace

MCU

PROJECTS

Related Articles
Microcontroller-Based Tachometer Temperature Indicator-CUM-Controller EEPROM Interface for Beginners Microcontroller-Based Tachometer Temperature Indicator-CUM-Controller

Control Circuit Relay


www.globalspec.com Search Thousands of Catalogs for Control Circuit Relay

Subscribe to Electronicsforu.com

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.

Authors 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

1 of 5

8/24/2013 9:30 PM

Microcontroller-Based Serial Data Transfer to PC

http://www.electronicsforu.com/electronicsforu/circuitarchives/view_arti...

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

2 of 5

8/24/2013 9:30 PM

Microcontroller-Based Serial Data Transfer to PC

http://www.electronicsforu.com/electronicsforu/circuitarchives/view_arti...

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. R and TXD pins of the
XD

microcontroller are connected to T

OUT

(pin 7) and R

IN

(pin 8) of the MAX232, respectively. T

IN

(pin 10) and R

OUT

(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 = (2
SMOD

Oscillator frequency)/( 3212(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 doublecheck 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.

3 of 5

8/24/2013 9:30 PM

Microcontroller-Based Serial Data Transfer to PC

http://www.electronicsforu.com/electronicsforu/circuitarchives/view_arti...

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

4 of 5

8/24/2013 9:30 PM

Microcontroller-Based Serial Data Transfer to PC

http://www.electronicsforu.com/electronicsforu/circuitarchives/view_arti...

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

Post Comment

| 1 Comments

MANOJ SHARMA

72 days ago

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

Electronics Buzz
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

Magazines

Portals

Directories

Events

News Verticals

Educational Institute

Electronics for You LINUX for You Facts for You Electronics Bazaar

electronicsforu.com efytimes.com bpotimes.com linuxforu.com

Electronics Annual EFY EXPO Guide EFY Awards EduTech Expo OSIWEEK Expo

Electronics Infotech Linux & Open Source Consumer Electronics Science & Technology BPO

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

5 of 5

8/24/2013 9:30 PM

Anda mungkin juga menyukai