Wednesday, 10 August 2016

transistors - Best way to get +5V or +12V or 0V from arduino pin


I am working on an eeprom programmer as an Arduino shield. There are two pins on my EEPROM that require a 12V signal as part of the programming process. One of them is an address pin that I am also driving by a signal through a 595 shift register, and the other is the output enable pin which is connected to a regular Arduino pin for 5V and 0V operation.



I would like to have a pin on the arduino for each of the 12V pins that will set it to the higher voltage without damaging any other components.


I was thinking I could use a simple transistor setup like Figure 1 on this page, but I'm really not sure how well that would work when connected to both sources at once. I would need diodes to protect my 5V components from getting damaged by the 12V signal, but I suspect that circuit may work out. I will simplify things by ensuring I that Vin is a solid 12V supply.


Here's my initial design:


enter image description here


My main problem is that I don't understand the circuit elements in play here very well. Will this explode? I'm still a bit confused by simple transistor circuits, and not sure what specific parts to use. I feel like what I am trying to do is not that hard, but my circuit skills are not good enough to know the best way to accomplish this. Thanks.



Answer



Here is a circuit that should work:



Your basic idea of using a high side PNP switch was fine. The problem with it is that this exposes the high voltage to the micro pin.


In this circuit, Q2 is the high side switch that turns the 12V output on or off. Q1 switches the high side switch, thereby isolating the micro from the 12V on the base of Q2.



When the base of Q1 is held at 5V, the emitter will be 4.3V, so there will be 1mA thru R1. Most of this also flows thru the collector of Q1, which thereby acts like a switchable 1mA current sink. Most of this can only come from the base of Q2. Figuring the two transistors each have a gain of at least 50, then the output is good for at least 45mA for Q2 to stay in saturation. The purpose of R3 is only to make sure Q2 is really off when Q1 is off.


No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...