Sanity check on N/P channel MOSFET's for battery charge/discharge - Page 1
Forum section: electronics / beginners

author: joeyjoejoe
author_rank: Frequent Contributor
timestamp: September 11, 2018, 10:52:20 pm
content: On to the next phase of my homemade battery charger, I want to confirm my understanding of MOSFET's.+CHARGE comes from a PWM controlled voltage source that Hero999 and some others helped me figure out.R10 is a shunt resistor (value still to be determined).When CHARGE_EN is enabled (pulled low), current will be allowed to flow through the shunt resistor, Q1 and charge the battery. Current is controlled by measuring voltage drop between ADC1/2, and battery voltage is determined by measuring ADC2/ADC3. (In theory ADC3 will be at 0V, but it can't hurt to have this). When disabled, current will not be able to flow backwards into the circuit.When DISCHARGE_EN is enabled (pulled high), current will be allowed to flow through Q2 to ground. When disabled, no current can flow. (Controlling the amount of current being discharged is still in the "todo" column. I am torn between a simple power resistor (non adjustable load), or with controlling the MOSFET.Hopefully this is correct - what I took away from reading (and the internal symbol) is that if I had chosen different MOSFET types (N/P), current would still be able to flow even when the MOSFET was turned off.

author: LukeB
author_rank: Contributor
timestamp: September 11, 2018, 11:39:04 pm
content: Schematic??

author: joeyjoejoe
author_rank: Frequent Contributor
timestamp: September 11, 2018, 11:45:17 pm
content: It's posted at the top.

author: Sceadwian
author_rank: Unknown
timestamp: September 12, 2018, 12:42:21 am
content: Q1 Drain/Source is swapped, that'd be a great smoke generator.

author: joeyjoejoe
author_rank: Frequent Contributor
timestamp: September 12, 2018, 12:51:00 am
content: Quote from: Sceadwian on September 12, 2018, 12:42:21 amDoes Q1 have to be a P-channel?

author: Sceadwian
author_rank: Unknown
timestamp: September 12, 2018, 01:18:14 am
content: No, but you will have gate drive level requirement issues with an N fet depending on how much current is involved because your source voltage will be floating above ground and the source to gate voltage is what turns it on. It depends on the exact VCC you have to work with and the exact FET's you have available.This is a common high side/low side switching problem with FETs. There are ways around it such as using a photo voltaic isolator but that's pretty exotic.

author: joeyjoejoe
author_rank: Frequent Contributor
timestamp: September 12, 2018, 01:25:24 am
content: I see. So I can stick with the P channel, but fix the directionI did totally misread the diode inside Q1. Smoke generator indeed!(an aside, ‎IRFP150MPBF looks like a potential candidate for Q2 (discharge). Apparently used in other electronic loads.)

author: Sceadwian
author_rank: Unknown
timestamp: September 12, 2018, 01:51:18 am
content: Pmos is fine for this.I'm guessing with the ADC net you have listed there that this will be micro controller driven? I'm going to assume until you correct me that you'll be sensing the current with the MCU which will be controlling the voltage? For proper current control you're going to want an opamp in the current sense loop or you're not going to have adequate control over it. Typically you'd use an opamp to drive the gate and feed the opamp a voltage from a DAC that will set the desired current, relying on the MCU to control the current via controlling the +charge voltage would very likely not be stable.But I'm just guessing there.A better idea of what you're doing here would be helpful. And be damn careful with that discharge enable line, you screw up and turn both of those fets on at the same time on accident and more magic smoke happens

author: Alex Nikitin
author_rank: Super Contributor
timestamp: September 12, 2018, 09:27:55 am
content: Batteries are dangerous stuff. I would design this kind of a circuit in a way that would be inherently safe, limiting the maximum discharge current and minimum discharge voltage in hardware, ideally with resistors as ultimately limiting elements and perhaps with a fuse as well.CheersAlex

author: krish2487
author_rank: Frequent Contributor
timestamp: September 12, 2018, 11:00:36 am
content: Also,if it were me, I would have some sort of physical steering logic for the charge and discharge enable lines using some 7400 logic..That way even if the firmware accidentally set both to active.. the gating should prevent accidental shoot through.

author: joeyjoejoe
author_rank: Frequent Contributor
timestamp: September 12, 2018, 11:58:22 am
content: Sceadwian - indeed this was only a snippet. I was trying to break things down into topics. I figured a "battery charger" post in projects would be one of a million. Here is a look at the source of the charge netI do know now how to find the appropriate resistor values to get the desired output from the LM317/338. These aren't 100% final either, as perhaps I'd want to accept cells as low as 3V. (Or not).Alex - I like the idea of a fuse, this will probably save me a lot of headachesI will put one in, and at the start keep it low around 1A, and just work out all the mCU code/logic keeping things under 1A. Hell, maybe 500mA. Then I can start nudging upwards.Krish - I had thought about the exact same thing. Having the hardware ensure it's not possible for both to be on. I'll consider it, if not for the final design then at least during the prototype phase. I don't want to add too much in the way of the footprint, and I can have a function in the mCU that guards these outputs to ensure they are never conflicting as well.

author: Sceadwian
author_rank: Unknown
timestamp: September 12, 2018, 10:45:13 pm
content: Yeah, this is not looking like a very good design. You're relying on the micro controller to be the control loop for the current limit. Based on your current sense resistor all it will take is one glitch that causes the PWM to fail logic high and you'll be jamming 5amps down the throat of any cell connected.Have you even checked your response time by simulating this stuff in LTspice? I don't want to be a wet blanket, but based on the fact you also had the PFET backwards in the original image here I think you might be biting off a bit more than you can chew.Quote from: joeyjoejoe on September 12, 2018, 11:58:22 am

author: Sceadwian
author_rank: Unknown
timestamp: September 12, 2018, 10:51:57 pm
content: What's the PWM frequency by the way? I'll simulate it, see what you got on your hands at least. This might not be horrible. But I can think of at least a half dozen different ways I'd do this to be much safer.

author: joeyjoejoe
author_rank: Frequent Contributor
timestamp: September 12, 2018, 11:41:42 pm
content: 2kHz for the PWM.I'm not sure I follow where the response time matters for a charger. It's about 400mS to go full swing. I didn't really design it to be responsive, as I figure a use case is battery goes in, the MCU starts off low and slowly adjust upwards based on what is required. As the battery approaches the cutoff voltage, it stops the charge. That was the thinking behind it. Any sudden/emergency anomalies could just abort the charge.While I am definitely at the edge (or beyond) what I know right now, the PFET backwards was a mistakeProbably staring at KiCad too long.Definitely open to your ideas and criticism! The actual charger doesn't matter. The journey is the fun part and the objective is to learn as much as possible which so far, has been quite successful with some of the nice members of this forum!Last night I watched the video below, which made me think some more about the principal, for both charging and discharging.