• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Need advice on making 12V+ tolerant in/out to a micro

Status
Not open for further replies.

iso9001

New Member
Hi,

I've got a project where I'll need to have some inputs and outputs in a automotive application (5V and 12V mixed).

My micro is 5V tolerant with 1 or 2 open collectors so going right to the pin is a bad idea. Can anyone recommend some schematics, design tips, circuits that might be closer to "approved methods" then what I may come up with on my own ? :)

I've done this work before but its always kinda flaky and I'm sure there is a better method for outputting 12V then the single NPN transistor I usually use.

I'm going for pretty bomb proof circuits, although the loads (in and out) will be automotive I'm not planning for any extreme disasters.


Any advice ?
Thanks!
iso

ps> Other then voltage following op amps I've never been really down on 5V protection components so if anyone has some good tips there, thats also quiet welcome,
 

Pommie

Well-Known Member
Most Helpful Member
Which Micro? Normally, for inputs a resistive voltage divider or a current limiting resistor will suffice. For outputs, it depends on the load.

Mike.
 

Sceadwian

Banned
Many micro controllers have clamping diodes on their I/O ports, as long as the current limit isn't passed you can feed it pretty much any voltage you want. There is an AVR appnote for a zero cross circuit that uses only a single resistor to go directly to 120volt AC line. A two transistor totem pole driver allows rail to rail high speed switching.
 

iso9001

New Member
Lets say for now its PIC, but plans to migrate the micro to moto or other.

I know of the clamping diodes, but wasn't sure if it was 'recommended practice' to trust them.

Sceadwian: I haven't seen that appnote but I have heard similar stories. I'll take a look for it.


My 5V ADC signals are all going through a voltage follower opamp but right now my 5V digital wires are just direct to the micro from the connector, I'm sure thats not exactly correct.

As far as my outputs go I have a decent relay driver, but lets say no more then 25ma for 12V out. I'm guessing a simple transistor or fet but I would like it to be at least short protected, thats the type of thing I'm curious about.

I've been looking around for app notes and schematics but haven't come up with much,
 

Nigel Goodwin

Super Moderator
Most Helpful Member
iso9001 said:
I know of the clamping diodes, but wasn't sure if it was 'recommended practice' to trust them.
If you can't trust a simple diode, how can you trust the thousands of transistors that form the processor, never mind your own code! :D

As far as I'm aware all PIC's have them on MOST I/O pins, some pins don't for specific reasons - explained in the datasheets. There are VERY, VERY, old PIC application notes feeding mains to PIC pins via simple resistors.
 

iso9001

New Member
Ok, so.... if pin is listed to sink 25mA and that pin does have a clamping diode can I allow 25mA @ 12V (via a 480ohm resistor) or is the rated 25mA really mean the clamping diode can only handle that at 5V / .125W and not the .3W the 12V would be allowing in ? That might not make sense, not sure. I suspect the rated mA is really meaning rated W as long as the pin has a clamping diode.

So then for output... if its going to another micro, a switch, or a lamp a mosfet seems like a better idea then an NPN ?
 

Papabravo

Well-Known Member
For inputs above the normal Vcc range use a comparator, such as LM393(daul) or LM339(quad) or equivalent. Set the threshold somewhere between Vcc/3 and 2*(Vcc/3). You can also add hysteresis and make it a schmitt trigger input. These have open collector outputs so they can be used in 5V and 3.3V systems.

You could also use a 26LS32 line receiver. The inputs are tolerant of higher voltages and you can set the threshold. These have 3-state outputs so they can be combined for multiple inputs on a single input pin.

For outputs consider driving the emitter resistor of a common base stage with the base connected to Vcc. Pull the collector up to V+. The output can be used to turn on either an NPN or a PNP switch. This is especially usefull with the aysmmetrical quasi-bidirectional port on an 8051.
 

Pommie

Well-Known Member
Most Helpful Member
The output pin of a pic can typically sink 25mA and source 20mA. As inputs they take a tiny current (~100nA). While it is true that the clamping diodes can take 20mA, the package as a whole is limited to less than 1W. Just use 10k resistors on your inputs. For your outputs consider something like the 2n7000 mosfet.

Mike.
 

eblc1388

Active Member
iso9001 said:
I'm going for pretty bomb proof circuits, although the loads (in and out) will be automotive I'm not planning for any extreme disasters.
For your peace of mind, and a few cents of part worth, do:

MCU pin <---> Resistor <---> clamp diodes to both +5V and ground <---> resistor <---> input signal
 

Nigel Goodwin

Super Moderator
Most Helpful Member
eblc1388 said:
For your peace of mind, and a few cents of part worth, do:

MCU pin <---> Resistor <---> clamp diodes to both +5V and ground <---> resistor <---> input signal
If you're going to duplicate the insides of the PIC why not go the whole way and built it entirely from scratch using transistors? :p

PIC's are designed to use the minimum of external components, it's designed and specified to use a single resistor feeding a higher voltage into a diode protected input pin. They have been proved exceedingly reliable for well over a decade, why not trust that they know what they are doing?.
 

eblc1388

Active Member
The reason is simple.

I don't trust the built-in clamping diode would offer sufficient protection and so for a few cents more, I would add my own as if they were not there in the first place.
 

eblc1388

Active Member
I consider the PIC inbuilt diodes are there for input protection purposes only and are not supposed to conduct in normal use. I will always keep them this way.

Mine added external resistors and diodes are there for signal conditioning and should be designed to do just that with properly rated components.

It is different methods of attacking the same problem.
 

Nigel Goodwin

Super Moderator
Most Helpful Member
eblc1388 said:
I consider the PIC inbuilt diodes are there for input protection purposes only and are not supposed to conduct in normal use. I will always keep them this way.
Perhaps you should try reading the datasheets and application notes?, I presume you (like myself) come from the long ago micro-processor days when you had to add external diodes? - which was MicroChip fitted internal ones.
 

iso9001

New Member
As I was aware this topic would be a debatable one, I'll just go ahead and say I think you are both right. For something mission critical it probably doesn't hurt to double up, for a blinking teddy bear anything goes :) As I fear I have only a basic understanding of what I'm doing I'll probably trust the internal clamping diodes and leave pcb space for papabravo's opamps in case I feel like getting redundant in here.


Two questions about those though.... One, since the inputs are open collector's they are going to absorb quiet a bit of power from each wire ? I was under the impression this was true for all open collectors. Two, if I feed the supply of the opamp with 5V, I can still tie my 12V signal to the + pin without damage (assuming correct) but for the - pin wouldn't I want to tie that to ground ? Rather (as I am reading it) it seems I am being recommended to tie it to ~1.6V, why is this ??

Then for the outputs I'm not 100% understanding the advantages between mosfet and npn in this instance but I'm leaning towards mosfet.

Cool, I feel much better about this project now :)
 

Papabravo

Well-Known Member
Be careful - a comparator is NOT an opamp. They are entirely different animals. The LM393 and LM339 which I recommended need a V+ supply that is at or above the signal input. At least one of the inputs must be within the devices "common-mode" range. Most choices of reference voltage will satisfy this requirement.

"Open collectors" are not inputs. They are outputs, and they only sink current when they are low. When they are high, the external pullup resistor pulls the output up to Vcc, which could be 5V or 12V or whatever.
 

iso9001

New Member
Ok, I see now. My mistake on using the word opamp. You were saying use the 12V to power the package and on its output to my module drop the voltage, well, that makes sense. At least that way I'm not effecting the input signal at all with resistors. I'll definitely make a note of that.

So, for now it seems my input scheme is taken care of. Anyone want to give me some feedback on this (pic) for output ? I want to try and use a single pin for 12V digital input and 5V or 12V output. I know this method would be very trusting of the pic's internal hardware (debatable) but I figured I'd ask here,

http://tinypic.com/view.php?pic=un6tg&s=2

The problem I can see right away is that any input signal will also turn the mosfet on. So... That rules out this being used as a 5V input. I would think that if I have a common 12V source as the signal then it should be O.K. no ?
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top