# Switching +12VDC by arduino

I am new to electronics, so please bear with me. I have next task to do:

I have programmed Arudino Mega 2560 to provide some arbitrary digital signals on predefined pins. This is to provide some kind of simulation that will bring signals to ICP DAS device DIs, so that it can count them. This simulation works, pins do change their state from HIGH to LOW and vice versa. ICP DAS DIs require +10+VDC, and will draw no more than 20mA current.

Logically, I need some NO switch that will allow +12VDC to ICP DAS Input when Arduino output is HIGH. I have been advised to buy a logic-level MOSFTET. By looking at the examples on internet, P-channel MOSFET is always used to switch the positive DC terminal for load, and N-channel MOSFET is always used to switch the ground (0VDC) for load.

For this reason I have bought p-channel tsm3401cx> I connected Arduino output to pin 1, +12VDC to pin 2, and pin3 to my voltmeter. When I measure voltage from arduino, I can see that it periodically jumps to 5VDC, and returns to 0V. When I connect transistor, as soon as I bring signal to source, no matter if signal on gate is LOW or HIGH, switch closes immediately. I have come to understanding that this is because of the difference between in polarity between the gate and the source (Vgs), which is always larger than the gate threshold.

So, how can I achieve what I need (switch +12VDC by +5VDC signal)? What kind of transistor do I need?

Edit:

Transistor output should be connected to ICP DAS digital input:

Contact: Wet Contact Sink/Source (NPN/PNP): Sink/Source On Voltage Level+10 VDC ~ +50 VDC Off Voltage Level+4 VDC Max.Input Impedance10 kΩ

• Two of them, of different polarities. Commented Apr 29, 2016 at 9:37
• What current do you need to take from +12 V output? I guess you need a small current, well below 1 mA. Then the right circuit is: use N channel logic level MOSFET; connect its Source to GND and its Gate to Arduino; connect its Drain to +12 via a resistor 1 kOhm or about; take the output from Drain to resistor node. Commented Apr 29, 2016 at 10:31
• I can provide more details when you give more information about what kind of output at 0-12 V do you need. Commented Apr 29, 2016 at 10:32
• There are also high side switches available with logic level control. Commented Apr 29, 2016 at 11:01
• @IgnacioVazquez-Abrams Can you provide some more information? Commented Apr 29, 2016 at 12:11

This should do it.

The TP0610K is capable of over 100mA load current (see the datasheet) and the 2N7002K will turn on properly in a 5V system.

simulate this circuit – Schematic created using CircuitLab

When the logic input to M1 goes high, M1 turns on, pulling the drain to (very close) to ground.

This pulls the gate of M2 low, turning it on in a low impedance state, powering up the switched power system.

• Can you please tell me what would be the voltage on the n-channel output / p-channel gate? This would help me better understand how the circuit works, while I wait for the components to arrive. I tried to use simulation that you posted, but it gives me some warnings about spacing Commented Apr 29, 2016 at 17:54

Thank you for clarification! Then this simplified circuit is reliable:

simulate this circuit – Schematic created using CircuitLab

M1 is not IRF530, it is any N channel Logic Level MOSFET with max drain to source voltage 20 V or more. R2 must be rated for dissipation of 72 mW, it is two 0402 SMD resistors or one 0603 or larger SMD resistor with rated power 80 mW, or almost any leaded resitor.

Same circuit with BJT:

simulate this circuit

Q1 must be a switching BJT with transition frequency 200-400 MHz, current transfer ratio h21 no smaller than 50 at collector current 10 mA and max collector - emitter voltage higher than 20 V. Plenty of BJTs are suitable.

• Thanks, will try it out. I currently do not have any logic level N-channel MOSFETs. While I wait for them to arrive (it will be like 5 days), is this possible to achieve the same effect with a bipolar transistor? Commented Apr 30, 2016 at 0:15
• Can you also please explain how does it work. You have brought 12VDC through resistor onto drain and ICP DAS input. Doesn't this mean that input will be high when the MOSFET is off, since the ICP DAS needs only positive voltage? Commented Apr 30, 2016 at 12:30
• Yes, it is right. The real input voltage on output is almost 0, when M1 is conducting, as the channel resistance of M1 is below 1 Ohm. On the contrary, when Logic Input is Low (0 V), M1 is not conducting and the output voltage is defined by voltage divider R1:{input resistance of ICP DAS}. It is 2 kOhms : 10 kOhms. So, we get exactly 10 V from the supply voltage 12 V. Commented Apr 30, 2016 at 15:28
• Yes, you can use bipolar NPN transistor. How fast switching do yo need? Commented Apr 30, 2016 at 15:32
• The advantage of MOSFET for such design is that it inherently allows to get fast enough switching. As for BJT - we have a tradeof between logic output current and switching speed. Commented Apr 30, 2016 at 15:34