gfroerli / hardware

PCB and other hardware stuff in the watertemp project.
1 stars 0 forks source link

Add battery meter #4

Closed dbrgn closed 6 years ago

dbrgn commented 7 years ago

A battery meter would be really useful to track the battery voltage. (Maybe a regular ADC would be enough, but I think there are specialized chips for that.)

@rnestler do you think this should go into the first prototype? Do you have experience with these things?

rnestler commented 7 years ago

@rnestler do you think this should go into the first prototype? Do you have experience with these things?

I don't really have experience with this things. Also we have a Lio battery with a charging circuit and everything included, so maybe it can even provide this information?

An easy thing to do is just log the voltage of the battery, although the value of that is pretty low since Lio batteries have a flat charge/voltage curve.

dbrgn commented 7 years ago

with a charging circuit and everything included

It's only a protection circuit, it doesn't do battery level measuring. (There's no data wire attached :slightly_smiling_face:)

An easy thing to do is just log the voltage of the battery, although the value of that is pretty low since Lio batteries have a flat charge/voltage curve.

Yes, that would be possible. Our microcontroller probably has a built-in ADC, right?

On the other hand, getting a percentage/charge value would be pretty nice. What about these that provide battery voltage / charge / temperature monitoring?

If I understand it correctly, these chips must be always on, so 100uA / 93uA is way too much in our case, right? Or can they also be operated in sleep mode?

What about the third option?

Edit: More resources:

rnestler commented 7 years ago

LC709203F (3uA when operating)

I'm not sure if we can handle that one, it's MSL 3 (168 Hours). So we can't keep it for longer than 168 hours before soldering...

dbrgn commented 7 years ago

I see. But that's fine if we keep it in the original packaging until when we solder the boards, right?

rnestler commented 7 years ago

I see. But that's fine if we keep it in the original packaging until when we solder the boards, right?

Yes but it basically means we can only order as many as we are going to use right away, since we can't store them.

rnestler commented 7 years ago

If I understand it correctly, these chips must be always on, so 100uA / 93uA is way too much in our case, right? Or can they also be operated in sleep mode?

I think you understand correctly. The main problem is, that those IC's are designed for smart-phones and other portable devices, which have a rather high current usage and get charged quite often.

dbrgn commented 7 years ago

Hm, let's go with voltage measurements for now to keep it simple. That should be easy with the ADC, right?

The built-in 10 bit ADC supports the voltage range 0V-VDD. Since we get 3.3V from the LDO, we'd need voltage dividing resistors, correct?

rnestler commented 7 years ago

The built-in 10 bit ADC supports the voltage range 0V-VDD. Since we get 3.3V from the LDO, we'd need voltage dividing resistors, correct?

Correct!

dbrgn commented 7 years ago

Hm, the voltage divider also uses up current. @rnestler can you ask at work whether they have experience with this kind of problem?

dbrgn commented 7 years ago

Here's a potential solution with a transistor and a P-channel MOSFET: https://electronics.stackexchange.com/questions/64490/low-current-battery-monitoring#64491

img

What about that?

rnestler commented 7 years ago

Isn't it possible to do it simpler? Just use an N-MOSFET to connect the voltage divider to GND? Or is the ADC input leakage to big?

dbrgn commented 7 years ago

There are two comments on that answer regarding that:

@jme - the ADC and MCU is referenced to ground and so it makes sense to switch the higher voltage feed. If I used an N channel device there would still be a drain permanently through the top resistor and thru the parasitic diodes in the MCU when it is in sleep mode.

"Why not use a low side switch (e.g. N-ch FET or μC i/o pin)?" is a good question. Here's why. The battery voltage can be greater than Vcc. When the low side switch is opened, then the battery voltage will appear on the A/D pin. That could lead to the burnage of the A/D, or to a leakage of the battery through the protection diodes on the A/D pin.

I don't fully understand them though :)

rnestler commented 7 years ago

Ah of course, silly me. If we disable the voltage divider the ADC input will be at battery voltage, which may or may not damage it, but certainly lead to a current flowing through the ESD diode to VDD.

dbrgn commented 7 years ago

Ok, the schematic up there is a bit complex, but probably worth it. What do you think @rnestler? This should reduce the power requirements to the leak current of the FET and the BJT.

dbrgn commented 7 years ago

What about this one?

https://www.digikey.ch/products/de?keywords=MAX6430EGUS%2BT-ND

It's a very simple dual-level voltage monitoring chip. This one (MAX6430EGUS) is factory-fixed to signal low_H at 3.3V and low_L at 3.0V and uses active push-pull for signal indication. (Open drain variants also exist but aren't available on Digikey.) It could be used to send a warning message / add a warning flag below 3.3V and turn off the circuit at 3.0V. (There are also user-configurable versions, but those would require external resistors.) Here's the block diagram:

block diagram

If you look at the voltage curve of a typical high capacity 18650 cell, it looks like this:

img

With low current consumption, at 3.3V, 3000 mAh have already been consumed. At 3.0V, additional 250 mAh have been consumed.

I think this could be a good alternative to the voltage divider, since it only requires a single part, no external components, and also turns off the entire circuit below a certain voltage. This would allow us to use unprotected Li-Ion cells, which are shorter and cheaper. Price is quite high though, at 4.40 CHF per piece when buying 10.

Downside when not having a voltage divider is that we don't know the voltage at all. We could also do both.

dbrgn commented 7 years ago

Something like this, right @rnestler?

schematics

dbrgn commented 6 years ago

Ping @rnestler. Maybe @ubruhin also wants to take a look?

ubruhin commented 6 years ago

I guess your circuit does not work as expected, or at least not "well defined" ;) The voltage level of LBOL is referenced to the negative battery pin, but the voltage at the gate pin of the mosfet needs to be referenced to GND (which is not equal to the negative battery pin, it's floating as long as the mosfet is not yet switched on).

dbrgn commented 6 years ago

We'll use the voltage divider and a DMC2038LVT-7DICT-ND dual MOSFET.

dbrgn commented 6 years ago

Does this look good to you, @rnestler @ubruhin?

screenshot

Simulation at 5.2V:

Disabled: 104 nA

img

Enabled: 1.4 mA

img

Simulation at 3.3V

Disabled: 66 nA

img

Enabled: 873 uA

img

Total resistance: 15.34 kOhm.

The ADC reference is Vdd and we have 3.3V output from the LDO, so below that voltage we won't get usable results anymore (since the reference drops too). But that will only happen at the very end of the battery lifetime.