Controlling a solar panel via Arduino & MOSFET on digital pin

Hi folks.

I have a device which is powered by a lead-acid battery that is charged by a solar panel.
I want to use that device's Atmega328 to turn the panel off when the battery is fully charged and on when the voltage drops below some threshold. I also want to disconnect the charger to measure the battery voltage periodically.

A relay is possible, but consumes power continuously - not good for a solar project. A normally-on relay is better, as it only consumes power when pulling the solar panel OFF - a time when, by definition, the battery has plenty of charge, but it's hokey.

I wanted to use an N channel power MOSFET, but it gets tricky.

I tried a low-side switch, wiring the solar panel positive to the battery positive, and the MOSFET (IRF540A) between the panel ground and the battery ground.

Because the panel has a higher voltage than the battery and the positives are connected, the panel's ground is 6V lower than the battery, so I flip the MOSFET source/drain - the source goes to the panel ground, and the drain goes to the battery ground.

Not home yet, because the Atmega can only source 5V (actually it's running on 3.7 - so 3.7volts) or Battery ground, which is also drain voltage.

However, I can use a large resistor between the gate and source to pull it low, turning the panel off, then I can use an Atmega digital output to write a HIGH, which pulls the gate on, thereby turning the panel ON. When I make the digital pin an INPUT, it goes high impedance, and so the pull-down is allowed to turn the panel OFF. So now I have control, right?

Well, yes - it worked. For a few minutes. Then it stopped. I think it's because I inadvertently created a path from the digital pin to - 6 Volts, and I think that fried the driver for that pin.

I wondered about using a diode to prevent this current/voltage path, but I realise I don't know how to analyse this circuit.

So my first question is - is it current or voltage that matters, and whatever the answer - how can I prevent it?
And my second is - assuming I get it working, is this a sensible way to control a panel? It's far less complex than any other charge regulator I've seen, which I suppose should be telling me something.

Any insights would be very welcome.

The image I inserted isn't visible for some reason - it's here: http://chriswesley.org/c.jpg

I looked at your schematic. No ground is marked. The circuit is not a good one.
The MOSFET has a threshold voltage of up to 4 volts ( 2 < Vth < 4 volts)

So if your Arduino is running on 3.7 volts, that MOSFET is not a good choice.
Establish a ground node in the schematic.
Do not use negative voltages, use a diode from the solar array to the battery.

What about a latching relay?

You need to level-shift the gate drive to the mosfet. Assuming that the atmega328 ground is connected to the negative side of the 12V battery, this is easier if you use a P-channel mosfet. See attached schematic. It doesn’t need to be a logic-level mosfet, because it will get about 14V gate drive. Also I believe you need a diode between then solar panel and the battery, which I have included in the schematic.

Yes, for starters, use a common ground. The schematic provided by dc42 looks good.

Thanks for your time and advice guys. I appreciate it.

AmbilLobe thanks for all your comments. No ground is marked - agreed - but I don't really understand the significance of that. In reality no part of the circuit is connected to ground, and so all that matters - or exists - is relative voltages. I'd welcome being educated on this.

Shpaget - latching relay - never knew such a thing existed. In fact, I invented it in my head last night. Too laet. Again. Thanks! I still prefer solid state, but it's a new option I now have undeer my belt.

DC42 thanks for the circuit - I'll do it that way. It avoids all the weird levels. The panel comes with a diode to stop backflow, so I think I'm all set.

Thanks again, folks.
Chris

In reality no part of the circuit is connected to ground, and so all that matters - or exists - is relative voltages. I’d welcome being educated on this.

The only way to have “relative voltages” is to have a common reference point to relate to, and generally that is “ground”.

Thanks again.

Well, it's working fine, and the digital pin can connect and disconnect my panel at will.
So now it comes down to deciding when yo connect and disconnect.

My thought was to measure the voltage of the lead-acid battery and turn the panel off when it gets too high, and on when it gets too low. Because the panel voltage is higher than the battery I must disconnect it before measuring the battery voltage. All of this works, too, but I find that when I first disconnect the panel, the battery voltage may be 14v, but it will drop rapidly, then more slowly, and not settle before MINUTES have passed. So - do I have to wait those minutes to performa a meaningful read of the battery state - or is there a better way to do it?

Thanks,
Chris

I suggest this:

  • When the voltage reaches 13.6V (or whatever charge voltage the battery manufacturer recommends), disconnect the solar cells
  • Reconnect them when either the battery voltage falls to a value indicating discharge (probably just under 12V about 12.5V - again, check the battery datasheet), or after X minutes, for some suitable value of X (e.g. 10).

There is a good article about charging lead-acid batteries
at How to charge all lead acid batteries; how to charge SLA lead acid batteries,a tutorial for engineers about lead acid chargers and charging.

I don’t understand the need!

Lead acid batteries float at 14.5v, an lm317 and a diode will do that, no need to worry about d/c the battery then, at night you have no choice lol

Hi, Chris you do not have to disconnect the panel to measure the battery voltage to see if it has charged.
All chargers measure the battery volts continuously and disconnect when the voltage gets high enough.
Because the output voltage open circuit of the panel is 18V, the voltage drops to the battery voltage when they are connected, the PV is a current source not a voltage source.
This project could be further advanced with an LCD or 7seg LED display showing battery volts, but get the switching level sorted first.
A good project to learn about FETs, PV, grounding etc.
I gather you are charging lead acid batteries, if they are wet-cell, look up equalization.
If your batteries are charged to 13.8V day in day out the electrolyte stratifies, or becomes layered, and it needs a stir.
To do this they allow the charge voltage to go to 14.2V to cause gassing for a short period of time.
Tom.. :slight_smile:

You can disconnect the solar panel from the battery to test if the battery is defective. Once in a while (week), after batteries are fully charged, disconnect the solar panel, and monitor how long it takes the battery to get to its low cutoff voltage. Get the time from a good/new battery, then each week compare the time to that. If the battery goes bad, the time will become shorter. You may want to further test the battery, and/or replace it. At least you are alerted the battery is in question.

TomGeorge:
Hi, Chris you do not have to disconnect the panel to measure the battery voltage to see if it has charged.
All chargers measure the battery volts continuously and disconnect when the voltage gets high enough.
Because the output voltage open circuit of the panel is 18V, the voltage drops to the battery voltage when they are connected, the PV is a current source not a voltage source.
This project could be further advanced with an LCD or 7seg LED display showing battery volts, but get the switching level sorted first.
A good project to learn about FETs, PV, grounding etc.
I gather you are charging lead acid batteries, if they are wet-cell, look up equalization.
If your batteries are charged to 13.8V day in day out the electrolyte stratifies, or becomes layered, and it needs a stir.
To do this they allow the charge voltage to go to 14.2V to cause gassing for a short period of time.
Tom.. :slight_smile:

If you apply 14.5v to a lead acid, the current draw from the battery is only a few ma (to basically keep it topped up constantly) bigger the 12v battery the more current it takes to float it, i'm using a sealed lead acid just fine, i guess I could just shake it once every few months, had this going for 2 1/2 years on float working wonderfully I've had a couple of heavy duty car batteries dry out on me floating (still took almost 2 years)

Hi, SLA and wet cell batteries are a bit different, SLA is designed to sit and float. Large wet cells need to be equalized.
Automotive batteries are stirred everytime you drive the car, plus the alternator will when supplying 10amps or more will make the battery bubble and so stir it up.
Wet cell batteries, particularly deep cycle, need regular checking as there will always be a certain amount of water loss.
Tom. :slight_smile:

Folks, thank you so much for your comments.

The battery I have is a Dynasty VRLA HSP 12-290 which specifis a float charge of 13.65 volts. I always assumed that was a deep cycle battery, but in fact it doesn't say that anywhere in the spec and it DOES say it's designed for "float service applicaiton" which I assume means to be used once in a while then topped up immediately.

In reality the panels, totalling 18watts, and giving around 18 volts are unable to push the battery up that high. A trickle charger will, but it will have dropped back down to 12.2V 10 minues after disconnecting it; the load is presumably tiny - it's about 20 mA.

Does this mean the battery's finished? I bought it new, and it's almost unused, but it's sat languisshing for a eyear or so. I've been researching rejuvination.

Tom, thanks - I will remove the code that disconnects the panel.
I thought the voltage droop after disconnectring the panel was caused by the higher panel voltage, but it may be due to battery damage.

Ah, I'm just waffling here. I'll plug on - thanks again for all your comments.

Depending on the battery type and capacity, it may be normal for the battery to drop to 12.2V quite quickly. I suggest you do the following:

  1. Measure the actual discharge current

  2. Measure how long it takes to drop to 10.5V (or 11V if you prefer), multiply that time the current, and compare that with the stated battery capacity. Don’t discharge the battery below 10.5V because that is likely to damage it.

Thanks for the further battery insights guys. I find I'm fudging it. I CAN drive the SLA up to 14.5 volts as the spec recommends, but as soon as you disconnect the solar panel, the battery drops back down to 12.5 within a minute or so. I'm thinking driving half an amp into them all the time to keep them up at 14.5 is probably not doing them any good, so I've changed the program to stop sooner.

Anyway, a new problem has arisen. Well, a new challenge, I should say.

I have completed the power management side of things with an N channel MOSFET (IRF540a) acting as a low-side switch to a car-phone charger which re-charges an Android phone from the battery. Source to system ground, drain up at 12V from the SLA and gate, via a resistor to a digital pin.

So a P channel MOSFET controls the solar panel charging the SLA as per the diagram provided here, and this new N channel MOSFET controls the charger - turning it off when the phone is full The phone tells the microcontroller when it's full via a Bluetooth tranceiver. The problem is that whenever the phone charger power is turned OFF, the BT module (JY-MCU) sends a few bytes of junk which causes problems downstream.

I'm assuming there is interference generated by switching 300mA off quickly. The MOSFET us very close to the module, so one idea would be to move it, but there is no room and it would be a major upheaval I'd rather avoid. A second idea would be to put a large capacitor across the power supply, but this doesn't help - the supply is from a switch-mode regulator. A third idea was to place a much smaller capacitor across the Drain and Source of the MOSFET but that doesn't fix it either.

Any ideas anyone? Thanks in advance.

Chris

ChrisXenon:
Thanks for the further battery insights guys. I find I'm fudging it. I CAN drive the SLA up to 14.5 volts as the spec recommends, but as soon as you disconnect the solar panel, the battery drops back down to 12.5 within a minute or so.

I think that is only to be expected, and entirely normal. There is no need to maintain 14.5V all the time.

ChrisXenon:
I have completed the power management side of things with an N channel MOSFET (IRF540a) acting as a low-side switch to a car-phone charger which re-charges an Android phone from the battery. Source to system ground, drain up at 12V from the SLA and gate, via a resistor to a digital pin.

I don't understand that. It sounds as though you have the N-channel mosfet connected so that it shorts the SLA battery, which I am sure is not what you meant. Please post a schematic

AmbiLobe:
I looked at your schematic. No ground is marked. The circuit is not a good one.
The MOSFET has a threshold voltage of up to 4 volts ( 2 < Vth < 4 volts)

So if your Arduino is running on 3.7 volts, that MOSFET is not a good choice.

Just picking up on this in case anyone’s confused - the threshold voltage of a MOSFET is
irrelevant to selecting gate drive voltage. Just ignore it and look for the
“Rds(on) at Vgs=xxx” specification.

The two voltages relevant to using a MOSFET as a switch are the voltage where it is
fully off (always 0V), and where it is fully on (as given in the Rds(on) spec).

Threshold voltages are highly variable and indicate only when the device is conducting
a few hundred microamps. For instance most MOSFETs with a Vthr of “2–4V” need 10V
to switch on properly and are not logic level at all.