[?] Subscribe To This Site

XML RSS
Add to Google
Add to My Yahoo!
Add to My MSN
Add to Newsgator
Subscribe with Bloglines


Custom Search

Sign up for MicroZine:
''The'' Microcontroller Newsletter


:
:
Don't worry -- your e-mail address is totally secure. I promise to use it only to send you MicroZine
Enter your first Name and primary email address in the form above:

And receive absolutely FREE a full project for:


"Measuring Analogue Voltages
Without An ADC"

(Using only one pin).

Instant Download:
You Can
Get It Right Now

Warning: This project could be Removed
at any time.  

It will NOT be
available indefinitely SO

To avoid
disappointment get it:

Now



Remember this is a project with full description and fully debugged C Source code - and it's not available from the main website.

You can only get it through this newsletter.


To get exclusive access Enter your first name Name and primary email address Now in the form above.:

But wait !

There's more...

You'll receive more
free and exclusive reports as well as site information and site product updates.

Scroll up to the form above and sign up NOW.  Don't forget it's FREE and if you don't like it you can unsubscribe at any time.

Click Here Now to use the form above to get your Valuable information absolutely free.



Social Bookmarking
Click & Add:
add to BlinkBlink
add to Del.icio.usDel.icio.us
add to DiggDigg
add to FurlFurl
add to GoogleGoogle
add to SimpySimpy
add to SpurlSpurl
Bookmark at TechnoratiTechnorati
add to YahooY! MyWeb
Readers comments

"I wanted to thank
you so so so much
for all the information
you have provided in
your site it's

SUPERB and FANTASTIC."


- Ranish Pottath


"This site really is
the best and my favorite.
I find here many useful
projects and tips."

- Milan

bursach<at>gmail.com

Learn PIC C Now
Wondering how to program your next project using C and need a great start?


"Awesome site,
very, very easy and nice
to navigate!"


- Matt
matt_tr<at>
wolf359.cjb.net


"I am a newbie to PIC
and I wanted to say
 how great your
site has been for me."


- Dave

de_scott<at>bellsouth.net

Learn Microcontrollers
"Interested in
Microcontrollers?"


Sign up for The
Free 7 day guide:

FREE GUIDE : CLICK HERE

"Your site is a great
and perfect work.
congratulations."


- Suresh

integratredinfosys<at>
yahoo.com

"I couldn't find the correct
words to define
yourweb site.

Very useful, uncovered,
honest and clear.

Thanks so much for
your time and works.
Regards."


- Anon





Does RS232 work ? Five simple rules to ensure your RS232 system works.

How to make RS232 work.
Follow these simple rules
then it will
work!...

"Download Your Essential
Guide To Logic Level MOSFETs"

"This is completely Free"

CLICK HERE to DOWNLOAD NOW

Sponsored Links...

How to make RS232 work: Follow these simple rules then it will work.

Click here for information on how RS232 works at the physical bit level.

I have been using RS232 at work for years and it always flys along and is always reliable but there are some simple rules to follow otherwise you can get in big mess.

Jump to Rule 1 : Keep it simple.
Jump to Rule 2 : Use a straight through cable.
Jump to Rule 3 : Make cross over at dev. board.
Jump to Rule 4 : Set RS232 Identical at each end.

Jump to Rule 5 : Re-check connections at both connectors.

Jump to Setting up Hyperterminal.

Jump to other RS232 problems.

If you are looking for information on general RS232 use then these rules can act as guidance but you will need to understand more about DCE (data communication equipment) and DTE (Data Terminal Equipment), all the handshaking and all the types of cable for your system. Basically there are too many - so looking at the following information could help you get a handle on the simplest configuration to show you that in fact RS232 does work.

RS232 can actually work well but a lot of software requires all the handshake signals to be in place and this is why it can be so frustrating - miss one out or connect a single wire wrongly and it will just sit there doing absolutely nothing.

Rule 1 : Keep it simple.

RS232 is only difficult if you try to use all the facilities that the standard provides. You really don't need to consider all the signals when using RS232 on the bench (for simple communication between your hardware and a PC) i.e. to make RS232 work over a few metres.

If you want to make RS232 work over long distances then you must use all the signals including handshake signals as these ensure correct operation. For 1-3 metres I only ever use the following:

  • TXD Transmit data
  • RXD Receive data
  • GND Ground
These work for speeds of 9600 baud and beyond. You can test how far beyond by experimenting with the settings in the PIC program and PC software.

Rule 2: Use a straight through cable.

This is a cable where pin 1 connects to pin 1 at the other end, pin 2 connects to pin 2 at the other end etc.

There are two cable types:

  • Straight through - also known as modem.
  • Cross over - also known as null modem.

Note: Signals that are crossed over for a null modem cable are (TX,RX) and handshaking signals (RTS,CTS) and (DSR,DTR).

If you don't know what cable type you have then use a multimeter to test on its buzz setting. To make sure you don't drop everything on the floor stick a piece of wire in the female connector and wrap the other end of the wire around the multimeter probe - then you can concentrate on probing the pin in the male connector. To keep things simple use a straight through cable.

Note: Serial cables are never marked as null modem or modem - they all look the same!

The key to getting an RS232 system to work is knowing exactly what cable you have and its pin connections. Using a straight through cable you don't need to worry about Modem / Null modem cables and this eliminates a source of confusion.

Rule 3 : Crossover at your dev. board.

You can not make the crossover at the PC end as you just plug the serial cable into the PC - and that's fine. At this point you have direct connections from the Serial connector at the back of the PC all the way to your development board.

So you know exactly where you are - all connections to the development board are straight through from the PC. The final step is to make the cross over on the board.

The schematic below shows a development board with a serial connection to/from the PC that lets RS232 work between a microcontroller and the PC.

PIC rs232 connection example

I have labeled the serial connector with the connections located at the PC - this makes it easier to visualize the whole system.

You can think of the PC and cable as one unit connecting directly to the development board and you do not need to worry about null modem cables, crossover cables, gender changers, cross over boxes etc. You only need to concentrate on the schematic with the PC serial port as an extension of the schematic.

All you do next is to connect the serial connector labeled TX (which is the serial input to the development board from the PC) to the receiver on your development board (labeled R1IN). Similarly connect T1OUT (which is the serial output from the development board) to the PC Serial port labeled RX. This makes the cross-over on your board. Next connect the grounds together (GND and 0 volts).

Rule 4 : Use identical settings at each end.

In each program there will be a setting that defines the usage of the bits transmitted between the PC and the microcontroller. To make RS232 work these settings must be identical. As a starting point use the following settings at each end.

Bits per second (BAUD) 9600
Number of bits 8
Parity None
Stop bits 1
Flow control None

If you want to change anything just change one thing at a time but again keep the same value(s) in both bits of software.

These settings are standard settings

Hyperterminal settings

In Windows you can find Hyperterminal (an accessory program) by navigating from the start menu (in windows XP):

Start->All Programs->Accessories->Communications->Hyperterminal

The following start dialog is shown (I have entered the name PIC to identify the session):

hyperterminal start for serial port

Hit OK and you are shown the connection dialog.

hyperterminal connection for serial port

Hit Cancel for this dialog as you don't want to dial out.

Now from the main menu in Hyperterminal Hit File->Properties

hyperterminal properties for PIC rs232

Select the 'Connect using' drop down menu (in the middle) and select the serial port you want to use e.g. COM1.

select hyperterminal COM1

Then hit the 'Configure' button underneath.

Serial port configuration parameters for hyperterminal

Phew! - got there at last - Now set the parameters as shown previously.

Rule 5 : Check your connectors before building a pcb.

A big source of confusion in making RS232 work is the connector gender (male or female). Usually a pcb designer is given a diagram that does not specify the gender of the part - and uses the one that was used last time. When it comes to building the board the connections are mirrored (male and female connectors are mirrors of each other) and you have to hand wire the connection.

To ensure that this does not happen always lay out all the parts before finishing the schematic so that you ensure the correct gender of connections from one end of the system to the other.

Getting the gender of the connections is essential so double and even triple check the parts so that you know in your head which way to connect up the system.

Now drive the PIC micro using your USART code.

Other reasons that the RS232 may not work

If you are writing code on the PC the serial ports are really fussy about what connections are made to the serial port and require looped back signals unless care is taken to program the chips in the PC so that they do not require loop backed signals. It is best just to use known working programs such as Hyperterminal.

Note: Loop back means faking the signals at one end - DTS is connected to RTS and DTR is connected to DSR (at the same end) - sometimes you need to control CD as well.

Another reason for RS232 not to work is if you use equipment that is powered by the serial port. Laptops are optimized for power saving so they give out the minimum power (lower volts and current).

Another possibility for RS232 not to work is voltage level sensing. Levels detected by the serial chip in the PC may not allow detection of the signal.

Newer serial port chip in the PC detect voltages below 3V (and above -3V) as a 'one' but older chips will not report it since the RS232 standard defines this voltage range as undetermined. For these older chips the voltage for a 'one' (mark) must be lower than -3V and for a 'zero' (space) must be higher than 3V. The ±3V indeterminate area gives the RS232 system immunity to noise and this allows the system to work in an electrically noisy environment but sacrificing the noise immunity means that it is easier to interface using standard CMOS logic levels (0,5V).

The only way to find out if your system works with (0,5V) logic levels is to test it - which is a pain (and what if you change it later). So it is just much easier to use a level translator chip such as a MAX232.

So does RS232 work ? - If you follow these guidelines then RS232 will work.


Jump from Getting RS232 to work to
Best Microcontroller Projects Home Page.



Don't forget to Sign Up for your

Microcontroller Newsletter

With "Essential tips and techniques",

..."New Site Info" and more...

Including a free project :

How to drive an LCD and 12key keypad using "Only One 8 Bit Port" with no interface logic!...

(Works for any microcontroller)

This costs you : Nothing...
Just fill out the form below and you'll get full C source code and project schematic and description.



:
:
Don't worry -- your e-mail address is totally secure. I promise to use it only to send you MicroZine
Google

  Best Microcontroller projects.