Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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?
 

chuckey

Advanced Member level 5
Joined
Dec 26, 2010
Messages
4,863
Helped
1,308
Reputation
2,622
Reaction score
1,283
Trophy points
1,393
Location
Southampton and holiday cottage in Wensleydale (UK
Activity points
31,695
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
 

KerimF

Advanced Member level 4
Joined
May 17, 2011
Messages
1,461
Helped
374
Reputation
756
Reaction score
370
Trophy points
1,363
Location
Syria
Activity points
12,314
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:

alexan_e

Administrator
Joined
Mar 16, 2008
Messages
11,895
Helped
2,021
Reputation
4,158
Reaction score
2,031
Trophy points
1,393
Location
Greece
Activity points
64,377
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
 

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
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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top