Switching between 2 batteries using mosfets ~ not working!

Thread Starter

Rasil1127

Joined May 13, 2023
22
Hi,

i would like to switch between 2 batteries using n-channel mosfets. i was thinking of connecting the pluses from both batteries and interrupting the negative of each battery. I'm possibly switching around 134v so i need a solution which the mosfets can do it and wont blow up. im hoping to have a device which i can plug in lithium ion batteries and switch between them when one of them gets low without ever putting them in parallel with each other. for my electric bike. i have a esp32 hooked up to the circuit to switch the mosfets. all of this powered from the batteries i have made a schematic but it has problems.
modified.png
This circuit switches batteries which have 35v and 36v absolutely fine. and i can even draw a load from them none of the mosfets get hot or warm.
PROBLEMS WITH THE CIRCUIT:

when everything switched off (low gpio signal) but mcu still powered. if 36v is connected in P2 circuit turns on, 0v on the outputs. 0v gate-source voltage. if 36v is connected to P1 circuit remains turned off and nothing happens. if 51v connected to P2 circuit turns on, 0v gate-source voltage for both sets of MOSFET. however, there's 6v on the output. additionally if 36v connected to P1 and 51v to P2 the same 6v remains.

If Q1 and Q2 are on and i connect 51v to P2 i get 51v on output, nothing gets hot. if i then connect 36v on P1 which is off Q4 and Q3 start to get hot and explode. Gate-Source is 0.5v on Q4 and Q3.

COMPONENTS:
OK1, OK2: TLP785
Q1, Q2, Q3, Q4: NCEP85T14 (will be changed for final product to support 134v)
MCU: ESP32
U3, U2: Dc to dc generic buck converter 190~12
U1: Dc to dc generic buck converter 30-5

Q&A:
1) why you don't want to connect the batteries in parallel?

Because i want to have 2 batteries connected together that automatically can be switched. probably even different voltage lithium-ion batteries altogether.

2) How much current will you be drawing from 134V supply?
I will be running around close to 20A however, i will add lots of parallel fets in the final design so that it could handle more current since i might want to deploy these on lower voltage circuits too.

3) I don't understand the dual N channel MOSFET thing with the MOSFETs in series like that, connected drain to drain, I can't see what that is means to achieve, or how it can work.
i put them in series like that because of the body diodes. before the circuit was non-functional if both Q4 & Q1 drains were connected together. With only one mosfet on each line, i was getting current flowing somewhere. Then i put diodes in to prevent that, but they got hot. So the dual mosfets have their body diodes in opposite directions, so if the mosfets were off, they were really off, with nothing flowing through the body diodes.

Credits:
ShermanP: for designing the circuit
PerryBebbington: For an explanation of the circuit.
Head over to Arduino forums to find them.
 

crutschow

Joined Mar 14, 2008
34,431
Try connecting the MOSFETs source-to-source and connect the 2k resistor between the gates and the common sources, which is how they are typically connected.
 

crutschow

Joined Mar 14, 2008
34,431
Are you suggesting a circuit which looks like this?
Yes.
That connection unambiguously insures that the gate-source voltage of both transistors stays at 0V when the gates are turned off (left floating).

It looks a little neater and easier to understand if you draw it like this:

1684002202131.png
 
Last edited:

sagor

Joined Mar 10, 2019
909
P1 feeds U2 which does not have the output "ground" reference connected, like U3 does. You are going to get some strange voltages...
 

sghioto

Joined Dec 31, 2017
5,389
I don't understand that dual N mosfet arrangement either. How does the MCU get power if there is no P2 battery? Doesn't that come from the 5 volt U1 converter?
Also the common grounds used don't seem to isolate the the MCU correctly from the battery switching circuits.
P2 battery supplies power for the MCU via U3 and U1 and bias voltage for the mosfets. Don't see the need for U2.
However if switching batteries with different voltages I think switching the positive side is more practical.
 
Last edited:

Thread Starter

Rasil1127

Joined May 13, 2023
22
Will at least one battery always be connected or do you want to be able to shut them both off?
Yes i don't mind having one battery always connected at any time. Plan was to keep P2 connected always.
Yes.
That connection unambiguously insures that the gate-source voltage of both transistors stays at 0V when the gates are turned off (left floating).

It looks a little neater and easier to understand if you draw it like this:

View attachment 294147
This did not work as expected. the mosfets where on and off but the current flow direction was wrong. so even when one of the mosfets where on there was no voltage on the output.
P1 feeds U2 which does not have the output "ground" reference connected, like U3 does. You are going to get some strange voltages...
this is not possible. if i ground U2 it will short both batteries together and make ground common which is what we are trying to avoid.
I don't understand that dual N mosfet arrangement either. How does the MCU get power if there is no P2 battery? Doesn't that come from the 5 volt U1 converter?
Also the common grounds used don't seem to isolate the the MCU correctly from the battery switching circuits.
To me this circuit arrangement below makes more sense if switching the negative side of the battery.
P2 battery supplies power for the MCU via U3 and U1 and bias voltage for both mosfets. Don't see the need for U2.
However if switching batteries with different voltages I think switching the positive side is more practical.


View attachment 294158
This circuit does not work, please have a look at the Q&A section of my original post. also U3 converted 12v has no reference to ground if i give it to q2 which is a completely different circuit with its own ground. And the idea is that P2 is always connected and the mcu will always have it as the highest priority when switching.
 

Thread Starter

Rasil1127

Joined May 13, 2023
22
Did you try the circuit or is that just your opinion?
Yes that is tried not my opinion, everything in that post is tried nothing is just said because in theory it will work. what you suggested is what i tried the first time i developed the circuit but later found out its problems and then made improvements to it and reached this circuit where I'm at now.
 

sghioto

Joined Dec 31, 2017
5,389
Yes that is tried not my opinion
Did you measure the output with a load?
I see a few issues with your circuit. R1 and R2 are 43K? How is that going to activate the opto-couplers or is that a typo?
The purpose of the opto's is to isolate the MCU from the battery circuit. You show common grounds between both circuits.
It would make more sense to switch the positive sides which would also eliminate the 12 volt converters.
 

Thread Starter

Rasil1127

Joined May 13, 2023
22
Did you measure the output with a load?
I see a few issues with your circuit. R1 and R2 are 43K? How is that going to activate the opto-couplers or is that a typo?
The purpose of the opto's is to isolate the MCU from the battery circuit. You show common grounds between both circuits.
Measurements of output in circuit you suggested? i did run same tests on it however as stated in Q&A the mosfets cannot be connected together with their drains. the batteries start to equalize and current flow through the mosfets and all sort of problems along those lines. Due to the body diodes i assume.

Indeed that is a mistake, its suppose to be 43Ohms i apologise.

OK1 is merely just there to act as a relay of sorts and to just connect 12v to the mosfet gate. however, OK2 is there to actually isolate the circuit since P1 ground isn't common with the mcu or P2. so OK2 has to be there for the circuit to function properly. The only common ground there being shown is one with P2 and the mcu.
 

sghioto

Joined Dec 31, 2017
5,389
Are you sure it's 43 ohms? That would seriously overload the output of the mcu and opto diode. Maybe 430 ohms?
I'm sorry but I find your circuit theory confusing in this application.
 

Thread Starter

Rasil1127

Joined May 13, 2023
22
Are you sure it's 43 ohms? That would seriously overload the output of the mcu and opto diode. Maybe 430 ohms?
I'm sorry but I find your circuit theory confusing in this application.
Yes i think i did some calculations to figure that out a long time ago and using that ever since. it is been working however i will re-do the calculations after solving this issue. at the moment its working fine through my many iterations.

Ah, what would you be confused about? please question my circuit it could be that I'm missing something obvious i have already explained about the common ground situation and why it is like that. however i cannot explain why 2 mosfets cannot be connected drain-drain in your circuit, it just doesn't work and I'm not sure why the only reason i think of is body diodes.

Also your concern about switching the positive side, is that possible with N channel mosfets? i need low RdsON and p channel mosfets arent good. also not enough to meet my requirements. i did hear about capacitors and some diodes and how it can bootstrap. but I'm not going to get into that. if anyone else has done that before please feel free to explain that here as an alternative to my circuit. but it has to use N channel mosfets.
 

crutschow

Joined Mar 14, 2008
34,431
This did not work as expected. the mosfets where on and off but the current flow direction was wrong. so even when one of the mosfets where on there was no voltage on the output.
Yes, I looked more carefully at your circuit and see that is will not work as you show.

Below is the LTspice sim of the basic switching circuit:

The 12V supply must be DC-DC converter with isolation between the input and output commons, not a standard buck converter with no isolation.
The common for the 12V supply output must go to the junction of the two MOSFET sources for proper MOSFET switching.

Also the power supply output common cannot be connected to the control common if you want the opto to provide isolation.
(Rsim is just for simulation purposes and is not used in the real circuit).

1684028477921.png
 

crutschow

Joined Mar 14, 2008
34,431
Below is a circuit that eliminates the 12V supplies by substituting a high-voltage (≥150V) PNP transistor to control the MOSFETs.

Note that this inverts the input signal, with the output on for a 0V input to the opto.

1684031103360.png
 

sghioto

Joined Dec 31, 2017
5,389
Below is a circuit that eliminates the 12V supplies by substituting a high-voltage (≥150V) PNP transistor to control the MOSFETs.
Looks good, I like it.
I just want to know who uses a 134 volt battery on an electric bike?
At 20 amps that's over 2600 watts. Must be an extreme machine.o_O
 

sghioto

Joined Dec 31, 2017
5,389
It seems a simpler alternative is to use an SSR rated for the application switching the positive sides. Something like this.
Although I understand the reasoning for designing a custom circuit.
1684079218710.png
 
Top