I'm trying to switch (just on/off) a 3.7V motor (coil resistance 2.2 Ohm) and a 6V motor (coil resistance 8 Ohm) with an arduino mini. And I have trouble finding an universal way to do so. What I know so far:
- there has to be a fly-back diode (D1 on schema)
There are 4 possibilities for the switch
a) relay (simplest, Arduino Uno with 12V pump: transistor or optocoupler+12V relay?)
b) NPN transtor https://electronicsclub.info/transistorcircuits.htm
c)(low gate voltage) MOSFET How to drive low impedance load with arduino and transistor
d) optocoupler (see the relay link)
A Low side switch is better than high side switch. High side switch and Low side switch
All grounds have to be connected together (unless using an optocoupler) Does signal ground have to be connected to actual ground?
I have built the following schema that does not work.
From the above points my schema violates 3 and 4 but are those the main problems or are there some other that I'm missing?
Is it vital to have the right resistance on R2? If I understand correctly too big R2 results in not enough current on the base to switch the transistor on. But why/how the board pin gets destroyed when there is not enough resistance on R2?
- Can a transistor and resistor be selected with such specs that if I want to change the motor to a different one I do not have to change those components? In other words which transistor specs I have to keep in mind if I want to select a motor with 1-100 ohm coil resistance and 3-12V?
More background info:
I measured that gate voltage is 4.6 V and current 40 mA (I used 70 Ohm at R2 instead of 330).
I think the transistor is working and connected right way (measured with a multimeter all pairs both ways).
I would like to keep the component count and price to a minimum. Relays are big and expensive so I hoped a transistor would do.
I understand I need R1 to prevent a floating pin What does pulldown resistor from Arduino's output pin to ground do? Is it necessary?
I'm trying different motors to see which one works best.
So I switched my logic to low side switch and it started working. I tried both ways with and without the grounds of arduino and the motor power supply connected but it did not seem to make a difference. However the transistor Q5 (2SD965) got hot when the 3.7 V motor was connected suggesting that the gate was not fully opened or something else was wrong. What exactly I do not know (newbie as I am).
Edit of the edit:
So I tried again the low side switch and connected the arduino GND and power supply minus together. Like magic everything started working with the transistor Q5 (2SD965) and it didn't get hot and it stopped working the minute I disconnected the grounds. So the only logical guess is that I miss-connected something during the first edit. On top of everything it worked with both motors and with other transistors!
So the morale is points 3 and 4 are extremely important