Common Techniques for Higher Voltage Inputs

Thread Starter

jwilk13

Joined Jun 15, 2011
228
Hello all,

I'm working on a project (one of many :p) where I have an input signal (digital, read as either ON or OFF) for a microcontroller that's above the rated 3.3V for the micro. I just figured I'd poll you guys on your preferred methods for reducing the voltage so that the microcontroller won't be destroyed.

What I'm thinking about doing is using an optocoupler as a switch. Any other recommendations?
 

strantor

Joined Oct 3, 2010
5,291
optocoupler, or voltage divider. I had this issue before and went with the optocoupler because the voltage divider scared me for some reason, don't remember much about the application or why it scared me it but should work.
 

Thread Starter

jwilk13

Joined Jun 15, 2011
228
I wish there was a "Thanks" button with two thumbs! That document is awesome. I can't believe I never stumbled on it before! It answers so many of the questions I've been having lately. It really clears up a lot of the questions I was having about interfacing my 3.3V PIC with 5V devices as well. Thanks a ton.
 

Thread Starter

jwilk13

Joined Jun 15, 2011
228
@strantor

It scares me for some reason too, not sure why. Maybe it just seems too simple :p. I'm using other voltage divider networks in my design as analog inputs (a trimmer and a static resistance make up the divider, allowing the input to vary from 0V - 3.3V), but for some reason it frightens me to switch on 12 VDC capable of completely frying all of my circuitry without some isolation.
 

Potato Pudding

Joined Jun 11, 2010
688
If you are talking about a part that costs around a $1 then I would see a dropping resistor and a 3.3V zener limiter as plenty. Less risky than a divider which might read high or low.

An optocoupler is expensive and the MCU would need to be at least $3 or the project would need to require critical reliability.
 

vrainom

Joined Sep 8, 2011
126
haha well, to sense the ac mains waveform on an attiny25 i use only a 150kohm resistor and the internal diodes of the uc do the clipping. So far after years of doing it I haven't had a problem.
 

Roto

Joined Jul 13, 2011
23
Yes I've used a 1 meg. resistor to bring a 110v 60hz. signal into an A/D pin. On a PIC don't know much about other MC's.
 

ErnieM

Joined Apr 24, 2011
8,046
I've done the resistor right to the AC line thing too, it works well. There's no harm in also using a diode to Vcc while you are at it.

I have a board that need to be very reliable (it's on the Airbus) where I need to take down 28V for the PIC to see a signal, I went "belt and suspenders" there, a resistive divider and a diode to Vcc. I can "see" the signal over a wide band of tolerance, plus I can clip out any spikes trying to slip in.
 

Thread Starter

jwilk13

Joined Jun 15, 2011
228
Interesting. So the resistive divider is actually a pretty reliable way of doing it? My opto works, but they're almost $3 a piece. The good thing is that it doesn't make a huge difference what my input voltage is. The system I'm working on is battery powered, so the 12V may or may not actually be 12V. If I were working off a regulated supply, I would probably go ahead with the divider.

Just to clarify Ernie, you have something like what is shown?

 

ErnieM

Joined Apr 24, 2011
8,046
jwilk13: Yes, exactly that. However, the more you look at that circuit you will see more subtle issues that arise.

First off is the diode: There may well be a similar diode inside the micro, and that diode may be good enough to use. Or you may be worried about using it, or times the input is there but the micro is unpowered. Or you just don't want to use the internal micro diode, where a Shockley diode due to it's lower on voltage may be the correct choice.

Next is the divider. In my case, I needed to detect a nominal 28V signal, but it could go as low as 20V, and the "off" level was 7V or such. Given that set of numbers I had to get a logic input, with it's own levels for valid "0" and "1" voltages satisfied. Doing this mathematically was not only leading to madness, and since the actual transition point of the input between "0" and "1" in not defined I had to punt.

I put a variable supply on my breadboard and tried the first combination that came to mind, and measure it's switching point at about 9V in. I can't guarantee it will stay there as I am depending on an unspecified transition voltage, so I tested it over several devices and all tripped at about the same place ± 1/4 volt.
 
Top