LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to monitor a UPS by serial port

Solved!
Go to solution

   We just bought a CyberPower UPS with a serial port. The UPS will not be used to maintain the computer running the LabVIEW program, but is for different equipment. Hence the standard software for shutting down your computer on a UPS power loss signal is not helpful. What I need is a way to monitor the serial port in LabVIEW so that I can get information from the UPS about its state (AC Power, Battery level, etc.) (This UPS does not support SNMP.)

    The manufacturer does not supply any documentation about the serial port protocol. I tried installing their software and snooping. It appears that when their software is installed, nothing is going across the serial port. I'm guessing that their software only monitors some of the handshaking lines. It only reports whether the UPS is on AC power or not and is connected or not. It doesn't report battery levels or any details. And no traffic is evident on the serial port.

    Is there a common, known protocol for this type of UPS behavior?

 

(By the way, I found this old thread:  http://forums.ni.com/t5/LabVIEW/read-javascript-on-web-page-to-shut-down-on-power-failure/m-p/782542... Different brand of UPS, different solution.)

 

Thanks,

     DaveT

-------------------------------------------------------------
David Thomson Original Code Consulting
www.originalcode.com
National Instruments Alliance Program Member
Certified LabVIEW Architect
Certified Embedded Systems Developer
-------------------------------------------------------------
There are 10 kinds of people: those who understand binary, and those who don't.
0 Kudos
Message 1 of 16
(18,075 Views)

There used to be a white paper on the NI boards.  Calculating the System Power Source and Battery Information in LabVIEW  I found the link in other threads, the link seems to have gone dead.

 

It used a VI to monitor batteries.  I wound up adapting a bit for my own purpose to be used as a subVI or as a standalone.  I'll attach that here.

 

I've used it to monitor both a battery in my laptop, and alos APC brand UPS's that had whatever level of drives they came with and a connection to the PC.  If the drivers for your battery cause it to show up in Windows Power monitoring, then I hope it can help you.

 

 

Message 2 of 16
(18,069 Views)

    Thanks for the reply. I do remember the link you mentioned. I copied that code a while ago and do use it to monitor the battery of the laptop that is running the program. I don't think that will work in this case, since I will eventually need to monitor several UPS's, none of which are dediated to keeping the laptop alive .E.g. I'm assuming that the built-in Windows battery API can only handle one UPS, with the assumption that that UPS is being used for the computer doing the monitoring.

    What I really need is the documentation for the low-level protocol that Windows is using to monitor the battery. Then I could implement that protocol directly on the serial ports and monitor as many UPS's as I need to.

-------------------------------------------------------------
David Thomson Original Code Consulting
www.originalcode.com
National Instruments Alliance Program Member
Certified LabVIEW Architect
Certified Embedded Systems Developer
-------------------------------------------------------------
There are 10 kinds of people: those who understand binary, and those who don't.
0 Kudos
Message 3 of 16
(18,062 Views)
Solution
Accepted by topic author Dave_Thomson

CyberPower responded to my inquiry with the necessary info.. I'll post a brief summary here in case anyone else needs it.

They use the handshaking lines to signal UPS state. I think the reason is that they can also drive "dumb" hardware (relays or whatever) with the same interface. In any case, they use DCD to signal low battery, CTS to signal no AC. The PC should keep RTS high during communication. DTR can be put high for 7 seconds to tell the UPS to shut down in two minutes.

I'm assuming (hoping) that this is a standard interface that a lot of UPS's use. Please post here if you find that it is used by other manufacturers.


Cheers,

    DaveT

-------------------------------------------------------------
David Thomson Original Code Consulting
www.originalcode.com
National Instruments Alliance Program Member
Certified LabVIEW Architect
Certified Embedded Systems Developer
-------------------------------------------------------------
There are 10 kinds of people: those who understand binary, and those who don't.
Message 4 of 16
(18,053 Views)

I'm thinking it may be able to handle more than one battery.  At least I seem to remember something about my laptop being able to look at its internal battery and an external UPS battery at the same time.  I'm not sure if the VI is setup to do that.  Maybe I just saw it in control panel or Windows device manager.  If it can handle more than 1, than that would be promising.  But I don't know if there is any practical upper limit on the number of batteries it can watch.

 

I'm pretty sure it doesn't have to be a UPS that is dedicated to keeping the laptop or PC alive.  A desktop PC doesn't necessarily have to be plugged into the UPS for power even though it might be plugged in for communication.  You'd just need to be sure any power monitoring features on a laptop or PC are set to not shutdown when it detects low power levels.

 

I don't think I can be able to help much more.  If you learn anything about the underlying protocol, please report back so we can learn something too.

0 Kudos
Message 5 of 16
(18,051 Views)
0 Kudos
Message 6 of 16
(16,716 Views)

Does Eaton Ellipse relate to CyberPower?  Because if it doesn't you should probably start your own thread.  Not only does this one only seem loosely related to your issue, it also has been solved a year ago and as a result will likely not get much attention.

0 Kudos
Message 7 of 16
(16,710 Views)

My issue is similar enough to warrant me commenting on this post rather than making a new one...

 

At my facility we are having issues with losing power in the middle of the night. The PCs that run the testing software all have UPSs to handle that, but the thermal chambers do not. Tests that take 8 hours are having to be restarted in the morning because of this. What I would like is some way of determining if the PC is currently running off the UPS power or main power.

 

Is there something out there like a .NET property node or simple VI that can tell me that right off the bat?

Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

0 Kudos
Message 8 of 16
(9,042 Views)

If Windows can "see" the UPS, you should be able to use SNMP to communicate with it.  Unfortunately I have no idea how to implement that in LV, or any other language, as I'm not very good at SNMP at all.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 9 of 16
(9,023 Views)

Andrew,

 

If the LabVIEW application is running on a Windows machine, and the UPS can be connected to that PC (via USB, as an HID Battery class device - this is common for APC UPSes), there is LabVIEW code available (originally written by Phillip Brooks and also a modified version by me).  The library I wrote registers a .NET callback event that detects UPS status changes, and also uses a Win32 API call to get UPS/battery status.  My library is set up to make it easy to use the LabVIEW event structure to process UPS changes, but of course you can still call just the Win32 API VI if you just want to poll.

 

Since the LV code only talks to Windows, and not hardware directly, any brand UPS that can be made to show up in the Windows Device Manager should theoretically work, though I've only used the library to watch APC UPSes, and my laptop's battery status. 

 

If you want this library, PM me an email address and I'll go dig it out and send it.

 

Best regards,

Dave

 

P.S.  Moog in NC?

David Boyd
Sr. Test Engineer
Abbott Labs
(lapsed) Certified LabVIEW Developer
Message 10 of 16
(8,986 Views)