Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenUPS v1.9 firmware reports wrong battery current #516

Open
rmk92 opened this issue Jan 27, 2018 · 4 comments
Open

OpenUPS v1.9 firmware reports wrong battery current #516

rmk92 opened this issue Jan 27, 2018 · 4 comments
Labels
USB USB-HID encoding/LogMin/LogMax Issues and solutions (PRs) specifically about incorrect values in bitstream

Comments

@rmk92
Copy link

rmk92 commented Jan 27, 2018

OpenUPS v1.9 firmware appears to report positive values for the battery current whether the battery is charging or discharging. The USB poewr HID specifications say that the current is supposed to be positive when charging and negative while discharging.

In my case, I have 12V output, ,12V input, and a 12V 7Ah battery connected.

Investigating this issue (and other issues) with nut-2.7.2 with OpenUPS, it appears that the HID Report Descriptor is non-conformant with the HID specification in many respects:

  1. It fails to set an initial logical minimum/maximum values, leading to the first few report IDs being clamped to zero.
  2. It fails to set the units and unit exponent before the feature/input/output item that it corresponds with (leading to some fun where (eg) UPS.PowerStatus.ConfigVoltage is unit-less, UPS.PowerStatus.ConfigCurrent has units of Volts, UPS.PowerStatus.Temperature gets units of Amps, and the PresentStatus flags get units of Volts (meaning some get a value of 0.01).
  3. It fails to set the logical minimum/maximum for the UPS.PowerStatus.Current correctly - as mentioned above, this is reported as a signed value, but the logical minimum is zero, the logical maximum is 65535 - this should be min -32768 max 32767.

These issues can be fixed by arranging for nut to accept a replacement HID Report Descriptor with fixes in place, and this allows me to get sensible UPS.PowerStatus.Current values.

Other firmware issues:

  1. It reports UPS.PowerStatus.PresentStatus.BattteryPresent as zero even when a battery is connected.
  2. UPS.PowerStatus.Input.Current reports absurd values which suggest that this UPS is an energy creation unit - with an output current of 1.3A, battery current of 0A, the input current can be reported as 0.03A.

Note that UPS.PowerStatus.Output.Voltage and UPS.PowerStatus.Output.Current appear to have correct Units/UnitExp, with a logical min/max of 0/65535, so this is not the issue reported in another bug report on this device.

I am attempting to talk to Mini-Box.Com about this, but they have yet to reply to my emails earlier this week covering some of this. However, if they remain unresponsive, having a method where the HID report descriptor can be replaced may be the only real solution.

I'm including this here so that people in the NUT project are aware of the issues with this hardware.

@clepple
Copy link
Member

clepple commented Jan 27, 2018 via email

clepple pushed a commit that referenced this issue Feb 18, 2018
Some UPSes contain HID report descriptors that fail to correctly
describe the contents of reports.  For example, the OpenUPS
descriptor fails to set the units, logical maximum and logical
minimum before the corresponding `main item' as required by the HID
specification.

This commit allows an override HID report descriptor to be given to
usbhid-ups which replaces the one produced by the UPS, allowing the
report descriptors to be properly parsed.

With an appropriately fixed report descriptor, OpenUPS reports correct
battery current (+ve for charging, -ve for discharging.)

(see #516  -- @clepple)
clepple pushed a commit that referenced this issue Feb 18, 2018
Monitoring the input and output currents reported through upsc for an
OpenUPS device suggests that it is an energy creation device - the
power out is greater than the power into the system once the battery
is fully charged.

Analysis and measurement reveals several issues:

1. "UPS.PowerStatus.Output.Current" is scaled for NUTs "output.current"
   value, which should be the output current from the UPS.

   However, the value reported for "UPS.PowerStatus.Output.Current" is
   not the output from the UPS terminals to the load, but is the
   current into the LTC3780 buck-boost converter on the output.  The
   evidence for this is that with a known constant load, the current
   reported is dependent on whether we are using battery voltage or
   input voltage, and varies as one would expect if it were reporting
   the current supplied to the LTC3780.

2. "UPS.PowerStatus.Input.Current" is scaled for NUTs "input.current"
   value, which should be the input current to the UPS.

   The value reported for "UPS.PowerStatus.Input.Current" follows and
   matches the current supplied to the battery while charging is taking
   place, whether bulk charging or floating.

In order to fix these issues, the general principle of switch mode
power conversion is employed:

  Power out = Power in * Efficiency (where Efficiency is between 0..1)

The fix for "output.current" involves knowing whether the UPS was
powered from the battery or the input voltage (which is the voltage
fed to the LTC3780), calculating the power into the LTC3780 converter,
and using the above equation to refer it to the output.

Fixing "input.current" requires a similar process, except in reverse.
We calculate the power being supplied into the battery, and refer that
back to the input terminals, remembering to sum the current draw from
the LTC3780.

(see #516  -- @clepple)
@jimklimov jimklimov added USB USB-HID encoding/LogMin/LogMax Issues and solutions (PRs) specifically about incorrect values in bitstream labels Jan 12, 2022
@davidwkerr
Copy link

Inaction on this is a real pity. I have 4 openups units. Hardware is great. I have learned to ignore the input and output reported currents which are wrong. Mini Box does not seem to care.

@jimklimov
Copy link
Member

jimklimov commented Oct 11, 2022 via email

@jimklimov
Copy link
Member

FWIW, some work was done about general tech for hot-patching the presumed-broken HID Report Descriptors, most recently touched in PR #2718 - someone with the device and a bit of programming courage can check the fix_report_desc approach and define the needed logic in the respective subdriver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
USB USB-HID encoding/LogMin/LogMax Issues and solutions (PRs) specifically about incorrect values in bitstream
Projects
None yet
Development

No branches or pull requests

4 participants