Author Topic: Inconsistent Battery Reading under load  (Read 4385 times)

0 Members and 1 Guest are viewing this topic.

Offline trilerianTopic starter

  • Regular Contributor
  • *
  • Posts: 163
  • Country: us
Re: Inconsistent Battery Reading under load
« Reply #25 on: February 05, 2024, 07:52:01 pm »
I'll redesign with a differential amplifier.  Just to make sure, use the differential op-amp and not an analog comparator?

EDIT:  Also, I assume I will want to filter the input to the differential op-amp and not the other way around, filtering the output?
You definitely don't need a comparator instead of opamp.
And I'm not sure you need a filter.

Filter is for the pwm frequency of 490Hz.  The literature I am reading on the difference amplifier says it has a gain of 1, so the output will be up to 4.2V, 8.4V - 4.2V.  I need it down to less than 4.096V since that is the top end of my LM4132 reference I a using.
 

Offline Manul

  • Super Contributor
  • ***
  • Posts: 1109
  • Country: lt
Re: Inconsistent Battery Reading under load
« Reply #26 on: February 05, 2024, 08:36:35 pm »
I'll redesign with a differential amplifier.  Just to make sure, use the differential op-amp and not an analog comparator?

EDIT:  Also, I assume I will want to filter the input to the differential op-amp and not the other way around, filtering the output?
You definitely don't need a comparator instead of opamp.
And I'm not sure you need a filter.

Filter is for the pwm frequency of 490Hz.  The literature I am reading on the difference amplifier says it has a gain of 1, so the output will be up to 4.2V, 8.4V - 4.2V.  I need it down to less than 4.096V since that is the top end of my LM4132 reference I a using.

You can set gain of less than one, you can set any arbitrary gain just by choosing ratio of resistors. You want filter at the output: series resistor and capacitor to ground. Don't put filter at the input (or feedback path), unless you know very well what you are doing, because you risk ruining CMRR or something else bad. CMRR might or might not be important, but better stay on safe side unless you know for sure. Also I suggest to use 1% resistors or better for the same reason.
 
The following users thanked this post: Vovk_Z, trilerian

Offline trilerianTopic starter

  • Regular Contributor
  • *
  • Posts: 163
  • Country: us
Re: Inconsistent Battery Reading under load
« Reply #27 on: February 06, 2024, 11:51:47 pm »

You can set gain of less than one, you can set any arbitrary gain just by choosing ratio of resistors. You want filter at the output: series resistor and capacitor to ground. Don't put filter at the input (or feedback path), unless you know very well what you are doing, because you risk ruining CMRR or something else bad. CMRR might or might not be important, but better stay on safe side unless you know for sure. Also I suggest to use 1% resistors or better for the same reason.

So I need to pick an op-amp to start with.  Presumably one with high impedance so I can run high value resistors to it?  What value resistors should I be looking at here?  100k, higher?  Bandwidth, while that is listed as an important doesn't seem like an issue with the adc of the 328P being 125kHz.  What does seem to be an issue is the output current, I see a lot of these over 40mA.  So I need to make sure I stay under 40mA, right, 328P input current limit on a pin is 40mA?  Although a filter on the output may take up some of that?

So, I need 2 or can I do a 2 channel op amp?  And it is fine, I assume, to use the junction between the +/- for the cells in series to measure from.  One going from + to the junction, the other going from the junction to -? I have no issue measuring from the junction to - now, so I assume it is fine, and probably will work better than subtracting.  Although in its own way that is what it is doing, lol. 


Would something like https://www.mouser.com/datasheet/2/268/MCP6496_Data_Sheet_DS20006758-3078050.pdf work?  Better choice available?
Thanks
 

Offline trilerianTopic starter

  • Regular Contributor
  • *
  • Posts: 163
  • Country: us
Re: Inconsistent Battery Reading under load
« Reply #28 on: February 07, 2024, 02:12:18 pm »
I added the attached to my schematic.  If I understand what I have read I will create a ratio of R3/R1.  R3=10k, R1=11K5 (not sure on these values).
Then this will measure the difference between the + and - inputs.  + will be 4.2V (highest) and - will be 0.  There are 2 channels to measure both cells.  The output then has a lowpass filter with cutoff of 31Hz to make the output a DC line from the 490Hz pwm.  I'm still not sure on my choice of op-amp. I would appreciate feedback on this.

Thanks
 

Offline Vovk_Z

  • Super Contributor
  • ***
  • Posts: 1419
  • Country: ua
Re: Inconsistent Battery Reading under load
« Reply #29 on: February 07, 2024, 04:48:33 pm »
So I need to pick an op-amp to start with.  Presumably one with high impedance so I can run high value resistors to it? 
I guess you have to look at power supply voltage available for your opamp (that's first restriction). And consider input voltage range.
If you want to measure voltage from zero then look for opamps who can work rail-to-rail, at least for input ('RtoR Input ').
« Last Edit: February 07, 2024, 04:52:36 pm by Vovk_Z »
 

Offline Vovk_Z

  • Super Contributor
  • ***
  • Posts: 1419
  • Country: ua
Re: Inconsistent Battery Reading under load
« Reply #30 on: February 07, 2024, 05:07:22 pm »
I'm still not sure on my choice of op-amp. I would appreciate feedback on this.
[/quot
Looks like ok. I don't know about availability this opamp but seems it is available for ordering. It has RtoR input and output. Since your supply voltage is 5 VDC (and not higher) then it can be fine.
 

Offline trilerianTopic starter

  • Regular Contributor
  • *
  • Posts: 163
  • Country: us
Re: Inconsistent Battery Reading under load
« Reply #31 on: February 07, 2024, 06:14:37 pm »
Looks like ok. I don't know about availability this opamp but seems it is available for ordering. It has RtoR input and output. Since your supply voltage is 5 VDC (and not higher) then it can be fine.

Are 1% resistors good enough, or should I use 0.5 or 0.1%?  I generally get the 1% for most parts, but kind of feel this is a more important component to get really close on values, but mainly for the math.  I can measure these on my 4 wire meter to get actual values.

What I am curious about is how the input impedance of the resistors affects the output?  The 328P like less than 10k on the adc pins.  So if I have a 10K/12K divider essentially on the input that is 5455 \$\Omega\$, if that is transferred to the output plus the 5K1 \$\Omega\$ after the output, would put be just above the 10K.  But there is the filter cap that may help a bit too.   


EDIT:  Also reading through the data sheet it says the VDD needs bypass capacitors.  I don't see any values given for the bypass.  Should 100nF be ok?
« Last Edit: February 07, 2024, 06:39:29 pm by trilerian »
 

Offline Vovk_Z

  • Super Contributor
  • ***
  • Posts: 1419
  • Country: ua
Re: Inconsistent Battery Reading under load
« Reply #32 on: February 07, 2024, 08:34:21 pm »
1) rated resistor accuracy depends on you. You may use 1% but select them manually with DMM, or use 0.1 % and select manually with good DMM too. The difference is that with 1 % initial accuracy you definitely have to select identical but with 0.1 % initial accuracy they might  be good enough without additional selection. And you don't need 4-wire ohmmeter to measure 10 k resistors (just usual 4-5 digit DMM).
2) Output impedance of your diffamp is 5k1 for DC, and less for AC because of a capacitor. If ig is too much - use another opamp as buffer.
3) 100 nF is typically ok for opamp bypass until other is clearly stated.
« Last Edit: February 07, 2024, 08:36:45 pm by Vovk_Z »
 
The following users thanked this post: trilerian

Offline Manul

  • Super Contributor
  • ***
  • Posts: 1109
  • Country: lt
Re: Inconsistent Battery Reading under load
« Reply #33 on: February 07, 2024, 09:04:51 pm »
So I need to pick an op-amp to start with.  Presumably one with high impedance so I can run high value resistors to it?  What value resistors should I be looking at here?  100k, higher?  Bandwidth, while that is listed as an important doesn't seem like an issue with the adc of the 328P being 125kHz.  What does seem to be an issue is the output current, I see a lot of these over 40mA.  So I need to make sure I stay under 40mA, right, 328P input current limit on a pin is 40mA?  Although a filter on the output may take up some of that?

I don't know what exactly you mean by high impedance op amp. I suppose you want resistors something like 30k and 10k (will give you gain of 1/3). Not too low, not too high. Bandwidth is not important, I would choose an op amp which has low current consuption and has good price. Faster ones often need more current and are pricier.

Output current is completely irrelevant. Your thought process here is completely wrong. 40mA limit is for 328P output. Input is really high impedance, so there is almost no current. You just need to make sure to not exceed ADC input voltage range. But if op amp is powered from same supply as 328P, that is impossible. For instance, it would be a danger to power op amp from 12V, while feeding it's output directly to MCU input which is powered from 5V.

I added the attached to my schematic.

Schematic is wrong. Remember: amplifier always uses negative feedback. So feedback from output must go to inverting input.

Are 1% resistors good enough, or should I use 0.5 or 0.1%?  I generally get the 1% for most parts, but kind of feel this is a more important component to get really close on values, but mainly for the math.

1% is minimum, but should be enough. Mainly it affects two things: accuracy of gain and CMRR. I don't think you need high CMRR in this aplication. And for accuracy, I don't think that you will gain much more by going 0.1%. Calculate or experiment.

What I am curious about is how the input impedance of the resistors affects the output?  The 328P like less than 10k on the adc pins.  So if I have a 10K/12K divider essentially on the input that is 5455 \$\Omega\$, if that is transferred to the output plus the 5K1 \$\Omega\$ after the output, would put be just above the 10K.  But there is the filter cap that may help a bit too.

Nothing on the input gets transfered to op amp output. Op amp output (in closed loop) always has very very low impedance. So only 5.1k of the output filter. Yes, you can say that ADC likes less than 10k, but 10k is not resistance, it's impedance. Filter cap has way enough low impedance.

Op amp bypassing is generally based on op amp bandwidth and frequency band of interest. In your case I would go more than 100n, like 1uF or more, for sure can't hurt.

Actually after reading your posts, I strongly suggest you prototype before producing a PCB.
 

Offline trilerianTopic starter

  • Regular Contributor
  • *
  • Posts: 163
  • Country: us
Re: Inconsistent Battery Reading under load
« Reply #34 on: February 07, 2024, 09:38:54 pm »

Schematic is wrong. Remember: amplifier always uses negative feedback. So feedback from output must go to inverting input.

[\quote]

Thanks, I was trying to figure out the inverting/ non inverting inputs.  I haven't had a design with op-amps yet, so wasn't sure which pin was which. I guess I didn't really understand what was meant by the inverting and non inverting inputs.  But it makes sense now. 





I really appreciate the advice so far, and I have been reading on op-amps  to try an understand them a bit more.  We'll se how this affects output under load.
 

Offline trilerianTopic starter

  • Regular Contributor
  • *
  • Posts: 163
  • Country: us
Re: Inconsistent Battery Reading under load
« Reply #35 on: February 08, 2024, 12:32:23 am »
I don't know what exactly you mean by high impedance op amp. I suppose you want resistors something like 30k and 10k (will give you gain of 1/3). Not too low, not too high. Bandwidth is not important, I would choose an op amp which has low current consuption and has good price. Faster ones often need more current and are pricier.

Output current is completely irrelevant. Your thought process here is completely wrong. 40mA limit is for 328P output. Input is really high impedance, so there is almost no current. You just need to make sure to not exceed ADC input voltage range. But if op amp is powered from same supply as 328P, that is impossible. For instance, it would be a danger to power op amp from 12V, while feeding it's output directly to MCU input which is powered from 5V.

I wasn't sure how high of values to choose for the input resistors, but it seems it doesn't matter much.  The only real thing that matters is the gain.  I need to be under 4.096V, I am using an external reference for the ADC, so while 5V won't hurt the pin, anything 4.096V and above just reads 1023.  So my choice of resistors are 11K5, 10K. 

At a max input of 4.35V this should reduce it to ~3.8V
Quote
Schematic is wrong. Remember: amplifier always uses negative feedback. So feedback from output must go to inverting input.

I updated my schematic and attached.

Quote
Nothing on the input gets transfered to op amp output. Op amp output (in closed loop) always has very very low impedance. So only 5.1k of the output filter. Yes, you can say that ADC likes less than 10k, but 10k is not resistance, it's impedance. Filter cap has way enough low impedance.

Op amp bypassing is generally based on op amp bandwidth and frequency band of interest. In your case I would go more than 100n, like 1uF or more, for sure can't hurt.

Thank you
 

Offline trilerianTopic starter

  • Regular Contributor
  • *
  • Posts: 163
  • Country: us
Re: Inconsistent Battery Reading under load
« Reply #36 on: February 08, 2024, 03:00:37 am »
I would like to bring back the subject of grounding the battery in this circuit.  Is this actually needed?  Using the difference amplifier there isn't a need for the batt - to be grounded, or at least I don't think so.  It will measure the difference between V1 and V2 no matter how far above ground V2 is.  If I am following  what I have read, the summing point is a virtual gnd created in the inverting amplifier, so the inputs are 0V.  Although I am a little confused how there isn't current flowing when the voltage is being dropped to 0.  But...  The point is I don't think the battery - needs to be connected to ground to measure the voltages here.  So what about the battery - being connected to ground for discharging?  The mosfets gates are controlled by the microcontroller, when the gates turn on a circuit is completed from the Batt - to the Batt + through an external resistor bank.  I am failing to see the need for a gnd reference here.  The current sensor is a hall sensor, so it isn't directly measuring the voltage of the battery, the voltage sensing isn't grounded to the battery, which I think is the point there.  Although the op amp itself is grounded.

I am attaching my full schematic again, with the difference amplifier update.  I would very much appreciate some clarity on the grounding.  If the battery - needs to connect to the ground plane, and why?

Thanks
 

Offline Manul

  • Super Contributor
  • ***
  • Posts: 1109
  • Country: lt
Re: Inconsistent Battery Reading under load
« Reply #37 on: February 08, 2024, 09:09:53 pm »
Batt- should be grounded, how else the circuit will close? Actually why would you put that current sensor (and fuse!) on the low side in series with mosfet source? That's awkward at best, may cause problems at worst. Put them to the high side. And draw schematic in a way, that n-ch mosfet source faces down, drain faces up. It's really confusing to read the way it is.
 

Offline trilerianTopic starter

  • Regular Contributor
  • *
  • Posts: 163
  • Country: us
Re: Inconsistent Battery Reading under load
« Reply #38 on: February 09, 2024, 12:55:08 am »
Batt- should be grounded, how else the circuit will close? Actually why would you put that current sensor (and fuse!) on the low side in series with mosfet source? That's awkward at best, may cause problems at worst. Put them to the high side. And draw schematic in a way, that n-ch mosfet source faces down, drain faces up. It's really confusing to read the way it is.

Going back to the start of the project.  A device was given to me to reverse engineer since the original maker wasn't making them anymore and wouldn't respond communication attempts.  So I did my best to reverse engineer the project with some help from this and other forums.  The lowside current sensor and fuse was pulled directly from his design.  Where I differ from the original design is I am using pwm to open the gate of the fets and allow current to pass between the external resistor bank and the battery.  The fets are not sinking current, well except for their IR, they are just connecting drain to source which connects the resistor bank.  I could place the current sensor and fuse between the Batt+ and one of the load terminals.  But back to the ground question.  I still fail to see why the Batt- has to be grounded to the rest of the circuit.  This seems isolated to me.  I know for certain if the fets were not involved, if I was just connecting the battery to the resistor bank with the current sensor to measure the current, it would work without the battery being grounded to the circuit.  I have this setup with a dyno using the same style current sensor. The dyno was purchased from a company, I didn't build it.   

Now, all that said...  I found out today, that the original designer decided to release a V2.  Maybe he found out I was making one, who knows.  But regardless, I'm not going to be able to release this before he does, so I am going to go back to the drawing board and redesign this properly.  At this point it is now for me and I want to build it right.  I bought a couple of huge linear mosfets to start with and I am going to move this off of the 328P and onto an esp32 or an stm32.  The mosfets I bought are IXTK90N25L2, which are pricey.  There is a lot of stuff I will have to change, but I am going to keep the difference amplifier.  I may be building this for the next year, lol.  But I am enjoying learning how to do it and that is worth all the money and time I have and will put into it.

Moving to the ESP32 is for twofold reasons, one, my program space is at 97% with the 328P and there was still more I wanted to add.  And, to force myself into another MCU since I have only been using the 328P so far. 
 

Offline trilerianTopic starter

  • Regular Contributor
  • *
  • Posts: 163
  • Country: us
Re: Inconsistent Battery Reading under load
« Reply #39 on: February 09, 2024, 03:58:27 am »
So, interesting tidbit about this circuit as well.  I asked awhile back how to implement reverse polarity protection for the battery.  I asked what would happen if I plugged the battery in backwards.  I think someone said something about a full bridge rectifier.  And then the "just use polarity plugs", which I was doing already.  But the battery connections are 5mm bullets and they can get plugged in accidentally.  So one fine day in the middle of the night, I decided to see what happens if you plug the battery in backwards.  Well, nothing popped.  My current sensor sensed current in the opposite direction of normal use, I am using a bi directional sensor.  I know it sensed in the opposite direction because the analog reading was below 512 instead of above.  Now, obviously the load has to  be plugged in for it to happen, without the load plugged in, you are just touching the positive of the battery to the ground of the circuit, and nothing will happen because there is no ground for current to flow.  Back to the reverse polarity.  When I connected it in reverse the mosfets heated up a lot faster than normal, so it is still bad, but it didn't blow anything up.  So this is another reason why I think the battery doesn't have to be grounded to the rest of the circuit.  When it was connected in reverse polarity and current was flowing it didn't affect the rest of the board. 

I am attaching a couple of pics of the actual board.  I have drawn on the top side pic.  When the mosfet is turned on current flows (old belief) from the higher potential (+), through the load and to the LOAD pad on the pcb, this is via stitched to the pad on the bottom which is connected to the drain of the mosfet, from there is goes through the mosfet and to the source which is on top of the pcb, through the fuse then the current sensor and finally to the lower potential (-) of the battery.  I seperated the drain and the source on the top and bottom of the pcb because the amount of current the traces carry can be up to 45A.  According to a chart I looked at, I needed 30mm traces for 40A and a 30°C temp rise. I didn't know how to accomplish that except to put one of the traces on the bottom.  I chose the drain on the bottom because the source has the fuse.   

Despite the design flaws, this device actually works pretty well.  And to alert the user of reverse polarity plug in, the screen flashes all red and in big white letters it says battery backwards, it flashes for 1 second at a time until the reverse polarity issue has been fixed, or the mosfets burn up and current flow stops.  I'm using the reverse current flow as the condition to flash the screen.  I do have proper reverse polarity protection via a mosfet on VIN as well, but when that is plugged in backwards, nothing happens or turns on. 

 

Offline Vovk_Z

  • Super Contributor
  • ***
  • Posts: 1419
  • Country: ua
Re: Inconsistent Battery Reading under load
« Reply #40 on: February 09, 2024, 09:49:21 am »
or the mosfets burn up and current flow stops.
It'll take some time to fully burn a MOSFET into nothing. Most semiconductors make a short circuit when they die, so you'll still have a path for a current. And still, a leftover (burned textolite, etc) is conductive. So there is a risk of overheating a battery and a battery fire.
If short circuit current is limited by a resistance of an additional resistive load within a rated battery current limits then ok.
(When you apply an opposite voltage to the closed MOSFET its body diode starts to conduct a current. That's why you see hot MOSFETs).
« Last Edit: February 09, 2024, 09:51:08 am by Vovk_Z »
 

Offline PA0PBZ

  • Super Contributor
  • ***
  • Posts: 5129
  • Country: nl
Re: Inconsistent Battery Reading under load
« Reply #41 on: February 09, 2024, 11:20:37 am »
I may be totally wrong here so I'll leave my coat on to be able to make a quick escape but... looking at the 3rd picture you posted you are bundling the load and sense wires? I wouldn't be surprised if that is where your problem originates  :-//
Keyboard error: Press F1 to continue.
 

Offline trilerianTopic starter

  • Regular Contributor
  • *
  • Posts: 163
  • Country: us
Re: Inconsistent Battery Reading under load
« Reply #42 on: February 09, 2024, 01:56:44 pm »
I may be totally wrong here so I'll leave my coat on to be able to make a quick escape but... looking at the 3rd picture you posted you are bundling the load and sense wires? I wouldn't be surprised if that is where your problem originates  :-//

I don't think I am.  The sensor wires are completely separate from the load wires starting at the connectors.   The consensus is that somehow the voltage dividers and the battery gnd both being connected to the ground plane causes the difference I see.  I'm not sure how that exactly works.  But I was told it wasn't a true 4 wire connection because of the voltage divers ground, it was more of a 3 wire connection.  The fix is to use a difference amplifier instead of the voltage divider to measure the voltage with.  I have now designed that into the circuit.  This essentially eliminates the voltage sense leads being connected to ground, except through the battery ground.

 Now I am trying to understand why the battery - needs to be connected to the pcb ground.
 When going through the current flow of the design, I don't see any current from the battery needing to go through the pcb ground.  It is limited to the specific traces used for the battery circuit.  The only reason I can think that the battery ground would need to be connected to the pcb ground is if the batt- needs to be at the same potential as the pcb lower potential.  Which is this case I don't think it needs to be.  Voltage sensing of the battery is being done with a difference amplifier.  After my reading on those the input to the divider is theoretically zero, and the output ends up being a potential difference between the inverting and non inverting leads.  The current sensor doesn't care about the ground connection of batt-,  and I don't think the mosfets do either, when their gates turn on, current flows from the higher potential to the lower potential. 



or the mosfets burn up and current flow stops.
It'll take some time to fully burn a MOSFET into nothing. Most semiconductors make a short circuit when they die, so you'll still have a path for a current. And still, a leftover (burned textolite, etc) is conductive. So there is a risk of overheating a battery and a battery fire.
If short circuit current is limited by a resistance of an additional resistive load within a rated battery current limits then ok.
(When you apply an opposite voltage to the closed MOSFET its body diode starts to conduct a current. That's why you see hot MOSFETs).

That is where the fuse is supposed to come in.  If the mosfet internal shorts and gets stuck closed the voltage drop across the load will cause a current around 70-80A.  The fuse is a schurter 50A fast blow fuse, although I'm not quite sure how long that is supposed to take to blow.  I will admit the safety features need more work.  For one, the fuse would never blow if this were a 1S lipo, and if a 2s lipo is discharged enough, it wouldn't supply enough voltage under the load to create over a 50A current flow either.  This is another reason why I am going to change this to the linear fet sinking the current.  If the fet creates an internal short there is no load at all for the battery to go through and it is a true short.  Current theoretically goes infinite and the fuse should blow. 
 

Offline Manul

  • Super Contributor
  • ***
  • Posts: 1109
  • Country: lt
Re: Inconsistent Battery Reading under load
« Reply #43 on: February 09, 2024, 03:02:01 pm »
Now I am trying to understand why the battery - needs to be connected to the pcb ground.
 When going through the current flow of the design, I don't see any current from the battery needing to go through the pcb ground.  It is limited to the specific traces used for the battery circuit.  The only reason I can think that the battery ground would need to be connected to the pcb ground is if the batt- needs to be at the same potential as the pcb lower potential.  Which is this case I don't think it needs to be.  Voltage sensing of the battery is being done with a difference amplifier.  After my reading on those the input to the divider is theoretically zero, and the output ends up being a potential difference between the inverting and non inverting leads.  The current sensor doesn't care about the ground connection of batt-,  and I don't think the mosfets do either, when their gates turn on, current flows from the higher potential to the lower potential.

You are still insisting, that ground is not needed. To be frank, your schematic is drawn horribly. The purpose of schematic is to make all relations between components and circuit blocks as clear as possible. Yours fails at that. Well drawn schematic makes even a complex design easy to perceive, bad schematic obfuscates even the most obvious and simplest circuits. I believe because of that schematic you have (kinda self-inflicted) confusion. See the image attached. Battery and load is in series, so you can connect them in two different ways. If you call circuit on the right "not connected to ground", ok, that's fair. I agree, technically speaking, it's not connected to ground. But the circuit on the right has a potential issue, that the battery common mode voltage is flying up and down when mosfet is switching. That will introduce extra and totally unjustified common mode noise to you kelvin sense wires. So the normal way of connecting things is left side circuit.

Now I will redirect your question back to you , why Batt- needs to be connected to circuit ground?
 
The following users thanked this post: Vovk_Z

Offline trilerianTopic starter

  • Regular Contributor
  • *
  • Posts: 163
  • Country: us
Re: Inconsistent Battery Reading under load
« Reply #44 on: February 09, 2024, 06:05:27 pm »
You are still insisting, that ground is not needed. To be frank, your schematic is drawn horribly. The purpose of schematic is to make all relations between components and circuit blocks as clear as possible. Yours fails at that. Well drawn schematic makes even a complex design easy to perceive, bad schematic obfuscates even the most obvious and simplest circuits. I believe because of that schematic you have (kinda self-inflicted) confusion. See the image attached. Battery and load is in series, so you can connect them in two different ways. If you call circuit on the right "not connected to ground", ok, that's fair. I agree, technically speaking, it's not connected to ground. But the circuit on the right has a potential issue, that the battery common mode voltage is flying up and down when mosfet is switching. That will introduce extra and totally unjustified common mode noise to you kelvin sense wires. So the normal way of connecting things is left side circuit.

Now I will redirect your question back to you , why Batt- needs to be connected to circuit ground?

I wasn't insisting that the Batt- didn't have to be grounded.  I was asking why it needed to be because I didn't understand why it needed to be.  The whole conversation started with this is an issue due to the grounding of the 4 wire connection and Batt-, essentially being a 3 wire connection.  Which I still don't understand, but there is a whole world of electronics that I don't understand.  Sometimes you just fix what someone tells you to fix.  But in light of the issue, I am trying to understand why Batt- needs to be grounded.  This makes no difference in whether or not I add the difference amplifier.  I think the difference amplifier is a more elegant solution to a voltage divider and want to incorporate it.  I'm just looking for understanding, that is all.

Also, sorry about my schematic, I'll just leave it as I am a beginner,  posting in the beginner forum, and will make bad mistakes and draw bad schematics.  All I can do is try to improve on them as I learn more.


EDIT:  And I really do appreciate the help, and will go back and try to update my schematic. 
 

Offline Manul

  • Super Contributor
  • ***
  • Posts: 1109
  • Country: lt
Re: Inconsistent Battery Reading under load
« Reply #45 on: February 09, 2024, 08:45:43 pm »
Sorry for being a little harsh. You know, they say good teaching should involve either jokes or harshiness, then things sink into head much better. I guess I'm out of jokes today. Sort of like "I have come here to chew bubblegum and kick ass. And I'm all out of bubblegum."

The whole conversation started with this is an issue due to the grounding of the 4 wire connection and Batt-, essentially being a 3 wire connection.  Which I still don't understand

Take a look at picture 1. Battery, positive and negative wires with their own resistance and a load at the end. The reason you don't measure 10V at the load is because both positive and negative wire have voltage drop (~100mV on each). So if you need accurate voltage measurement, that sucks.

You say alright, I will add independent sense wires right at the battery to avoid issue with power wires droping voltage under load. Picture 2. Works like a charm. Even though sense wires also have resistance, but the current is zero, so no voltage drop. It is litterally like measuring right at the battery terminals with a multimeter.

Now because of circuit implementation you join ends of power negative wire and sense negative. Picture 3. Note that what you get is essentially power negative wire and sense negative wire in parallel. Two wires in parallel is essentially one wire! So load current now also flows through negative sense wire, it has voltage drop and you have measurement error.

I am trying to understand why Batt- needs to be grounded.

This comes from the fact that you use a directly driven mosfet for switching. Imagine for a moment that you use a relay instead. In a relay control coil and contacts are isolated. So you can drive the relay with your MCU and relay contacts are floating relative to MCU ground. Their are independent, not referenced to anything else. It would work very nice, just slow and contacts would burn with time.

So you use a mosfet. Mosfet is controlled by the votage between gate and source. So you connect source to ground (0V) and switch voltage at gate. Nice. But notice that mosfet source terminal is used both for control and as one of it's "contacts" (continuing relay analogy, another "contact" is drain). So you have no isolation. So anything what mosfet is switching is inevitably referenced to the circuit which controls it.

There are isolated mosfet driving options. Those include using gate drive transformer, optocoupler, solid state isolated gate driver (last two require isolated power supply to power the isoltage side). If you implement something like that, you have floating mosfet switch. But don't do that, that's unjustified and too complicated for the task.
« Last Edit: February 09, 2024, 08:57:03 pm by Manul »
 
The following users thanked this post: tooki, Vovk_Z, trilerian

Offline trilerianTopic starter

  • Regular Contributor
  • *
  • Posts: 163
  • Country: us
Re: Inconsistent Battery Reading under load
« Reply #46 on: February 10, 2024, 12:38:35 am »

Now because of circuit implementation you join ends of power negative wire and sense negative. Picture 3. Note that what you get is essentially power negative wire and sense negative wire in parallel. Two wires in parallel is essentially one wire! So load current now also flows through negative sense wire, it has voltage drop and you have measurement error.

Thank you for that explanation.  I did not think of the negative sense wire being in parallel as I didn't think there should have been current running through the ground plane


Quote
This comes from the fact that you use a directly driven mosfet for switching. Imagine for a moment that you use a relay instead. In a relay control coil and contacts are isolated. So you can drive the relay with your MCU and relay contacts are floating relative to MCU ground. Their are independent, not referenced to anything else. It would work very nice, just slow and contacts would burn with time.

So you use a mosfet. Mosfet is controlled by the votage between gate and source. So you connect source to ground (0V) and switch voltage at gate. Nice. But notice that mosfet source terminal is used both for control and as one of it's "contacts" (continuing relay analogy, another "contact" is drain). So you have no isolation. So anything what mosfet is switching is inevitably referenced to the circuit which controls it.

And thank you again, that makes sense. 


I'm going to mull this over a bit more, and I'll probably have more questions.  But that does help clear that up a little.

Thank you
 

Offline trilerianTopic starter

  • Regular Contributor
  • *
  • Posts: 163
  • Country: us
Re: Inconsistent Battery Reading under load
« Reply #47 on: February 20, 2024, 01:18:40 am »
The op amp circuit is not working at all.

I am going to try to explain what voltages are where and I have made some screenshots, but they are kind of bad...

Channel 2, (channel 1 inverting input not connected, non inverting is connected since it is the junction between the 2 cells).  Channel 2, place low potential probe on a ground, connect ground of battery to the circuit as well because there is a potential difference.  Ok.  With the high potential probe, measure the non inverting input before any resistors (battery ground).  0V - Ok, good.  Measure the inverting input before any resistors, cell 1.  3.85V - ok, good, storage charge.  Measure non inverting at op amp channel 2 input.  3mV.  Hmm, this should still be zero...  Ok, measure inverting op amp channel 2 at input.  1.79V.  And measure channel 2 output, 3.17mV. 

The op amp I chose is:
MCP6497T-E/SN
https://www.mouser.com/datasheet/2/268/MCP6496_Data_Sheet_DS20006758-3078050.pdf

I am completely lost... 
I'm going to try to figure out how to use ltspice and see if it can help.  But I am lost.
Thanks


 

Offline Manul

  • Super Contributor
  • ***
  • Posts: 1109
  • Country: lt
Re: Inconsistent Battery Reading under load
« Reply #48 on: February 20, 2024, 04:41:43 pm »
I think you have your input polarity wrong going into difference amplifier. Non inverting (+) input branch must be connected to the positive side of your battery, inverting (-) must be connected to negative side (I mean, relative potential). Man, you need to always double check these things. Easiest is probably to just rewire the cable.
 

Offline trilerianTopic starter

  • Regular Contributor
  • *
  • Posts: 163
  • Country: us
Re: Inconsistent Battery Reading under load
« Reply #49 on: February 20, 2024, 05:15:29 pm »
I think you have your input polarity wrong going into difference amplifier. Non inverting (+) input branch must be connected to the positive side of your battery, inverting (-) must be connected to negative side (I mean, relative potential). Man, you need to always double check these things. Easiest is probably to just rewire the cable.

So higher potential goes to the non inverting, and lower potential goes to the inverting inputs?  The inverting input has the feedback and the non inverting has the divider to gnd?



I have attached a schematic of the part to verify.

Thanks

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf