# [Nut-upsdev] Logic problem in NUT with upscode2 driver

Ted Mittelstaedt tedm at mittelstaedt.us
Wed Feb 19 17:50:41 UTC 2014

```Hi All,

I have what is probably a 12 year old (or older) Compaq R3000 UPS
plugged into a FreeBSD 8 system running NUT version 2.6.5

This UPS contains a total of 16 batteries in 2 banks of 8,
each battery is 6 volts and the bank produces 50 volts.

The UPS monitors battery voltage and the battery charger in
the UPS works like this.  For about 2 days it will apply a
charge/float/topping voltage of 55.2 volts to the batteries.
During that time the battery voltage measures 55.2 volts
both with a voltmeter on the batteries and as reported by
upsc, and the "calculated state of charge" of the UPS is 92.7%

(keep in mind that UPSes that are driven by upscode2 are unable
to report battery charge, so per the man page the upscode2 driver
synthesizes that value based on nominal battery min/max and current
battery voltage)

Anyway, then the UPS shuts off the battery charger.  The battery
voltage then starts dropping gradually until the battery voltage hits a
bit above 48v then the charger turns back on.  (this takes about 2 days)
For example, right now the battery voltage of each bank (as shown by
upsc and confirmed by a voltmeter) is 50.5 volts yet the calculated
state of charge is 64% even though the UPS is reporting
a nominal battery voltage of 48v and the batteries are 2 volts ABOVE
that.

The problem I am having appears to be the logic in the upscode2
driver.  For starters, the calculated state of charge is quite wrong.
48v on a bank of 8  6v batteries is normal, it IS fully charged, it
is NOT 64% charged.  50.5 volts on a 48v bank of batteries should be
almost 100% charged, not 64%.

Worse, however, is if there's a power failure right near the end
of the 2-days-off cycle.  That happened to me last week - it was a
short duration 15 second loss - and the upscode2 driver decided it
needed to issue a forced shutdown.

Very likely this was because upscode2 had decided the batteries
were dangerously low discharged.  But they were NOT discharged and
easily kept the servers up and online.

The UPS reports a battery max voltage of 56.4 and minimum voltage of
40 and nominal voltage of 48  (this is obviously for a given bank)

Now I do not know if OTHER upses that require upscode2 have battery
chargers that sense battery voltage like this, and that shut off. If
I disconnect the battery pack for a second and plug it back in, the
battery charger sees the loss of battery voltage and turns back on,
so it's obvious the charger is sensing battery voltage.

I am guessing the upscode2 driver is assuming that the battery charger
would be switched on all of the time.  55.2v is the correct float charge
voltage for a bank of 8 6v SLA batteries, although the driver is
calculating a state of charge of 92.7% when the charger is switched on
and the battery bank is at 55.2v.

I believe the upscode2 driver should be calculating a battery state
of charge of 97% with a max battery voltage of 56.4 and a measured
voltage of 55.2.  It should not be reporting 92%

And, I believe the upscode2 driver should NOT be calculating that
state of charge below 97% until the measured voltage drops below the
nominal voltage.

Below the nominal voltage - 48v - is where the calculated state of
charge should be dropping down below 90%

Can anyone tell me how to correct the logic in upscode2?  I can't have
the NUT software shutting servers down when the UPS has plenty of
runtime and capacity.

Thanks!!!
Ted

```