Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PIC]:Simple RS232 hardware

8 views
Skip to first unread message

Andy N1YEW

unread,
Sep 8, 2001, 6:38:26 AM9/8/01
to PIC...@mitvma.notneeded.mit.edu
Andy Shaw wrote:
> Resent missing header!
> Hi Folks,
> I'm sure this must have been covered before but a search of piclist.com
> failed to find anything... Anyway what would you recommend as the
> simplest/minimal hardware RS232 interface for use between a PIC and a
> modern PC? This is *not* for a production product I would just like to be
> able to include a very cheap interface on a home project for occasional
> diagnostic/config use. Can I get away without using a MAX* converter? What
> are the pros/cons? What would be your suggested circuit?
>
> Thanks
>
> Andy

Ignore Kat, and try this:

PC: PIC:
TX ---|>|--/\/\/\------ PIC RX
|
GND-/\/\/\-

RX---------------- PIC TX

Works for me every time.

andy

--
http://www.piclist.com hint: To leave the PICList
mailto:piclist-unsub...@mitvma.Take.This.Out.mit.edu


Also-Antal Csaba

unread,
Sep 8, 2001, 7:01:42 AM9/8/01
to PIC...@mitvma.remove.mit.edu
Andy Shaw wrote:
>
> Resent missing header!
> Hi Folks,
> I'm sure this must have been covered before but a search of piclist.com
> failed to find anything... Anyway what would you recommend as the
> simplest/minimal hardware RS232 interface for use between a PIC and a modern

pic/sx pc
17k
Rx----------|||||||----------------Tx
|
|
_
_
_ 100k
_
|
| gnd
_______


Tx----------|||||||----------------Rx
100 ohm or nothing


On the pic/sx site you must invert the signals.

udv
Csaba

--
http://www.piclist.com hint: To leave the PICList

mailto:piclist-unsub...@mitvma.We.Hate.SP.AM.mit.edu


Dale Botkin

unread,
Sep 8, 2001, 9:36:01 AM9/8/01
to PIC...@mitvma.fight.spam.mit.edu
> I'm sure this must have been covered before but a search of piclist.com
> failed to find anything... Anyway what would you recommend as the
> simplest/minimal hardware RS232 interface for use between a PIC and a modern
> PC? This is *not* for a production product I would just like to be able to
> include a very cheap interface on a home project for occasional
> diagnostic/config use. Can I get away without using a MAX* converter? What
> are the pros/cons? What would be your suggested circuit?

For one-off, home projects, I'm in the "resistor-to-PIC" crowd. I've used it a dozen or so times with no problems... but of course people are right, it's not true EIA-232, it's not guaranteed to work, etc etc. Truth is it will work in the vast majority of cases, but I'd probably not use it in a production device. I have seen it done in commercial products though, often. Mice come to mind.

Pros: Dirt cheap. Extremely simple. Dirt cheap.
Cons: You HAVE to do bit-banged comms, since there is no way to invert UART data. Also not precisely to PIC datasheet specs. Of course, neither is at least one of Microchip's app notes using 110VAC directly to a PIC pin via a high-value resistor. I figure if they do it so can I at less than 10% of the voltage.

In those cases where I had to use the hardware UART and didn't have a MAX232 type device handy, I have (in a pinch, temporarily) used a 74LS04 in place of a MAX232. Just use two inverter sections to invert the TxD and RxD; I used 330K Ohm resistors between the LS04 and the PC. I wouldn't say I recommend this, but it has worked for me -- like I said, in a pinch and as a temporary thing.

Dale
--
A train stops at a train station. A bus stops at a bus station.
On my desk I have a workstation...

--
http://www.piclist.com hint: To leave the PICList

mailto:piclist-unsub...@mitvma.NotNeeded.mit.edu


Drew Vassallo

unread,
Sep 8, 2001, 10:21:13 AM9/8/01
to PIC...@mitvma.cut.mit.edu
> > I'm sure this must have been covered before but a search of piclist.com
> > failed to find anything... Anyway what would you recommend as the
> > simplest/minimal hardware RS232 interface for use between a PIC and a
>modern
> > PC? This is *not* for a production product I would just like to be able
>to
> > include a very cheap interface on a home project for occasional
> > diagnostic/config use. Can I get away without using a MAX* converter?
>What
> > are the pros/cons? What would be your suggested circuit?

I've also used the resistor-to-PIC successfully. Perhaps this information
will help; I got it from the list a while ago:

------------- snip --------------

From: Bob Blick (b...@TED.RemovE.NET)
*********************************************************************************
NOTE: THE LOGIC LEVELS BOB INDICATES ARE CORRECT FOR DIRECT-CONNECTIONS MADE
TO
THE SERIAL PORT FROM THE PIC PINS. YOU DO NOT NEED TO INVERT THE SIGNAL
LEVELS
THAT ARE INDICATED HERE.


Computer: pin 2 = input (RX), pin 3 = output (TX), pin 5 = ground (GND)
*********************************************************************************
On Sat, 16 Dec 2000, Peter May wrote:
>Is it possible to kook up a one pin out of a 16F84 as a serial out, to a
>serial port on my computer and run a plain old terminal screen so I can
>send
>some values to watch? I gather I would have to hook the pin to the data in
>on the serial and gnd to gnd? It is just for test purposes.

Yes, just hook it up to pin 2 of a regular DB9 connector. The PC wants
to know something is there hardware-wise, so usually I tie pins 7 and 8
together, and also pins 4 and 6 together.

Ground on the DB9 connector is pin 5.

As far as software on the pic, you need to generate time delays equal to
one baud of time, after first sending a start bit(make the pin high) and
shove out the byte one bit at a time by shifting(rotating) right(send the
least significant bits first).

Make sure you send a stop bit(low) after your byte, actually it's good to
delay two stop bits of time.

OK, that sends serial out, but if you use a terminal, it expects ascii, so
you should also create another routine that makes two ascii hex characters
out of a byte so you can send that. A 16 element lookup table works well,
called twice(once for each nibble).

**** NOTE: THIS IS CORRECT IF YOU WANT "5F" TO APPEAR ON YOUR TERMINAL
SCREEN
AS A REPRESENTATION OF A RAW HEX VALUE. IF YOU WANT TO SEND AND RECEIVE
DATA
DIRECTLY FROM THE TERMINAL TO AN LCD, FOR EXAMPLE, YOU DON'T NEED TO
CONVERT,
AS THE ASCII HEX NOTATION WILL BE CORRECT FOR BOTH SCREENS (ROUGHLY, THERE
ARE A FEW THAT DON'T MIRROR EXACTLY)


--------------- continued snip ----------------------

From: Dale Botkin (da...@BOTKIN.Extra.ORG)

On Sat, 16 Dec 2000, Peter May wrote:
>Is it possible to kook up a one pin out of a 16F84 as a serial out, to a
>serial port on my computer and run a plain old terminal screen so I can
>send
>some values to watch? I gather I would have to hook the pin to the data in
>on the serial and gnd to gnd? It is just for test purposes.

If it's a test lash-up, you can get away with using a 100K Ohm or so
resistor in series with the TxD line to the PC -- that is, TxD on the PIC
conencted to RXD on the PC via a series resistor. You will need signal
ground also. Data needs to be sent inverted, which means you can't use
the internal UART on PICs that have them. I use this with a 16F84 and
others to send data to a PC. You can do the opposite (receive inverted
data via serial resistor) if you need 2-way communication, same
restriction about not using the internal UART because it can't send or
receive the data inverted.

Some people vehemently oppose this method. It works quite well every time
for me and several others. I wouldn't recommend it for a production
system, a MAX232 or similar device works well for that, and you can use
the internal UART.

---------------- end snip ---------------

Good luck.

--Andrew

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

--
http://www.piclist.com hint: To leave the PICList

mailto:piclist-unsub...@mitvma.Take.This.Out.mit.edu


Jim

unread,
Sep 8, 2001, 10:25:51 AM9/8/01
to PIC...@mitvma.no.spam.mit.edu
... send to the piclist this time? ...


"used a 74LS04"

Substitute the 'LS04' with a 74HC14 and
you've got my solution. The HC14 will (Schmitt
Trigger) assure 'clean', sharp tiggering on
slow rise/fall time serial input signals ...

Also, I'm not too sure a *true* "LS04" gate
can actually pulled low through a 330K Ohm
resistor - a true TTL LS (bipolar, Low-power
Schottky) gate is spec'd at more like .4 mA
low-level input current. This would require
a voltage of -132 VDC to be applied to the
330K Ohm resistor to supply .4 mA of current
for a logic low input to the gate!

With a CMOS gate - this is not an issue. Just
make sure the device family includes built-in
"clamping" diodes (normally associated/used
with/for static-protection) ...

Jim

----- Original Message -----
From: "Dale Botkin" <da...@botkin.NoThiS.org>
To: <PIC...@MITVMA.Delete.MIT.EDU>
Sent: Saturday, September 08, 2001 9:39 AM
Subject: Re: [PIC]:Simple RS232 hardware


> > I'm sure this must have been covered before but a search of piclist.com
> > failed to find anything... Anyway what would you recommend as the
> > simplest/minimal hardware RS232 interface for use between a PIC and a
modern
> > PC? This is *not* for a production product I would just like to be able
to
> > include a very cheap interface on a home project for occasional
> > diagnostic/config use. Can I get away without using a MAX* converter?
What
> > are the pros/cons? What would be your suggested circuit?
>

> For one-off, home projects, I'm in the "resistor-to-PIC" crowd. I've used
it a dozen or so times with no problems... but of course people are right,
it's not true EIA-232, it's not guaranteed to work, etc etc. Truth is it
will work in the vast majority of cases, but I'd probably not use it in a
production device. I have seen it done in commercial products though,
often. Mice come to mind.
>
> Pros: Dirt cheap. Extremely simple. Dirt cheap.
> Cons: You HAVE to do bit-banged comms, since there is no way to invert
UART data. Also not precisely to PIC datasheet specs. Of course, neither
is at least one of Microchip's app notes using 110VAC directly to a PIC pin
via a high-value resistor. I figure if they do it so can I at less than 10%
of the voltage.
>
> In those cases where I had to use the hardware UART and didn't have a
MAX232 type device handy, I have (in a pinch, temporarily) used a 74LS04 in
place of a MAX232. Just use two inverter sections to invert the TxD and
RxD; I used 330K Ohm resistors between the LS04 and the PC. I wouldn't say
I recommend this, but it has worked for me -- like I said, in a pinch and as
a temporary thing.
>
> Dale
> --
> A train stops at a train station. A bus stops at a bus station.
> On my desk I have a workstation...
>

> --
> http://www.piclist.com hint: To leave the PICList

> mailto:piclist-unsub...@mitvma.RemoveThis.mit.edu
>
>

--
http://www.piclist.com hint: To leave the PICList

mailto:piclist-unsub...@mitvma.Spammers.Are.Scum.mit.edu


James Newton. Admin 3

unread,
Sep 8, 2001, 11:30:08 AM9/8/01
to PIC...@mitvma.no.spam.mit.edu
The link from
http://www.piclist.com/techref/microchip/rs232.htm
to
http://www.piclist.com/techref/io/serial/ttl-rs232.htm
was broken which may account for your not finding it.

Let me know if there is anything missing.

James Newton, PICList Admin #3
mailto:james...@piclist.NoThiS.com
1-619-652-0593 phone
http://www.piclist.com

----- Original Message -----
From: Andy Shaw <and...@GLOOMY-PLACE.Delete.COM>
To: <PIC...@MITVMA.RemoveThis.MIT.EDU>
Sent: Saturday, September 08, 2001 03:41
Subject: [PIC]:Simple RS232 hardware


Resent missing header!
Hi Folks,

I'm sure this must have been covered before but a search of piclist.com
failed to find anything... Anyway what would you recommend as the
simplest/minimal hardware RS232 interface for use between a PIC and a modern
PC? This is *not* for a production product I would just like to be able to
include a very cheap interface on a home project for occasional
diagnostic/config use. Can I get away without using a MAX* converter? What
are the pros/cons? What would be your suggested circuit?

Thanks

Andy

--


http://www.piclist.com hint: To leave the PICList

mailto:piclist-unsub...@mitvma.Cut.mit.edu


Ian Jordan

unread,
Sep 8, 2001, 12:30:07 PM9/8/01
to PIC...@mitvma.removethis.mit.edu
Something that works for me on the RX side on the PIC is to use a transistor
do do the inversion and conversion. When I have a project that only does
RS-232 RX, I don't need to deal with the voltage upconversion. One
transistor and two resistors have always worked great for me on the PIC RX
side, even when using the USART.

--Ian

----- Original Message -----
From: "Also-Antal Csaba" <ant...@MAIL.Bogus.MATAV.HU>
To: <PIC...@MITVMA.Fight.Spam.MIT.EDU>
Sent: Saturday, September 08, 2001 5:03 AM
Subject: Re: [PIC]:Simple RS232 hardware


> Andy Shaw wrote:
> >
> > Resent missing header!
> > Hi Folks,
> > I'm sure this must have been covered before but a search of piclist.com
> > failed to find anything... Anyway what would you recommend as the
> > simplest/minimal hardware RS232 interface for use between a PIC and a
modern
>

> pic/sx pc
> 17k
> Rx----------|||||||----------------Tx
> |
> |
> _
> _
> _ 100k
> _
> |
> | gnd
> _______
>
>
> Tx----------|||||||----------------Rx
> 100 ohm or nothing
>
>
> On the pic/sx site you must invert the signals.
>
> udv
> Csaba
>

> --
> http://www.piclist.com hint: To leave the PICList

> mailto:piclist-unsub...@mitvma.Extra.mit.edu
>
>

--
http://www.piclist.com hint: To leave the PICList

mailto:piclist-unsub...@mitvma.Delete.mit.edu


Dan Michaels

unread,
Sep 8, 2001, 1:10:15 PM9/8/01
to PIC...@mitvma.delete.mit.edu
Andy Shaw wrote:
>Resent missing header!
>Hi Folks,
>I'm sure this must have been covered before but a search of piclist.com
>failed to find anything...
........


Andy, this topic "has" been beat to death "many" times on piclist
in the past.

However, what you may not understand is that < piclist.com > and the
< PICLIST Mailing List Archives >, ie piclist discussion group, are
not really the same thing. AFAIK, piclist.com does not contain the
archives.

If you want to search the discussion group archives, goto to the
bottom of the page at the folowing site and use the search engine.
You'll find 100s of RS232 references.

http://www.infosite.com/~jkeyzer/piclist/

--
http://www.piclist.com hint: To leave the PICList

mailto:piclist-unsub...@mitvma.NO.SPAM.mit.edu


Alexandre Domingos F. Souza

unread,
Sep 8, 2001, 1:50:36 PM9/8/01
to PIC...@mitvma.fight.spam.mit.edu
>This circuit will convert TRUE RS232 to proper PIC levels.

Of course. But if you see, the parts count is bigger than a MAX-232, so it is easier to use a MAX-232 ;o)))


---8<---Corte aqui---8<----

Alexandre Souza
ta...@terra.NotNeeded.com.br
http://planeta.terra.com.br/lazer/pinball/

---8<---Corte aqui---8<----

--
http://www.piclist.com hint: To leave the PICList

mailto:piclist-unsub...@mitvma.We.Hate.SP.AM.mit.edu


James Newton. Admin 3

unread,
Sep 8, 2001, 3:06:52 PM9/8/01
to PIC...@mitvma.spammers.are.scum.mit.edu
Dan, if you are going to eavesdrop, pay attention. <GRIN>

The piclist.com site DOES have the only COMPLETE piclist archive... all the
way back to December of 1993 with a fast browse, full text search, etc...

There are several other archives which have different good and bad points.
All are discussed at piclist.com

Frankly I have no idea how Andy could have "searched" piclist.com and NOT
come up with literally thousands of hits from the archive and at least one
full FAQ page devoted to this subject.

I found a lot with "RS232 near TTL" as a search phrase and even more with
just "RS232 TTL convert"

James Newton, PICList Admin #3

mailto:james...@piclist.Cut.com
1-619-652-0593 phone
http://www.piclist.com


----- Original Message -----
From: Dan Michaels <ori...@USWEST.NO.SPAM.NET>
To: <PIC...@MITVMA.NoSpam.MIT.EDU>
Sent: Saturday, September 08, 2001 11:14
Subject: Re: [PIC]:Simple RS232 hardware

Andy Shaw wrote:
>Resent missing header!
>Hi Folks,
>I'm sure this must have been covered before but a search of piclist.com
>failed to find anything...
........


Andy, this topic "has" been beat to death "many" times on piclist
in the past.

However, what you may not understand is that < piclist.com > and the
< PICLIST Mailing List Archives >, ie piclist discussion group, are
not really the same thing. AFAIK, piclist.com does not contain the
archives.

If you want to search the discussion group archives, goto to the
bottom of the page at the folowing site and use the search engine.
You'll find 100s of RS232 references.

http://www.infosite.com/~jkeyzer/piclist/

--


http://www.piclist.com hint: To leave the PICList

mailto:piclist-unsub...@mitvma.Cut.mit.edu

--
http://www.piclist.com hint: To leave the PICList

mailto:piclist-unsub...@mitvma.Fight.Spam.mit.edu


Graeme Zimmer

unread,
Sep 8, 2001, 6:45:45 PM9/8/01
to PIC...@mitvma.counterspam.mit.edu
> For one-off, home projects, I'm in the "resistor-to-PIC" crowd. I've used
it a dozen or so times with no problems... but of course people are right,
it's not true EIA-232, it's not guaranteed to work, etc etc.

The sad thing is that it is so easy to arrange a simple interface which IS
true EIA-232.

You need a dual supply (a couple more cells to give the negative line ?) (a
zener to give a voltage drop ?)

and then arrange the switching transistor so that it can go below ground, eg
can switch to both positive and negative voltages.

The important thing is to arrange that the negative going pulse actually
swings a few volts negative.


..................... Zim

--
http://www.piclist.com hint: To leave the PICList

mailto:piclist-unsub...@mitvma.RemoveThis.mit.edu


Kathy Quinlan

unread,
Sep 8, 2001, 9:01:38 PM9/8/01
to PIC...@mitvma.nothis.mit.edu
Ignore Andy as you will be scratching your head until you realise that RS
232 is inverted.

And the MAX * chips are cheap, maxim sends free samples out and all it costs
you is some typing on a web page and a few days later they are at your door
(IIRC you can get 8 chips at a time)


Yes you can use discrete transistors to invert the signal, yes most "New"
equipment accepts 5v RS 232, but older equipment will not, an old Wyse
terminals etc (some ppl use them with monitor programs, some external modems
(one model (number I do not recall) of netcomes will not work on new PC's
without a level converter.

Andy the reply I sent was correct for the question asked, and follows good
engineering practices of following standards.

Regards,

Kat.

____________________________________________________________________________
The information contained in this email and any files transmitted with it
are confidential and intended solely for the use of the individual or entity
to whom they are addressed. If you have received this email in error please
promptly notify the sender by reply email and then delete the email and
destroy any printed copy. If you have received this email in error, you must
not disclose or use this information in any way.
____________________________________________________________________________


----- Original Message -----
From: "Andy N1YEW" <n1...@SOFTHOME.Fight.Spam.NET>
To: <PIC...@MITVMA.Take.This.Out.MIT.EDU>
Sent: Saturday, September 08, 2001 7:29 PM
Subject: Re: [PIC]:Simple RS232 hardware


> Andy Shaw wrote:
> > Resent missing header!
> > Hi Folks,
> > I'm sure this must have been covered before but a search of piclist.com

> > failed to find anything... Anyway what would you recommend as the
> > simplest/minimal hardware RS232 interface for use between a PIC and a

> > modern PC? This is *not* for a production product I would just like to


be
> > able to include a very cheap interface on a home project for occasional
> > diagnostic/config use. Can I get away without using a MAX* converter?
What
> > are the pros/cons? What would be your suggested circuit?
> >
> > Thanks
> >
> > Andy
>

> Ignore Kat, and try this:
>
> PC: PIC:
> TX ---|>|--/\/\/\------ PIC RX
> |
> GND-/\/\/\-
>
> RX---------------- PIC TX
>
> Works for me every time.
>
> andy
>

> --
> http://www.piclist.com hint: To leave the PICList

> mailto:piclist-unsub...@mitvma.CounterSpam.mit.edu
>
>

--
http://www.piclist.com hint: To leave the PICList

mailto:piclist-unsub...@mitvma.Fight.Spam.mit.edu


Steve Baldwin

unread,
Sep 9, 2001, 6:00:16 AM9/9/01
to PIC...@mitvma.removethis.mit.edu
> Don't believe all the answers :-).
>
> People will tell you that the receiver can be a resistor from modem tx
> to PIC pin as RX. It indeed "can" be but you violate PIC design specs
> and in an indeterminate number of cases it will give you endless
> problems.

> Diode D1 can probably be omitted in practice.
> Transistor can be almost any small signal npn - a BC337 is a good
> choice.

Why can't you violate the PIC specs but you can leave out D1 and
violate the transistor specs ?

Steve.

======================================================
Steve Baldwin Electronic Product Design
TLA Microsystems Ltd Microcontroller Specialists
PO Box 15-680, New Lynn http://www.tla.co.nz
Auckland, New Zealand ph +64 9 820-2221
email: ste...@tla.Bogus.co.nz fax +64 9 820-1929
======================================================

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


Mike Harrison

unread,
Sep 9, 2001, 8:03:26 AM9/9/01
to PIC...@mitvma.antispam.mit.edu
On Sat, 8 Sep 2001 10:29:15 -0500, you wrote:

>... send to the piclist this time? ...
>
>
> "used a 74LS04"
>
>Substitute the 'LS04' with a 74HC14 and
>you've got my solution. The HC14 will (Schmitt
>Trigger) assure 'clean', sharp tiggering on
>slow rise/fall time serial input signals ...
>
>Also, I'm not too sure a *true* "LS04" gate
>can actually pulled low through a 330K Ohm
>resistor - a true TTL LS (bipolar, Low-power
>Schottky) gate is spec'd at more like .4 mA
>low-level input current. This would require
>a voltage of -132 VDC to be applied to the
>330K Ohm resistor to supply .4 mA of current
>for a logic low input to the gate!
>
>With a CMOS gate - this is not an issue. Just
>make sure the device family includes built-in
>"clamping" diodes (normally associated/used
>with/for static-protection) ...

One thing to watch out for - the current consumption of HC series
devices can get a bit high unless you add external clamp diodes. This
is only likely to be an issue for battery powered systems.

Mike Harrison

unread,
Sep 9, 2001, 8:03:26 AM9/9/01
to PIC...@mitvma.removethis.mit.edu
On Sat, 8 Sep 2001 23:45:14 +1200, you wrote:

>> I'm sure this must have been covered before but a search of piclist.com
>> failed to find anything... Anyway what would you recommend as the
>> simplest/minimal hardware RS232 interface for use between a PIC and a
>modern
>> PC? This is *not* for a production product I would just like to be able to
>> include a very cheap interface on a home project for occasional
>> diagnostic/config use. Can I get away without using a MAX* converter? What
>> are the pros/cons? What would be your suggested circuit?

>Andy,
>
>A very common question.


>Don't believe all the answers :-).
>
>People will tell you that the receiver can be a resistor from modem tx to
>PIC pin as RX.
>It indeed "can" be but you violate PIC design specs and in an indeterminate
>number of cases it will give you endless problems.

No you don't - as long as the series resistor is sensible, you do not
exceed the permitted current through the input protection diodes.

Mike Harrison

unread,
Sep 9, 2001, 8:03:26 AM9/9/01
to PIC...@mitvma.nothis.mit.edu
On Sat, 8 Sep 2001 09:39:36 -500, you wrote:

>> I'm sure this must have been covered before but a search of piclist.com
>> failed to find anything... Anyway what would you recommend as the
>> simplest/minimal hardware RS232 interface for use between a PIC and a modern
>> PC? This is *not* for a production product I would just like to be able to
>> include a very cheap interface on a home project for occasional
>> diagnostic/config use. Can I get away without using a MAX* converter? What
>> are the pros/cons? What would be your suggested circuit?
>

>For one-off, home projects, I'm in the "resistor-to-PIC" crowd. I've used it a dozen or so times with no problems... but of course people are right, it's not true EIA-232, it's not guaranteed to work, etc etc. Truth is it will work in the vast majority of cases, but I'd probably not use it in a production device. I have seen it done in commercial products though, often. Mice come to mind.
If you KNOW that you will be talking to a PC and not some other serial
device (which may also use nostandard levels), and the cable length
isn't too long (like it's a widget that plugs straight onto the PC
socket, or has a shor (<2M) captive lead, and the baudrate is
sensible, and you're not trying to pull too much power from the
control lines, you should have no hesitation about doing this in
production. It works, period.

>Pros: Dirt cheap. Extremely simple. Dirt cheap.
>Cons: You HAVE to do bit-banged comms, since there is no way to invert UART data.
> Also not precisely to PIC datasheet specs.

Not enturely true - the data shhets do specify the maximum input clamp
current - although the data I have in front of me lists it in the
'absolute max' parameters, it is entirely reasonable to infer than
operation a couple of orders of magnitude below this is fine.

Russell McMahon

unread,
Sep 9, 2001, 9:33:59 AM9/9/01
to PIC...@mitvma.fight.spam.mit.edu
> > Don't believe all the answers :-).
> >
> > People will tell you that the receiver can be a resistor from modem tx
> > to PIC pin as RX. It indeed "can" be but you violate PIC design specs
> > and in an indeterminate number of cases it will give you endless
> > problems.
>
> > Diode D1 can probably be omitted in practice.
> > Transistor can be almost any small signal npn - a BC337 is a good
> > choice.
>
> Why can't you violate the PIC specs but you can leave out D1 and
> violate the transistor specs ?

I should learn that if I want a quiet life I should avoid trying to provide
information on dubious short cuts that may save a cent or so :-).
I included that comment for practical completeness. At the cost of a diode
you probably will not want to exclude it .
However, the difference is result between PIC and transistor is substantial.

Note that, even if reverse e-b breakdown does occur, the transistor is NOT
in fact being run OUT of spec - it is just being run in a different part of
its operating range. It is not, in this case, a useful area to run it in but
it is also not harmful per se in a digital circuit.

If you exceed PIC input voltage specs and leak current into the chip via the
protection diodes it can (and sometimes will) cause completely undefined
processor malfunction. In something as complex as a microprocessor the
problem is not that you have exceeded the specs in a defined way on a single
semiconductor device but that you have caused an unknown condition in a
device containing thousands of semiconductor devices in it.

In this circuit, leaving out the diode will cause a reverse voltage to be
placed across the transistor base-emitter junction. Depending on the
transistor this reverse voltage may or may not exceed Vebo max. For small
signal transistors Vebo is typically in the 2 to 10 volt range so in many
cases reverse breakdown will indeed be experienced on RS232 negative input
excursions. If this occurs the transistor will go into "reverse base emitter
breakdown" and the junction will act as a zener diode. Without the input
resistor this could result in transistor destruction. With the input
resistor it will largely just draw some reverse base current. An even
greater current will be drawn if the diode is included. There will be some
minimal transistor heating (typically around a few milliwatt) and some zener
noise generated. BUT the transistor will not turn on. The circuit will still
work as intended. The transistor is NOT in fact being run OUT of spec - it
is just being run in a different part of its specification. It is not, in
this case, a useful area to run it in but it is also not harmful per se in a
digital circuit. Conceivably the small amount of noise generated MAY affect
adjacent sensitive analog circuits but odds are that the RS232 switching
transients are of a far greater magnitude.

Just add the diode! :-)

(Did I pass? :-) )


Russell McMahon

Olin Lathrop

unread,
Sep 9, 2001, 11:03:50 AM9/9/01
to PIC...@mitvma.notneeded.mit.edu
>>
If you KNOW that you will be talking to a PC and not some other serial
device (which may also use nostandard levels), and the cable length
isn't too long (like it's a widget that plugs straight onto the PC
socket, or has a shor (<2M) captive lead, and the baudrate is
sensible, and you're not trying to pull too much power from the
control lines, you should have no hesitation about doing this in
production. It works, period.
<<

While it may work much of the time, claiming it will "work, period" is
rediculous, irresponsible, and just plain wrong. The valid range of
detection thresholds is from -3V to +3V, with receivers being encouraged to
use some hystersis. Many receivers deliberately set the detection threshold
to be compatible with TTL levels. This is perfectly valid as these levels
fall between -3V and +3V even with some hysteresis. However, receivers that
care more about noise immunity will use negative thresholds too. I've
personally designed some units that used -2.5V and +2.5V as the detection
thresholds and +-15V as the transmit levels. These units adhere to the spec
and will work with all other units that also adhere to the spec. However,
your units would not be able to transmit to them.


********************************************************************
Olin Lathrop, embedded systems consultant in Littleton Massachusetts
(978) 742-9014, ol...@embedinc.Take.This.Out.com, http://www.embedinc.com

Steve Baldwin

unread,
Sep 9, 2001, 3:19:11 PM9/9/01
to PIC...@mitvma.nospam.mit.edu
<snip>

> Just add the diode! :-)
> (Did I pass? :-) )

Yeah, yeah. Whatever. :-)

Steve.


======================================================
Steve Baldwin Electronic Product Design
TLA Microsystems Ltd Microcontroller Specialists
PO Box 15-680, New Lynn http://www.tla.co.nz
Auckland, New Zealand ph +64 9 820-2221

email: ste...@tla.AntiSpam.co.nz fax +64 9 820-1929
======================================================

--

Russell McMahon

unread,
Sep 9, 2001, 4:06:46 PM9/9/01
to PIC...@mitvma.take.this.out.mit.edu
>> I'm sure this must have been covered before but a search of piclist.com
>> failed to find anything... Anyway what would you recommend as the
>> simplest/minimal hardware RS232 interface for use between a PIC and a
>modern
>> PC? This is *not* for a production product I would just like to be able
to
>> include a very cheap interface on a home project for occasional
>> diagnostic/config use. Can I get away without using a MAX* converter?
What
>> are the pros/cons? What would be your suggested circuit?
>Andy,
>
>A very common question.
>Don't believe all the answers :-).
>
>People will tell you that the receiver can be a resistor from modem tx to
>PIC pin as RX.
>It indeed "can" be but you violate PIC design specs and in an indeterminate
>number of cases it will give you endless problems.

// No you don't - as long as the series resistor is sensible, you do not
// exceed the permitted current through the input protection diodes.

This topic (whether you can use the on chip protection diodes for "SAFE"
RS232 reception is a repeating one which has been discussed on list many
times. There are always two groups who take opposing stances. I will
summarise the viewpoint from the point of view of the group who say it is
not a valid thing to do and will suggest partial reasons why.

- Using a series resistor to a PIC pin from an RS232 input exposes the PIC
to voltages in excess of Vcc + 0.6 volts or Ground - 0.6 volts.

- Under these conditions the PIC's internal protection diodes will conduct
to limit the voltage actually appearing at the PIC pins.

- The resultant current entering the PIC die via the protection diodes
creates biases and voltages which are uncontrolled in the normal sense.

- The allowable voltages guaranteed by Microchip as able to be applied to a
PIC's pins during NORMAL operation vary with device but are usually 0 < V <
Vdd. The GUARANTEED OPERATING voltages are well within the levels at which
the protection diodes conduct

- The ABSOLUTE MAXIMUM voltages guaranteed by Microchip as able to be
applied to a PIC's pins without destroying the PIC or causing permanent
damage vary with device but are usually 0 - X < V < Vdd + X where X was
originally 0.6 volts and in later data sheets may be 0.3 volts.

- The term "ABSOLUTE MAXIMUM" is an industry standard one and carries the
same meaning here as elsewhere. It loosely means (at the risk of sounding
smart :-) ) "If you apply voltage and current above these levels you are
liable to have a defective chip on your hands. If you apply voltages and
currents at these levels and confidently expect the chip to function
normally while doing so then you are dreaming. If it just happens to work
properly under these conditions then we are very pleased for you, please
don't come any closer, do try to have a nice day. YMMV"

- The ABSOLUTE MAXIMUM conditions guaranteed by Microchip were originally
JUST AT the point where the protection diodes start to conduct and are now
often BELOW the point where the protection diodes conduct.


SO

- Applying RS232 voltages through a straight resistor exceed the NORMAL
guaranteed conditions severely.

- Applying RS232 voltages through a straight resistor place the device ABOVE
the absolute maximum guaranteed voltage for chip survival.

- If the chip DIES during this operation do not be surprised (It is in
practice very unlikely that it will die if you limit the current sensibly
during this operation but MChip do not say it won't).

- If the PIC malfunctions during this operation do not be surprised in any
way whatsoever. The fact that the currents injected may very very very small
compared to "normal" digital signal levels is not relevant. You are
injecting current which goes you know not where, biasing on reverse paths
that do you (and Microchip) know not what, utilising perhaps parasitic
transistors connecting ??? to ??? with outcomes of ???. When multiple
transistors are involved currents in the order of microamps can cause
currents of milliamps to flow. Anything can and sometimes will happen. (Even
a 1 megohm input resistor allows microamps of current to flow.)

Sometimes it works.
Sometimes it doesn't.
I have seen it "not work".
When it doesn't the result may well be inconsistent.
When it goes wrong the result may not be noticed (or only noticed by the
customer when things perhaps only occasionally go wrong).
Your mileage will vary.
Do it if you want to. Don't blame Microchip when it doesn't work.

Note: At least one Microchip application note breaks this "rule".
This does not in any way change any of the above arguments.


regards

Russell McMahon

David VanHorn

unread,
Sep 9, 2001, 4:15:06 PM9/9/01
to PIC...@mitvma.delete.mit.edu
>
>Note: At least one Microchip application note breaks this "rule".
>This does not in any way change any of the above arguments.

Many projects have died, from following application notes, and ignoring the
specs.

IMHO, there shouldn't be anything in app notes that violates the specs, as
application notes are commonly taken as "how to do (X) with our
chips". One then assumes that everything shown is in-spec.


--
Dave's Engineering Page: http://www.dvanhorn.org

I would have a link to http://www.findu.com/cgi-bin/find.cgi?KC6ETE-9 here
in my signature line, but due to the inability of sysadmins at TELOCITY to
differentiate a signature line from the text of an email, I am forbidden to
have it.

Dale Botkin

unread,
Sep 9, 2001, 4:21:25 PM9/9/01
to PIC...@mitvma.removethis.mit.edu

Yeah, but there's also an absolute maximum voltage for I/O pins listed -
for example, the 'F877 datasheet says -0.3 V to (VDD + 0.3 V). I think
it's to limit pin current, but the fact is it's listed in teh datasheet...
which is why I said not "precisely" to spec. I agree it won't break
anything though; for all the hand-waving and prophecies of doom from those
who maintain it's just a bad idea, I have yet to hear anyone claim it's
ever actually damaged a PIC. Yes, there are some devices that won't work
properly with a 5V single-ended swing on an EIA232 interface, which is why
I'd never say it's a perfect solution.

Dale
--
Hallo, this is Linus Torvalds and I pronounce Linux as Leennuks.
Hallo, this is Bill Gates and I pronounce 'crap' as 'Windows'.

Andy Shaw

unread,
Sep 9, 2001, 4:46:15 PM9/9/01
to PIC...@mitvma.counterspam.mit.edu
> Frankly I have no idea how Andy could have "searched" piclist.com and NOT
> come up with literally thousands of hits from the archive and at least one
> full FAQ page devoted to this subject.
>
> I found a lot with "RS232 near TTL" as a search phrase and even more with
> just "RS232 TTL convert"
>

OK well I'll tell you what I did. I'm not saying what I did was correct and
that there is not a better way to do a search but maybe we could all learn
from my mistake!
1. Went to www.piclist.com and typed RS232 into the search box on the front
page. Waited for a while and then got either a page not found or a
connection timed out message (not sure if this was at my end or not but lots
of other sites were Ok at the same time).
2. Thought maybe it was the search engine so I'll try the "advanced" search
just in case that is different. So I typed RS232 into that and got back 2
pages of hits. Looking at them most of them seemed to be about software
issues. Note - looking back at this my mistake may have been not checking
the "full text search option at this stage" sigh!
3. So I typed in RS232 hardware and did the search again. This time I got
back just a single hit which was a reference to an article about an SX
processor.
4. I tried a couple of other search terms but again got timeouts/not found
errors.
5. Decided to do things the hard way so basically browsed around the site
looking for something that covered the topic. I was unable to find anything
that seemed to cover things.
6. Decided to post a quick question half expecting to get told "We've done
this to death, go look at XXXXX" which would have been fine. Instead as
always I got a lot of great answers (and some interesting discussions), from
the other people that looked at the list over the weekend - thanks folks.

So that's my story. I probably should have looked for TTL along with RS232
but I guess it just did not occur to me. I was rather surprised at how few
hits I got on just RS232 and the problems I had with the search engine kind
of made me give up on it. By the way I'm still having problems (at 22:39 (UK
time) 9th Sep), I've been trying to repeat what I did (and try RS232 near
TTL) I can get to www.piclist.com and the normal pages but any attempt to
search just gives me a timeout.

Note no criticism of piclist.com here *I know* how much effort it takes to
look after a site like this and I've often found really useful information
there. But James did say he couldn't understand so I thought it may be of
use to explain....

Andy

Russell McMahon

unread,
Sep 9, 2001, 6:56:59 PM9/9/01
to PIC...@mitvma.counterspam.mit.edu
> Yeah, but there's also an absolute maximum voltage for I/O pins listed -
> for example, the 'F877 datasheet says -0.3 V to (VDD + 0.3 V). I think
> it's to limit pin current, but the fact is it's listed in teh datasheet...
> which is why I said not "precisely" to spec. I agree it won't break
> anything though; for all the hand-waving and prophecies of doom from those
> who maintain it's just a bad idea, I have yet to hear anyone claim it's
> ever actually damaged a PIC.

I don't think anyone was talking about damaging the PIC - just saying the
product may not work.

> Yes, there are some devices that won't work
> properly with a 5V single-ended swing on an EIA232 interface, which is why
> I'd never say it's a perfect solution.

No - it's worse than that - all the forgoing descriptions were saying that
the PIC receive circuit MAY cause the PIC to malfunction SOMETIMES with
perfectly properly specified RS232 equipment. If a design can live with MAY
and SOMETIMES (and arguably some designs can) then it's a perfect solution
:-) .

RM

0 new messages