Switching between 2 batteries using mosfets ~ not working!

Thread Starter

Rasil1127

Joined May 13, 2023
22
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.

View attachment 294163
Thank you for this circuit, i have ordered 2N5401 and will try this. though this spice simulator circuit is a bit confusing for me, is it possible if you where to make it a "normal" schematic? anyways thank you for running the spice simulations to figure this out for me! i have also taken your suggestion about isolating the power supplies and have ordered B0505S-1W isolators.
I will try both the pnp method and the isolation method.
 

crutschow

Joined Mar 14, 2008
38,512
After further thought, I had a eureka.
You don't need the transistor.
The opto can drive it directly if you use a resistive divider to reduce the maximum voltage.
The red trace is the MOSFETs' gate-source voltage.

1684091142107.png
 
Last edited:

Thread Starter

Rasil1127

Joined May 13, 2023
22
After further thought, I had a eureka.
You don't need the transistor.
The opto can drive it directly if you use a resistive divider to reduce the maximum voltage.
The red trace is the MOSFETs' gate-source voltage.

View attachment 294218
very nice work from you! i made this circuit and it works even with 50v battery and 36v battery connected. (before the mosfets blew up.)
however when i attach a 8.4Ohm load to it whatever mosfet pair has the 36v connected start to get very hot when switched onto the lower voltage battery. when switched to the higher voltage battery nothing gets warm. but the mosfets don't blow up they just get very hot once the lower voltage battery is selected.

For now, i changed r4 and r1 to 100k 20k.
 
Last edited:

crutschow

Joined Mar 14, 2008
38,512
whatever mosfet pair has the 36v connected start to get very hot when switched onto the lower voltage battery.
Not surprising, as the ON gate voltage is only about 4.5V with R4 and R1 equal to 100k and 20k, so the MOSFETs are not fully turned on.

If you want to operate over such a wide voltage range, you need to substitute a 10V Zener for R1 as I stated in post #27.
 

Thread Starter

Rasil1127

Joined May 13, 2023
22
Not surprising, as the ON gate voltage is only about 4.5V with R4 and R1 equal to 100k and 20k, so the MOSFETs are not fully turned on.

If you want to operate over such a wide voltage range, you need to substitute a 10V Zener for R1 as I stated in post #27.
yes i realised that now, i apologise for my mistake. however, this circuit works so well I'm really impressed by your work! i have the esp32 powered via USB from my PC but everything is like in your schematic. i have bought a 5v dc to dc isolator will this work to isolate the mcu? part number: B0505S-1W

Also can you explain how the zener diode works in that way? I'm a bit confused about that.
 

crutschow

Joined Mar 14, 2008
38,512
i have bought a 5v dc to dc isolator will this work to isolate the mcu? part number: B0505S-1W
Isolate it from what?
can you explain how the zener diode works in that way?
The Zener keeps the MOSFET Vgs ON voltage constant with a change in the battery voltage.
The red trace below shows the 12V Zener, D1 generating over 11V Vgs when on, for the battery voltage varying from 30V to 134V (yellow trace).
Edit: I used a 12V Zener so Vgs On will always be >10V, which is where most standard MOSFETs are rated for their minimum on-resistance.

1684112913613.png
 
Last edited:

Thread Starter

Rasil1127

Joined May 13, 2023
22
Isolate it from what?

The Zener keeps the MOSFET Vgs ON voltage constant with a change in the battery voltage.
The red trace below shows the 12V Zener, D1 generating an essentially constant 12V Vgs when on, for the battery voltage varying from 30V to 134V (yellow trace).

View attachment 294240
ah that explains it, I've ordered those too.

I will be running the mcu from one of the batteries and have ordered that isolator to keep the mcu isolated from the batteries. and was asking if it was sufficient in keeping the circuit running like it is now.
 

Thread Starter

Rasil1127

Joined May 13, 2023
22
That isolator requires a 5V input to get a 5V output.
Are you getting the 5V from one of the buck regulators operating from the battery?
If so, then the isolator should work.
exactly, i will convert the battery voltage into 5v for the isolator. also thanks again for everything you did it really helped me out
 

crutschow

Joined Mar 14, 2008
38,512
Below is the sim showing the two circuits switching between a 134V battery and a 36V battery:
Yellow trace is the load voltage.

Edit: Just noticed a problem.
Due to cross-coupling of the voltages, the voltage across the output of the U2 isolator goes to 100V when the bottom circuit is on, which exceeds its rating.
Need to give this some further thought.


1684168664426.png
 
Last edited:

Thread Starter

Rasil1127

Joined May 13, 2023
22
Okay, to eliminate the high voltage from the opt output, I think we need to go back to the PNP buffer (below):

View attachment 294265
Ah, okay so this should be working. i wont re-create it now but in final version. One last thing that is bugging me is that i need to measure both batteries voltages via ADC. the only method i can think of is getting ADUM1251ARZ i2c isolator and an external adc. however, these components are quite pricey. is there another smarter method to do this? or that could be the only method.

Also i can get MCP3002 which is an SPI ADC and i heard spi is quite simple to optoisolate using optocouplers. if the circuit for isolating SPI is simple, then i might choose that MCP3002 instead of spending £10+ on the ADUM1251ARZ + external i2c adc.
 

crutschow

Joined Mar 14, 2008
38,512
You could also use a high voltage difference amp (example below) to convert the battery voltages to a ground based signal for conversion by an A/D.

1684184279154.png
 

Thread Starter

Rasil1127

Joined May 13, 2023
22
You could also use a high voltage difference amp (example below) to convert the battery voltages to a ground based signal for conversion by an A/D.

View attachment 294278
Ah, that looks interesting, do you have a part number? i tried searching but the results are ambiguous since i had never seen this component before.

EDIT: found one, INA117P is that the same thing as in your circuit? it looks different but has the same name.
 
Last edited:
Top