Common Techniques for Higher Voltage Inputs

Discussion in 'Embedded Systems and Microcontrollers' started by jwilk13, Sep 9, 2011.

  1. jwilk13

    Thread Starter Member

    Jun 15, 2011
    228
    12
    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?
     
  2. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    Have a look at chapter 8 of this:
    ww1.microchip.com/downloads/en/DeviceDoc/01146B.pdf
     
    jwilk13 likes this.
  3. strantor

    AAC Fanatic!

    Oct 3, 2010
    4,302
    1,988
    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.
     
  4. jwilk13

    Thread Starter Member

    Jun 15, 2011
    228
    12
    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.
     
  5. jwilk13

    Thread Starter Member

    Jun 15, 2011
    228
    12
    @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.
     
  6. Potato Pudding

    Well-Known Member

    Jun 11, 2010
    684
    92
    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.
     
  7. vrainom

    Member

    Sep 8, 2011
    109
    19
    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.
     
  8. Roto

    New Member

    Jul 13, 2011
    23
    0
    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.
     
  9. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,388
    1,605
    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.
     
  10. jwilk13

    Thread Starter Member

    Jun 15, 2011
    228
    12
    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?

    [​IMG]
     
  11. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,388
    1,605
    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.
     
Loading...