how does one calculate the required base resistance, or base current?
Look up the hfe (DC current gain) , and divide the load current by the hfe .
ie: if the hfe is 100, and the load current is 100mA R**base= 100mA/100 = 1mA.**
If base input voltage is 5V then 5V-0.7V = 4.3V
R = V/I
= 4.3v/0.001A
= 4300 ohms. HOWEVER, IMPORTANT NOTE: The above is the method to calculate the small signal base resistor.
For saturation, the base current is multiplied by 10 => 4.3V/0.010A = 430 ohms.
The correct value is somewhere between 430 ohms and 2200 ohms. More than likely 1k would work.
Thanks for the explanation. This device needs to be reliable, unfortunately the transistor arrangement seems to be anything but...
I tried with a 1k base resistor and I was still having voltage drop issues, I also tried with 500 ohms and the problem was a little better, but the transistor was starting to get warm.
@Larryd, I am doing my best to try and understand MOSFETs, but I am having trouble with the drain current diagrams. The ones available in the data sheet are a bit different to those in the link you provided, I will keep reading up though and hope it clicks at some point.
I wanted to ask, will the above circuit work at 3.7-4.2v? And is it a problem that the gate voltage is higher (5v)?
"I wanted to ask, will the above circuit work at 3.7-4.2v? And is it a problem that the gate voltage is higher (5v)?"
What kind of Arduino are we talking about, 3.3V or 5V ?
If you are saying the voltage output from the Arduino is in the range of 3.7-4.2v this is confusing as 5V Arduino will have 5V on a digital output and its 5V pin will be 5V.
Note you can use an NPN transistor to control the series pass P channel MOSFET.
See attached schematic.
If your battery is 12V then you do not need a "logic level" P channel MOSFET so that will make your hunt easier.
"Therefore I have to take an external approach to shutting down the arduino after x amount of time."
Please explain the above in more detail.
The circuits so far discussed will not power up by them selves.
I want the latch to be between the lipo and the step up. The gate voltage will be 5v from the Arduino, and there will be approx 400mA @ 3.7-4.2v running through the latch.
Will this be a problem, and will the components work?
Also not sure if it’s worth mentioning, but the display runs on 3.3v from the 3v out of the Uno
I will power up the device via a push button, and it will turn itself off after x amount of time.
A digital pin will be connected to the buck converter, if this pin is high, the Arduino will not start the power off timer.
mickymik:
I guess what I meant to ask is, how does one calculate the required base resistance, or base current?
For a BJT used as a switch, base current needs to be about 5 to 10% of collector current.
The quoted current gain for the device doesn't apply to saturation, which is the mode used
in a switch. Transistor current gain only applies to the forward active region when the collector
base junction is reverse biased.
I still have some BC337’s laying around, will this be suitable to drive the MOSFET?
I am also driving a 12v relay from the Arduino, at the moment I am using a BC337 with a 10k base resistor (coil impedance is 75 ohms). Should I also switch this to a MOSFET? If so, will the AO3401 also work, or do I need an N channel? And can I switch it directly from a digital pin?
I don’t mind that the buck converter draws some power, the lipo should be recharged each time the device is connected to 12v.
Here are some pics of my project, it’s a small mobile compressor for track days
">
The parts arrived today and I assembled everything, and the Latch works very well. I changed the design a bit to include two diodes so that the buck converter turns on the device via the transistor instead of connecting it to a digital pin and doing it in software.
I was however mistaken when I said I had some BC337s left over. I had actually used them all on previous iterations of the latch circuit, and what I had in the parts box were actually 2N2222A transistors.
I double checked the specs from the suppliers and the hfe was basically the same (250 for the BC337 and 100-300 for the 2n2222a), so I used them instead. The latch works fine, but the relay driver doesnt work at all.
I had actually bought the 2n2222As specifically for the relay driver shown here: but it didnt work last time either. I am a bit stumped, I thought maybe last time the resistor was too big, but this time I used a 220 Ohm resistor and it still doesnt work.
I can confirm the relay is 75 ohm, I have measured it. Manufacturer specs say 1.8w, which fits (I think it works out to be 80 something ohms in theory, pretty close). I will double check that it is working by powering it directly. I had 2 new ones, on this particular one I popped the cover off and installed the diode inside, maybe I messed it up. I did measure again afterwards though to be sure there was still continuity through the coil.
Transistor part number is CTPN2222A LS. I am pretty sure this type has the emitter on pin 1, but I couldn’t find a data sheet matching this exact part number.
Also the latch works so I guess the pinout must be correct?
The resistor definitely came from the 220R packet, but I didn’t physically check the resistance or even check the band colors. I will double check that too.
Thanks for the tips, I’ll let you know what I find.
I tested it out, didnt work...
Turns out it was just a dud transistor. I removed it, tried a new one backwards, didnt work, so I reinstalled the new one in the original position and it works now.
During this process the TP4056 went up in a puff of smoke. I checked the output voltage of the Buck, it was 6.5v, but the datasheet for the TP4056 says it accepts a VCC of up to 8 volts.
I turned the buck down to approx 4.9v and installed a new TP4056. I noticed it was also getting warm, even though input voltage was ~5v. I tested it on USB and it doesnt get warm.
Should I add a current limiting resistor between the buck and the TP4056?
I had already thought about it, but its a very small buck and the poti is SMD type. It will be a real pain to solder them on the board.
I have double checked everything, and it all seems to be OK. I think I am probably responsible for the first charger, and IM pretty sure the second one was getting warm because the lipo was pretty flat, the charger was charging the battery and powering the arduino at the same time.
This brings me to the next problem I am facing...
I would like to have the latch remain off unless the button is pressed. I have to do it externally because I cant fit any more code on the UNO. I'm at 99% and the if statement to only start the timer if another pin is high puts me a few bytes over.
The reason I want to do this is because when finished the only way to charge the lipo will be via 12v, and the lipo will never charge fully if the charger is also powering the uno at all times when connected to 12v.
The lipo is there to power the device when not connected to 12v.
The aim is for it to work as follows:
If 12v is not connected, I push the button, the device powers up for 20 seconds to show on the display how much pressure is in the system, then switches off automatically.
If connected to 12v and the button has not been pressed, the lipo will charge, but the Arduino/display are off. (This allows the lipo to be charged without load from the Arduino and display)
If connected to 12v and the button has been pressed, the device remains turned on until 12v is disconnected.
As I mentioned earlier I had planned to just use the output of the buck as a signal to tell the Arduino to not begin the auto shutdown timer.
Unfortunately I don’t have enough memory for that, I am already on the limit due to display drivers and widgets. I have optimized the sketch as much as possible, and I am even using a modified version of the GUISlice library to reduce memory, but I can’t get enough free space to implement the if statement needed, it puts me about 50 bytes over max. The UNO is completely tapped out.
Do you think it’s possible to meet these criteria? Or do you think I could just leave it how it is, that the battery is charging and the Arduino is powered up both simultaneously whenever connected to 12v?
I measured last time the step up draws about 400mA. The lipo is 800mA. And the charger should output 1000mA. Will this be a Problem if I don’t have some way to disconnect the Arduino when charging?
Another Idea I had was to add an NPN transistor in parallel, and trigger it from the buck. Would this be a better solution?