PWM Mosfet voltage working chart?


I have a 7S lithium 18650 Battery Bank (28.7V total, 4.1 each) and an Arduino Uno to control the solar charge. Pin10 as the PWM into a BJT (2n3904) that triggers the gate of a MOSFET (IRF640N) that connects or disconnects the ground from solar cells.

So far so good, PWM regulates charging when 0 and no charge when 255 and all in between those values.

But my Problem start after all that before:

When it reaches 28.7 the charging method (PWM = 0 which is máximum charge) turns into PWM variable, and doesn't stop charging fast enough.

Cheking the Voltage values of the GATE of the MOSFET:

  • pwm-pulse = 0, maximum charge , Gate Voltage = 12.5 V
  • pwm-pulse = 255, minimum charge, Gate Voltage = 0 V

So you would soy "evething's right!" but no.. if pwm 212 I get 2,06V on Mosfet-Gate and if pwm 172 I get 4,03V on Mosfet-Gate.

How should I simulate/adjust/make a curve for the MOSFET to stop charging or work faster and really make use of the pwm instead of just turning the MOSFET on and off

NOTE: I used a Voltage divider with 100K y 18K to read on A0

We will need to know how the 2N3904 is wired to the micro and the MosFet. Also the code would be helpful.

When you measure voltage on the MosFet should we assume you are using a Voltmeter?

I forgot, here it is:

pin10 (pwm) goes to a 1K resistor into the base of BJT (2N3904), BJT emiter and Mosfet Source to ground, BJT colector to Gate-Mosfet and all of them with a 10K to 28.7V BatteryBank. Finally Mosfet Drain to the (-) of solar panel

and you're right, all measured with a multi-voltmeter

Please sketch, verbal descriptions give me a headache.

here's the sketch

Other post/duplicate DELETED
Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

Can you please give us a complete circuit diagram, showing all battery and solar panel connections?
A pen(cil) and paper drawn diagram will be fine, just make sure all pins and components used are labeled.

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

Here it is (should I update the first post with the image also?

PS: I was thinking my problem was not making the mosfet work under the saturation stage to control de current and stop charging when needed


For me, the IRF640N is not connected properly. Charging does not stop because current flows through the internal body diode in the FET.

When Pin10 is high (logic 1) the Mosfet will be off (open).

I know , when pin10 is on max = 255 , Mosfet Gate is 0V
and when pin10 on min= 0 , Mosfet Gate is at 12,5V

the problem seems that even then Mosfet Gate is at 0V is still remains "connected"/charging very slowly

So you mean I should find a way to avoid the internal diode to conduct? by replacing with another Mosfet or wiring it completely in another way?

Your MosFet is not of the correct polarity. It will look like a diode when used in that ckt.

I think wiring it a different way. Maybe the MosFet has to be flipped around, which will change the drive circuit. On the way out and can't check the details right now. But the mosFet has to be connected so current goes from drain to source. And the gate voltage has to be positive relative to the source.

So you mean the Mosfet, when using it to switch the ground/(-) connection of the solar panel, makes the current flow from Source to Drain which makes the internal body diode conducts even when no positive voltage is on Gate (compared to Source)????

Yes, the body diode is actually a parasitic portion of the MosFet structure.

I think there is a way to use this Mosfet if you reverse the drain and source but I would have to go through it again to be sure.
You could of course use a P-Channel Mosfet.
What is your charging current?

I have now 2Ah (@ 28,7V) and was planning to use it with 8Ah

I could try to use a P-Channel , but this change the hole circuit and programing (and the N-channel Mosfets was the one's I had lying here)

I'm really puzzled by this. The problem is that it seems the lowest point in the circuit is the solar panel negative terminal. It's not the system ground. So the mosfet needs to control current flowing from ground back into the solar panel.

But I think there's also a problem that if the mosfet is off, the solar panel somehow becomes de-referenced from the rest of the circuit, including the Arduino and the NPN. Well, I shouldn't pretend to understand this. I've always had trouble with low side switching when there are multiple power rails.

1 Like

@ShermanP you are exactly correct. I'm embarrassed I missed that (was focusing on the MosFet function.)

The OP will need to common the circuit and Solar panel grounds. Switch the high side with a PChannel Mosfet and move the divider going to A0 directly to the solar panels.

well FOLKS! thanks a lot for all the info

I was trying to make "things work" with what I had available in my box of parts

Now I'm buying a bunch of P-channel mosfet to change everything and have a better desing, with no loss, and with controlable charging and "NO CHARGING" to avoid overcharging the 18650 which they hate!