Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] How would I create an input to an MCU pin that could be anywhere from 5V to 12V?

Status
Not open for further replies.

jumanji

Newbie level 6
Joined
Mar 15, 2011
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,395
I want to design a "trigger" input into the pin of a microcontroller that is running at 5V. However, the input voltage of the trigger for a "high" could be 5V or 12V. Can I just tie the input to the base of a transistor and use it to turn on or off a 5V signal to the actual pin on the microcontroller?
 

If you feed your your trigger via a resistor of 1-10K and at the MCU end connect a small fast diode from the input pin(anode) to the 5V line (cathode) then the actual voltage at the MCU pin is limited to 5 +diode volt drop (.8?). repeat this with another diode to the MCU input pin (cathode)and the earth rail (anode) this will clamp any negative spikes to -.8V.
Frank
 
If the MCU pin has an internal pullup resistance it is already high otherwise you need to add one from the pin to 5V (say of value 4K7).
You are right, you can connect the collector to the the pin and the emitter to the ground. At the transistor (npn) base you add a resistor in series to limit the base current. Its value could be rather high (say 100K if you like). It is better to add also a resistor between the base and ground having a value about 1/4 of the previous one (say 22K).

Added (another solution, using a zener diode):
If there is an internal pullup resistor (otherwise you need to add a 10K external resistor) and you have a 4V7 zener, you can connect its cathode to the MCU pin and its anode to ground. Then you add a resistor having a relatively low value (as 1K) between your input source (5 to 12V) and the MCU pin.
 
Last edited:
The clamping diode can be used to limit the input voltage to the mcu.
The other solution is to use either a transistor or even an optocoupler if you want to isolate the mcu from the input voltage.
If you use a NPN and the output (going to the mcu) is from the collector then the outpout will be inverted , LOW with positive input and HIGH with no input.

Alex
 
Thanks to all of you for your inputs. I think I am going to go with using a FET for now with the gate tied to the incoming signal.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top