MOSFET ON by default when arduino is off.

Hi, I am working in a project.

I have a solar panel (9 Voc) connected to a battery (AGM, 6V) and then to my arduino (Working with a LDO 3.3V).

I want to control my battery charge and discharge cycles so:

  1. with a TL431 and a second mosfet I can make a circuit to disconnect my load (LDO IC and arduino) from battery when the voltage is low, and reconnect it when voltage has rise a little bit (my schema has a bit of hysteresis for doing this. If you want it, please, ask me).

  2. with controlling my battery voltage, measuring it by AnalogRead from arduino, I want to disconnect my solar panel from the battery when it's more than 7V. ( my battery is a 6V system and solar panel is 9Voc)

I want to use a mosfet (for me is the same P or N channel): let's call it "solar-mosfet"

Arduino will control solar panel connection with my battery by putting ON or OFF the solar-mosfet. NO PROBLEM HERE. analogread--> digital write to control solar-mosfet

But If my arduino is disconnected from the battery (low voltage) so my arduino is NOT alive, may be for few days, how can I ensure that the solar-mosfet is ON so the solar panel is charging the battery?

NOTE: may be you have other options, but I want to keep it simply and I have already broke a battery because of it is going up to 8 or 9Volts, low current yes, but high voltage).

Thanks a lot.

Use a NPN as a buffer between Arduino and MOSFET gate. Then use pullup or pulldown on the gate to hold whatever default level you want when the Arduino is off and the NPN collector is floating.

Hi, thanks

I have simulate this circuit. It is simple as it doesn't need a transistor.

What to do you think about it ???

Thanks,

NOTES:

Switch (key=space) is arduino pin, when arduino is powered off, it is open, so mosfet is ON, when powered and digital input LOW, mosfet is OFF.

Load is battery.

R13 is pull high for the gate of the mosfet

cto.jpg|580x275

Won't work, the Arduino pin will drag the gate down towards zero volts when the Arduino is powered down. You simulation lacks the Arduino pin circuitry so wouldn't show that.

You must arrange a LOW output to turn on the load and a HIGH output to turn it off. However HIGH = 5V, not 8V, so an extra level shifting transistor is probably the best way. Drive an NPN that shorts the gate to ground in that circuit.

Hi OPs circuit. |500x237 Your system gnd needs to be on the battery/load side of the MOSFET not the PV side.

Forget about measuring the PV voltage, use a shottky blocking diode in series with the positive PV terminal. That is if it isn't already fitted.

Then switch the MOSFET ON when the battery needs charge, if the PV voltage is high enough it will provide current. If the PV voltage is too low then NO current will flow.

What are you PV specs. What are you battery specs?

Tom.. :)

TomGeorge: Hi OPs circuit. |500x237 Your system gnd needs to be on the battery/load side of the MOSFET not the PV side.

Forget about measuring the PV voltage, use a shottky blocking diode in series with the positive PV terminal. That is if it isn't already fitted.

Then switch the MOSFET ON when the battery needs charge, if the PV voltage is high enough it will provide current. If the PV voltage is too low then NO current will flow.

What are you PV specs. What are you battery specs?

Tom.. :)

Hi Tom, thanks a lot.

I will only measure battery voltage and do as you say, switch the MOSFET on and off when the battery needs charge

My problem is that I have a second circuit that disconnect my arduino from the battery when my battery's voltage is low.

So I want to ensure that when my arduino is powered down, my battery will recharge. "That second circuit" has some kind of hysteresis, so it will powered down arduino at 5.7V and reconnect it again at 6.2V.

The mesasurement of battery voltage and mosfet will disconnect PV from the battery at 7V and reconnect it again at 6.5 or 6.7V ( this is easy as you can program your sketch, the second circuit is ALL analogic).

Here you have the second circuit attached only for reference.

SecondCircuit.jpg|741x371

MarkT: Won't work, the Arduino pin will drag the gate down towards zero volts when the Arduino is powered down. You simulation lacks the Arduino pin circuitry so wouldn't show that.

You must arrange a LOW output to turn on the load and a HIGH output to turn it off. However HIGH = 5V, not 8V, so an extra level shifting transistor is probably the best way. Drive an NPN that shorts the gate to ground in that circuit.

CrossRoads: Use a NPN as a buffer between Arduino and MOSFET gate. Then use pullup or pulldown on the gate to hold whatever default level you want when the Arduino is off and the NPN collector is floating.

Hi @MarkT and @CrossRoads, do you mean something like this circuit ? Is it possible to put R12 as a 100K resistor ? (in order to let it low current device).

is it now ok ? Any more changes ?

Regards,

Cto_02.jpg|606x324

Hi, Move the earth like i advised earlier. |500x267 Tom.... :)

Cto_02edit.jpg|606x324

TomGeorge: Hi, Move the earth like i advised earlier.

I only partially agree with that Tom. The circuit definitely has problems with ground placement, but making that change alone (battery negative and Arduino ground at the mosfet drain) creates more problems than it solves.

Jaun: You need to move the ground to the battery negative as Tom suggests (because that is where you want the ground for the Arduino to be) AND you need to flip the mosfet around (exchange source and drain) so that you are switching the solar cell and not the battery.

Your circuit is confusing, however from what you previously said I'm taking your "load" as the battery and your voltage source "V5" as the solar cell. This is a FAR from realistic simulation though.

BTW. Your simulation probably wont work properly when you make the suggested changes, but frankly that is just because your simulation is such a poor model.

TomGeorge: Hi, Move the earth like i advised earlier. |500x267 Tom.... :)

No, definitely don't move the ground there!

MarkT: No, definitely don't move the ground there!

Mark. I know that the ops circuit is poorly drawn, but previously he said ...

NOTES: - Switch (key=space) is arduino pin,

- Load is battery.

So yes, he really does want the ground (common reference node) at the negative of the battery, not at the negative of the solar cell as it currently is shown.

Refer to my previous post. He has to move both the ground and the mosfet (so that it switches the solar cell rather than the battery).

TomGeorge:
Hi,
Move the earth like i advised earlier.

Tom… :slight_smile:

stuart0:
I only partially agree with that Tom. The circuit definitely has problems with ground placement, but making that change alone (battery negative and Arduino ground at the mosfet drain) creates more problems than it solves.

Jaun: You need to move the ground to the battery negative as Tom suggests (because that is where you want the ground for the Arduino to be) AND you need to flip the mosfet around (exchange source and drain) so that you are switching the solar cell and not the battery.

Your circuit is confusing, however from what you previously said I’m taking your “load” as the battery and your voltage source “V5” as the solar cell. This is a FAR from realistic simulation though.

BTW. Your simulation probably wont work properly when you make the suggested changes, but frankly that is just because your simulation is such a poor model.

MarkT:
No, definitely don’t move the ground there!

stuart0:
Mark. I know that the ops circuit is poorly drawn, but previously he said …

NOTES:

  • Switch (key=space) is arduino pin,
  • Load is battery.

So yes, he really does want the ground (common reference node) at the negative of the battery, not at the negative of the solar cell as it currently is shown.

Refer to my previous post. He has to move both the ground and the mosfet (so that it switches the solar cell rather than the battery).

Thanks, thanks, thanks and thanks.

I know that the schema is very very basic, but it is because I am beginning with MOSFETs and I want understand how they work.

I think it is not necessary to have a PV and battery model in the simulation.

I have changed (see attach) what you say and put some other parts in order to show you where is the battery, where is arduino, … (I have put also the first LDO that I have found in Multisim).

I dont understand why I need to change DRAIN and SOURCE

Also, arduino pin is very poor simulated, I don’t know if it is enough, and if not, i don’t know where I could simulate arduino and analogical parts in the same schema.

What I have found with this simulation is that:

  • arduino pin OUTPUT high to DISCONNECT PV from BATTERY
  • arduino pin INPUT to CONNECT PV to BATTERY
  • arduino powered down ==== INPUT, so I can connect PV and BATTERY

I know that is a poor simulation, but in this circuit and get negative voltages in base of the NPN. Will It hurt my arduino pin?

Sorry for my poor knowledge.

Regards and thanks a lot for your efforts, I am learning a lot of this mosfets.

Clever pv controllers use a maximum power transfer algorithm.

the pv panel has both a voltage ( which increases ) and an internal resistance - (which decreases) as the illumination level increases.

Given the battery isn't fully charged :

  • the controller acts as a boost convertor at low illumination levels.
  • it acts as a buck convertor at higher levels.

As the internal resistance of the pv is unknown , a hunting algorithm is used to find the highest power transfer point.

Allan

allanhurst: Clever pv controllers use a maximum power transfer algorithm.

the pv panel has both a voltage ( which increases ) and an internal resistance - (which decreases) as the illumination level increases.

Given the battery isn't fully charged :

  • the controller acts as a boost convertor at low illumination levels.
  • it acts as a buck convertor at higher levels.

As the internal resistance of the pv is unknown , a hunting algorithm is used to find the highest power transfer point.

Allan

Thanks Allan, here my goal is to connect and disconnect the PV panel from the battery (it is a low voltage and low power PV so I don't want to use a controller).

Regards,

juan3211: I think it is not necessary to have a PV and battery model in the simulation.

I understand that you are trying to keep the simulation as simple as possible, but it makes the circuit look a bit obscure.

If you want a really simple approximation then just use a voltage source for the battery (with optional small series resistance) and voltage source with relatively large series resistance (V/R to give panel short circuit current) for the solar panel.

If you want a better model for the solar cell (if your sim software doesn't already include one) then the following circuit gives a very good approximation. Set the current source for the solar cell current maximum (short circuit current) and simply add as many diodes as you need to get the correct open circuit voltage (probably about 14 diodes in your case).

solar_cell.jpg|200x246

juan3211: I know that is a poor simulation, but in this circuit and get negative voltages in base of the NPN. Will It hurt my arduino pin?

That is because you still haven't got the overall circuit topology right. To be clear, you need to disconnect the solar cell from the rest of the circuit, not just disconnect the battery as in your original plan.

Initially I thought that you could still achieve this using the low side switch as per your original plan, but switching the low side of the solar panel instead of the battery (while keeping a common ground for BJT emitter, and MOSFET source, and Arduino gnd, and battery negative).

After some thought however I now don't think that this simple solution can work, because the mosfet body diode will allow the battery to keep charging even after you attempt to switch out the solar panel (a low side switch on the panel would need to be reverse blocking).

So I suggest changing to a high side switch (p-channel) so that you can keep a common ground for everything. It complicates the circuit a little, but I now believe you need something like the following.

BTW. This is a crude freehand diagram to show basic interconnection only. It's not a complete circuit diagram!.

overview2a.jpg|475x225

BTW. If anyone was wondering what I was referring to previously (which I now believe won't work with a low side switch), it was this.

Note how the internal body diode of the mosfet will prevent it from ever stopping the battery charging.

overview1.jpg|479x247

Then put a diode in series with the MOSFET....

Allan

allanhurst: Then put a diode in series with the MOSFET.... Allan

And when you want the mosfet to switch on and charge the battery ...?

Allan, the problem is that the mosfet needs to conduct current in the wrong direction. In other words, when it's "on" it need to conduct current backwards, when it's "off" it need to block current backwards.

I think that this should look pretty obvious now that I've re-drawn the circuit. I have to admit that the slightly goofy way the circuit was originally drawn threw me a bit. I could see that the wrong thing was being switched out (battery instead of solar cell), but I didn't see that the low side switch cannot work until I re-drew it.