Russell: What pin were you using for the input, and on what chip? --Tom Rogers VP-R&D Time Tech Inc. ------------------------------------------------- Russell McMahon wrote: > Moral of this story: > Don't rely on PIC protection diodes and a series > resistor for input signals which swing substantially > outside the PIC's power rails. > > I implemented a "cheap and nasty" PIC RS232 receive interface > as proposed by microEngineering labs in their BASIC compiler > manual, using a single 22K resistor from a PC serial TX data > pin to the PIC receive data pin (and a similar arrangement with > a smaller resistor for PIC TX data). As I had not used their > BASIC compiler before I initially presumed that problems > getting some simple code going was due to my misunderstanding > of the code syntax in the manual (the language is simple but > the manual is utterly diabolical - at least the compiler is > better than its manual!) > > But no! - the problem lay in the interface. > Adding 2 Schottky diodes to the PIC pin to clamp voltage > excursions to (almost) ground and 5v supply cured the problem > and RS232 input worked as desired. While a number of people in > this list have proposed using the PIC's protection diodes to > clamp voltage excursions outside the power rails it is clear > that, in this case, this practice caused the chip to > malfunction. This is of course rather poor design practice but > is a known 'trick' in many other circumstances - especially > during fault conditions. I am not certain whether the positive > or negative excursion caused the problem - I'll go back and > check later - at the moment the Schottky solution works OK. Vin > high current is about (12-5)/22k = 0.3ma and Vin low is about > 12/22K = 0.54ma. Incidentally - the PIC data sheet have Gnd and > Vpp as maximum Vin limits with no reference, on a quick scan, > of acceptable maximum currents when the protection diodes > conduct. > > (The transmit circuit worked with no problems - as would be > expected as the PIC is driving a high impedance. While this may > tend to pull to one or other rail the affect will be swamped by > the PIC's low output impedance.) > > In this case, to implement R232 a simple "proper" design could > be implemented, probably, using resistors alone. 2 resistors > and 1 transistor is the standard el-cheapo solution in such > cases (1 R from P.C. to transistor base, 1 R in transistor > collector, (back diode base to ground if you're squeamish). I > will be using an opto-coupler ultimately to protect the PC and > the target object from each other.