Discussion:
[Nut-upsuser] Cyberpower Value1200E might not need 0.667 battery scaling
Matthew Stapleton
2014-08-08 02:18:55 UTC
Permalink
I just got a Cyberpower SOHO Value 1200 ELCD UPS and even with nut
2.7.2, it appears to report battery voltage too low due to the battery
scaling function (In drivers/cps-hid.c). Even though the ups has usb
id: 0764:0501, UPS.PowerSummary.Voltage reports 26.6 for the 24V
batteries so when the 0.667 battery scale is applied that goes down to
17.7V.

upsc output:
battery.charge: 100
battery.charge.low: 10
battery.charge.warning: 20
battery.mfr.date: CPS
battery.runtime: 3012
battery.runtime.low: 300
battery.type: PbAcid
battery.voltage: 17.7
battery.voltage.nominal: 24
device.mfr: CPS
device.model: Value1200E
device.type: ups
driver.name: usbhid-ups
driver.parameter.offdelay: 20
driver.parameter.ondelay: 1
driver.parameter.pollfreq: 30
driver.parameter.pollinterval: 2
driver.parameter.port: auto
driver.version: 2.7.2
driver.version.data: CyberPower HID 0.3
driver.version.internal: 0.38
input.transfer.high: 0
input.transfer.low: 0
input.voltage: 235.0
input.voltage.nominal: 230
output.voltage: 239.0
ups.beeper.status: enabled
ups.delay.shutdown: 20
ups.delay.start: 1
ups.load: 11
ups.mfr: CPS
ups.model: Value1200E
ups.productid: 0501
ups.realpower.nominal: 720
ups.status: OL
ups.test.result: No test initiated
ups.timer.shutdown: -60
ups.timer.start: -60
ups.vendorid: 0764

Full usb descriptor from lsusb:
Bus 002 Device 016: ID 0764:0501 Cyber Power System, Inc. CP1500 AVR UPS
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor 0x0764 Cyber Power System, Inc.
idProduct 0x0501 CP1500 AVR UPS
bcdDevice 0.01
iManufacturer 3 CPS
iProduct 1 Value1200E
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 34
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 50mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 0 No Subclass
bInterfaceProtocol 0 None
iInterface 0
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.10
bCountryCode 33 US
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 518
Report Descriptors:
** UNAVAILABLE **
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 bytes
bInterval 10
Device Status: 0x0000
(Bus Powered)
--
Matthew Stapleton
Email: matthew4196 at gmail.com
Charles Lepple
2014-08-08 02:52:31 UTC
Permalink
I just got a Cyberpower SOHO Value 1200 ELCD UPS and even with nut 2.7.2, it appears to report battery voltage too low due to the battery scaling function (In drivers/cps-hid.c). Even though the ups has usb id: 0764:0501, UPS.PowerSummary.Voltage reports 26.6 for the 24V batteries so when the 0.667 battery scale is applied that goes down to 17.7V.
I'm wondering if that scale factor is only needed for that one Dynex UPS model. We should be able to do a string match, which is ugly, but should work (especially if we default to no scaling).

Logged: https://github.com/networkupstools/nut/issues/142
--
Charles Lepple
clepple at gmail
Charles Lepple
2014-08-08 13:15:16 UTC
Permalink
Post by Charles Lepple
I just got a Cyberpower SOHO Value 1200 ELCD UPS and even with nut 2.7.2, it appears to report battery voltage too low due to the battery scaling function (In drivers/cps-hid.c). Even though the ups has usb id: 0764:0501, UPS.PowerSummary.Voltage reports 26.6 for the 24V batteries so when the 0.667 battery scale is applied that goes down to 17.7V.
I'm wondering if that scale factor is only needed for that one Dynex UPS model. We should be able to do a string match, which is ugly, but should work (especially if we default to no scaling).
Logged: https://github.com/networkupstools/nut/issues/142
It's not just Dynex models - there are some early "UPS VALUE" and "CP 1000D" units that seem to need the correction factor. I'll try to add a check that looks to see if the battery voltage makes sense.
--
Charles Lepple
clepple at gmail
Charles Lepple
2014-08-09 15:27:47 UTC
Permalink
Post by Charles Lepple
Post by Charles Lepple
I just got a Cyberpower SOHO Value 1200 ELCD UPS and even with nut 2.7.2, it appears to report battery voltage too low due to the battery scaling function (In drivers/cps-hid.c). Even though the ups has usb id: 0764:0501, UPS.PowerSummary.Voltage reports 26.6 for the 24V batteries so when the 0.667 battery scale is applied that goes down to 17.7V.
I'm wondering if that scale factor is only needed for that one Dynex UPS model. We should be able to do a string match, which is ugly, but should work (especially if we default to no scaling).
Logged: https://github.com/networkupstools/nut/issues/142
It's not just Dynex models - there are some early "UPS VALUE" and "CP 1000D" units that seem to need the correction factor. I'll try to add a check that looks to see if the battery voltage makes sense.
Matthew, can you try the attached patch, and run the driver it with -DDDD?

https://github.com/networkupstools/nut/commit/c8950dee9c91ce45d05d8f220ea26891fb92329e

Also, if anyone else has a Cyberpower UPS with the 0501 productID, I'd appreciate any additional testing.

Thanks,
--
Charles Lepple
clepple at gmail


-------------- next part --------------
A non-text attachment was scrubbed...
Name: cps_hid_scale.patch
Type: application/octet-stream
Size: 3286 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/nut-upsuser/attachments/20140809/6eb8b9a0/attachment.obj>
Matthew Stapleton
2014-08-11 01:29:55 UTC
Permalink
Attached is the first 32 seconds of the driver output after applying the
patch which fixes the battery scaling problem for this UPS.

Matthew Stapleton
Email: matthew4196 at gmail.com
Post by Charles Lepple
Post by Charles Lepple
Post by Charles Lepple
I just got a Cyberpower SOHO Value 1200 ELCD UPS and even with nut 2.7.2, it appears to report battery voltage too low due to the battery scaling function (In drivers/cps-hid.c). Even though the ups has usb id: 0764:0501, UPS.PowerSummary.Voltage reports 26.6 for the 24V batteries so when the 0.667 battery scale is applied that goes down to 17.7V.
I'm wondering if that scale factor is only needed for that one Dynex UPS model. We should be able to do a string match, which is ugly, but should work (especially if we default to no scaling).
Logged: https://github.com/networkupstools/nut/issues/142
It's not just Dynex models - there are some early "UPS VALUE" and "CP 1000D" units that seem to need the correction factor. I'll try to add a check that looks to see if the battery voltage makes sense.
Matthew, can you try the attached patch, and run the driver it with -DDDD?
https://github.com/networkupstools/nut/commit/c8950dee9c91ce45d05d8f220ea26891fb92329e
Also, if anyone else has a Cyberpower UPS with the 0501 productID, I'd appreciate any additional testing.
Thanks,
cps_hid_scale.patch
commit c8950dee9c91ce45d05d8f220ea26891fb92329e
Author: Charles Lepple <clepple+nut at gmail.com>
Date: Sat Aug 9 11:19:27 2014 -0400
usbhid-ups (CPS): determine battery.voltage scale factor at runtime
If the battery.voltage reading is greater than 1.4x battery.voltage.nominal,
apply a scale factor of 2/3 to bring the voltage back in line.
Closes networkupstools/nut#142
diff --git a/drivers/cps-hid.c b/drivers/cps-hid.c
index a6d64ba..78c952f 100644
--- a/drivers/cps-hid.c
+++ b/drivers/cps-hid.c
@@ -28,29 +28,36 @@
#include "cps-hid.h"
#include "usb-common.h"
-#define CPS_HID_VERSION "CyberPower HID 0.3"
+#define CPS_HID_VERSION "CyberPower HID 0.4"
/* Cyber Power Systems */
#define CPS_VENDORID 0x0764
-/*
+/*! Battery voltage scale factor.
* For some devices, the reported battery voltage is off by factor
* of 1.5 so we need to apply a scale factor to it to get the real
* battery voltage. By default, the factor is 1 (no scaling).
*/
static double battery_scale = 1;
+static int might_need_battery_scale = 0;
+static int battery_scale_checked = 0;
+
+/*! If the ratio of the battery voltage to the nominal battery voltage exceeds
+ * this factor, we assume that the battery voltage needs to be scaled by 2/3.
+ */
+static const double battery_voltage_sanity_check = 1.4;
static void *cps_battery_scale(USBDevice_t *device)
{
- battery_scale = 0.667;
+ might_need_battery_scale = 1;
return NULL;
}
/* USB IDs device table */
static usb_device_id_t cps_usb_device_table[] = {
- /* 900AVR/BC900D, CP1200AVR/BC1200D */
+ /* 900AVR/BC900D */
{ USB_DEVICE(CPS_VENDORID, 0x0005), NULL },
- /* Dynex DX-800U? */
+ /* Dynex DX-800U?, CP1200AVR/BC1200D, CP825AVR-G, CP1000AVRLCD, CP1000PFCLCD, CP1500C, CP550HG, etc. */
{ USB_DEVICE(CPS_VENDORID, 0x0501), &cps_battery_scale },
/* OR2200LCDRM2U, OR700LCDRM1U, PR6000LCDRTXL5U */
{ USB_DEVICE(CPS_VENDORID, 0x0601), NULL },
@@ -59,12 +66,48 @@ static usb_device_id_t cps_usb_device_table[] = {
{ -1, -1, NULL }
};
+ */
+static void cps_adjust_battery_scale(double batt_volt)
+{
+ const char *batt_volt_nom_str;
+ double batt_volt_nom;
+
+ if(battery_scale_checked) {
+ return;
+ }
+
+ batt_volt_nom_str = dstate_getinfo("battery.voltage.nominal");
+ if(!batt_volt_nom_str) {
+ upsdebugx(2, "%s: 'battery.voltage.nominal' not available yet; skipping scale determination", __func__);
+ return;
+ }
+
+ batt_volt_nom = strtod(batt_volt_nom_str, NULL);
+ if(batt_volt_nom == 0) {
+ upsdebugx(3, "%s: 'battery.voltage.nominal' is %s", __func__, batt_volt_nom_str);
+ return;
+ }
+
+ if( (batt_volt / batt_volt_nom) > battery_voltage_sanity_check ) {
+ upslogx(LOG_INFO, "%s: battery readings will be scaled by 2/3", __func__);
+ battery_scale = 2.0/3;
+ }
+
+ battery_scale_checked = 1;
+}
+
/* returns statically allocated string - must not use it again before
done with result! */
static const char *cps_battvolt_fun(double value)
{
static char buf[8];
+ if(might_need_battery_scale) {
+ cps_adjust_battery_scale(value);
+ }
+
+ upsdebugx(5, "%s: battery_scale = %.3f", __func__, battery_scale);
snprintf(buf, sizeof(buf), "%.1f", battery_scale * value);
return buf;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/nut-upsuser/attachments/20140811/86140247/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cyberpower_debug_log.txt.gz
Type: application/x-gzip
Size: 6728 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/nut-upsuser/attachments/20140811/86140247/attachment.bin>
Charles Lepple
2014-08-12 01:16:20 UTC
Permalink
On Sun, Aug 10, 2014 at 9:29 PM, Matthew Stapleton
Post by Matthew Stapleton
Attached is the first 32 seconds of the driver output after applying the
patch which fixes the battery scaling problem for this UPS.
Thanks. Merged to the master branch, so this should be part of the
next NUT release.
--
- Charles Lepple
Loading...