networkupstools / nut

The Network UPS Tools repository. UPS management protocol Informational RFC 9271 published by IETF at https://www.rfc-editor.org/info/rfc9271 Please star NUT on GitHub, this helps with sponsorships!
https://networkupstools.org/
Other
2.12k stars 353 forks source link

[Question] APC Back-UPS Pro usbhid-ups possible to modify maximum charge voltage? #2222

Open initd0 opened 11 months ago

initd0 commented 11 months ago

I have an APC Back-UPS Pro 1200 - i modified it with 1 x 24V 100Ah Lithium ion battery. The stats of the battery as per manufacturer: Bulk: 28.8v Float: 27.2v Cut Off: 22.4v

Nut detects some of the following using usbhid-ups:

battery.charge: 100
battery.charge.low: 20
battery.charge.warning: 50
battery.date: 2001/09/25
battery.runtime: 183
battery.runtime.low: 120
battery.type: PbAc
battery.voltage: 26.5
battery.voltage.nominal: 24.0
device.mfr: American Power Conversion
device.model: Back-UPS RS 1200G
device.type: ups
driver.flag.ignorelb: enabled
driver.name: usbhid-ups
driver.parameter.pollfreq: 30
driver.parameter.pollinterval: 2
driver.parameter.port: auto
driver.parameter.synchronous: no
driver.version: 2.7.4
driver.version.data: APC HID 0.96
driver.version.internal: 0.41
input.sensitivity: low
input.transfer.high: 300
input.transfer.low: 156
input.voltage: 234.0
input.voltage.nominal: 230
ups.beeper.status: enabled
ups.delay.shutdown: 20
ups.load: 7
ups.mfr: American Power Conversion
ups.model: Back-UPS RS 1200G
ups.productid: 0002
ups.realpower.nominal: 720
ups.status: OL
ups.test.result: No test initiated
ups.timer.reboot: 0
ups.timer.shutdown: -1

The manufacturer told me that the battery must fully charge to 28.8v however the NUT software sees the voltage as OL, ie. fully charged to battery.voltage: 26.5. This is way below what its supposed to be and i cant leave the battery discharged like this.

Is it at all possible to increase this so it can charge it to 28.8v ? ive read about battvolts but im not sure if it will work for the driver im using.

On a sidenote: I have another one of the same UPS's using its original batteries (2 x 12v 9Ah) And with that one im using apcupsd and apcupsd is reporting: BATTV : 27.2 Volts NOMINV : 230 Volts NOMBATTV : 24.0 Volts NOMPOWER : 720 Watts

How is it possible that the same UPS is charging the batteries up to 27.2v but the one hooked up to NUT software is charging it up to 26.5v ?

Please advise? Thanks in advance

jimklimov commented 11 months ago

I can't really say here, only elaborate. Maybe @aquette had more practical experience with Li-Ion UPS hardware.

On one hand, NUT only reports what the devices tell it, and can set some variables or send commands. But the internals of how to charge the battery are on the UPS hardware or beyond - more so with Li-Ion batteries that typically have their own logic chips to manage the charge, temperature, amount of charging cycles survived, etc.

I see that current NUT sources do mention Li-Ion oriented nomenclature for battery.voltage.cell.max, battery.voltage.cell.min, battery.temperature.cell.max, battery.temperature.cell.min in the docs/nut-names.txt since NUT v2.8.0 release, but otherwise these do not seem to be represented in practical source files at this time. While at it, your 2.7.4 is pretty old - although that is likely not the problem here.

However, what a newer NUT could provide (2.8.1 or current git master) is the apc_modbus driver which would currently require a custom build of libmodbus with USB support - see https://github.com/networkupstools/nut/wiki/APC-UPS-with-Modbus-protocol for more details. Rationale behind this idea is that APC mostly downplayed support for USB HID and promoted ModBus instead in many devices.

All that said, a 24V nominal battery seems healthy at around 24V (even more in your case). Modern Li-Ion's also take care actively to not stay at 100% charge as that seriously reduces their lifetime.

Your UPS may be thoroughly confused by it overall, if it was wired and firmwared for PbAc and this is something else. Can't even tell the metadata right: battery.date: 2001/09/25 - it is not 22 years old I suppose (if it really is... oh well, bets are off for non-nuclear batteries of that age)?

jimklimov commented 11 months ago

Quick googling for https://www.google.com/search?client=firefox-b-d&q=li+ion+discharge+graph brings up quite a few images reminiscent of other battery types, in that you have a sharp decline from 100% charge to the practical plateau (roughly between 20% and 85-90% charge), near which the voltage stays for most of the time, and then it sharply drops to 0%. See e.g. https://siliconlightworks.com/li-ion-voltage for a graph and better worded details; they also discuss the longer-term charging cycles to keep the battery in shape.

Per https://www.powertechsystems.eu/home/tech-corner/lithium-ion-state-of-charge-soc-measurement/ the plateau of Li-Ion is more pronounced than in PbAc whose voltages are on decline with discharge and other electronics in the UPS account for that.

Finally, you've mentioned apcupsd probing your other UPS with the original-chemistry PbAc batteries, right? Is it possible for you to fire up apcupsd on the machine with this Li-Ion modification to check what it would report (they implemented ModBus a lot earlier than NUT did, so it is quite possible that over another protocol and data path, the UPS controller would tell other readings than it does over USB HID for us).

initd0 commented 11 months ago

@jimklimov thanks so much for your prompt reply.

So i took your advice and installed APCUPSD and as you can see below the BATTV is 26.5 Volts as well. Additionally i thought i should change the battery date by running apctest and it made a small difference in increasing TIMELEFT : 3.0 Minutes to TIMELEFT : 89.5 Minutes

APCUPSD report BEFORE changes of battery date:

APC      : 001,036,0865
VERSION  : 3.14.14 (31 May 2016) unknown
CABLE    : USB Cable
DRIVER   : USB UPS Driver
UPSMODE  : Stand Alone
MODEL    : Back-UPS RS 1200G
STATUS   : ONLINE
LINEV    : 228.0 Volts
LOADPCT  : 7.0 Percent
BCHARGE  : 100.0 Percent
TIMELEFT : 3.0 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME  : 0 Seconds
SENSE    : Low
LOTRANS  : 156.0 Volts
HITRANS  : 300.0 Volts
ALARMDEL : 30 Seconds
BATTV    : 26.5 Volts
LASTXFER : No transfers since turnon
NUMXFERS : 0
TONBATT  : 0 Seconds
CUMONBATT: 0 Seconds
XOFFBATT : N/A
SELFTEST : NO
STATFLAG : 0x05000008
BATTDATE : 2014-11-30
NOMINV   : 230 Volts
NOMBATTV : 24.0 Volts
NOMPOWER : 720 Watts

APCUPSD report AFTER changes of battery date:

APC      : 001,036,0866
VERSION  : 3.14.14 (31 May 2016) unknown
CABLE    : USB Cable
DRIVER   : USB UPS Driver
UPSMODE  : Stand Alone
MODEL    : Back-UPS RS 1200G
STATUS   : ONLINE
LINEV    : 227.0 Volts
LOADPCT  : 7.0 Percent
BCHARGE  : 100.0 Percent
TIMELEFT : 89.5 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME  : 0 Seconds
SENSE    : Low
LOTRANS  : 156.0 Volts
HITRANS  : 300.0 Volts
ALARMDEL : 30 Seconds
BATTV    : 26.5 Volts
LASTXFER : No transfers since turnon
NUMXFERS : 0
TONBATT  : 0 Seconds
CUMONBATT: 0 Seconds
XOFFBATT : N/A
SELFTEST : NO
STATFLAG : 0x05000008
BATTDATE : 2023-12-11
NOMINV   : 230 Volts
NOMBATTV : 24.0 Volts
NOMPOWER : 720 Watts

I didnt do battery calibration, because of the fact that the UPS already thinks the battery is fully charged at 26.5v Can i trick the UPS with NUT or APCUPSD into thinking that it needs to charge up to 28.8v ? Can i change/override the battery.voltage parameter from 26.5v to 28.8v so it can start charging?

If this is not possible, do you think i should take my battery to the supplier and ask them to fully charge it, so that when i reconnect it to the UPS it will see the higher voltage limit to 28.8v ? or will that not help and the UPS will push it back down to 26.5v ?

jimklimov commented 11 months ago

Regarding the changed "time left" - I wonder if the UPS controller somehow includes battery age into estimations how long it would hold at given load and voltage/charge-level.

Curiously, the two programs reported a different battery date by the way. I wonder if it is internally some offset converted from a given starting date (which would differ between NUT and apcupsd, and then which one is correct?): "2001/09/25" vs "2014-11-30"...

As for "telling the UPS to charge the battery to X Volts" - I don't think this is possible generally. Really depends on the hardware though, both on the controller (if it accepts such requests - e.g. you can tell a laptop to stop charging at 90%) and on the battery (as I noted, Li-Ion ones often have their own smarts to stay safe and live long, and might just disconnect the inflow circuit from stressing the battery cells even if the UPS itself presses on to try charging it more and more).

With the 24V nominal, the higher voltage after charging seems good enough. I suppose the 28.8V range specifies that it can/should not be higher - or, say, something would explode. For example, with PbAc "12V" batteries the full charge is closer to 13.5, maybe up to 14V (and quickly drops to ~12V and stays long around it when running on battery). However, cases close to 15V are possible with pulse charging used to desulphurize the internal contacts after salts grow on them and chemistry becomes inefficient - but that is done with special hardware and generally risks boiling the acid and ending badly.

But hey, it never hurts to ask the vendor - e.g. about what exactly they meant with that number, and if it is expected to be casually reachable by your battery or not.

Regarding calibration - one is always recommended after battery changes (including their aging without replacement), so the UPS controller itself knows how to predict the run-time on battery, how to translate voltages to percents, etc.

And if (guessing here) this UPS model's hardware/firmware was built to expect PbAc numbers (limits, charge/discharge curves, etc.), and if the Li-Ion being there is not directly supported by the UPS vendor, then it may be just misinterpreting something internally through formulas wrong for the use-case. Calibration might then help for it to factor some different values into some calculations...

initd0 commented 11 months ago

@jimklimov i just noticed something strange today.

NUT is now reporting battery.voltage: 26.8 - from the day before yesterday where it was reporting 26.4v (excluding yessterday since there was a power outtage) Clearly this means its still charging but its taking a long time (since its only charging at 1.5A which im fine with), the problem is.. im having a hard time understanding how on earth its charging if NUT is also reporting ups.status: OL and not ups.status: OL CHRG - is this a bug in 2.7.4? or is this normal behavior?

initd0 commented 11 months ago

But then again it still showed STATUS : ONLINE for when i checked it with APCUPSD - so that also shows it was not charging. But evidently it seems like it is charging... so im quite confused

jimklimov commented 11 months ago

It depends on what the device reports. Usually UPSes raise the "CHRG" flag when they are actively charging - they know they have to catch up on tens of percents and intentionally plan to do so (open the relays for pushing the Amps into the battery). I guess if the transformer is still connected to the battery and it is in the mood to accept more charge (in case of Li-Ion - perhaps if its chip detected the battery is in the right temperature range after the initial burst), it might soak some more in.

The "Online" term in UPS world is largely overloaded. For some UPS designs it may mean that the wall power is completely decoupled from the load - it is charging the battery on one side and depleting it on the other. Generally such batteries live less, but there are benefits like zero time to switch in an outage, always sine-wave on the inside circuit, surges and noise (like motors or luminescent lamps nearby) don't have a direct path to pass to your sensitive protected devices, etc. The significant "opposite" for this meaning is "line-interactive" where the load is fed from the wall, battery also. If the wall is out, there's some non-zero time to flip the switches (mechanical relays) and begin feeding the load from inverters. Generally the gap of no power is smoothed out by modern PSUs and their capacitors, but some devices can be upset about those 10ms or so of no juice flowing.

It also means UPS says it is "connected to wall power", "is on (utility) line/feed" in most of the NUT codebase.

For some devices there are (validly or confusingly) combos like "OL DISCHRG" - sometimes I'd say these are vendor bugs, in other cases reasonable representations of calibration (it is plugged in, and it is discharging the battery now). In some it is suspected to be an UPS "hovering" the battery charge between 100% and 90% and back (at least some laptops/phones do), more so in LiIon case.

I'd say that as long as it hovers considerably over the nominal healthy value, and if in load-testing or calibration it does protect your system for an expected time range (generally, at least as much as a shutdown needs after the "critical" alarm is raised), don't obsess much over it. This bubble is not intended to be over-stretched so it would burst :)