Premise APC SmartUPS Module

Motorola Premise

etc6849

Senior Member
Attached is a beta version of an APC SmartUPS driver for Premise. I'm hoping someone will take a look or give it a try. I think it's 99% ready for posting under the downloads section, but I welcome any feedback.

Protocol Resources and Cable Pinout
http://www.apcupsd.com/manual/manual.pdf

To Start Using
Import the module and creat a new SmartUPS device under custom devices. Connect to a serial port with the UPS connected. Note you must use the supplied APC RS232 cable that works with the PowerChute software or build your own cable.

Controls
User controls that you'd expect to find on the front of the UPS such as: Run self test, front panel test, simulate power failure, runtime calibration and enter smart mode.

AlarmStatus
Currently the driver relies on the output of single character alarm codes from the SmartUPS and the UPS does not output line terminators when it alarms. This means to make the newdata code simple, polling must be enabled so that the alarm character will show up on the rxtextline. I plan to fix this in the next release by trying a hybrid approach; i.e. using both rxTextLine and rxBinaryData. Once I add this, AlarmStatus will be completely independent of polling.

Status
Requires polling interval be set. Pulls data from the status bit register of the SmartUPS and displays it as pictured. This class includes a handler to convert and decode the binary data; it uses bitwise and masking to do this.

Batteries
Requires polling interval be set. Displays voltage, cause of last transfer to the batteries, estimated runtime and level.

Line
Requires polling interval be set. Displays line data (ie parameters of your homes electrical service) such as: voltage, max and min voltage since last poll, frequency and quality.

Load
Requires polling interval be set. Displays load data (ie stuff plugged into the SmartUPS) such as: voltage and relative power (power relative to UPS capacity).

JobQueue
Uses a FIFO principle and includes priority so that if a test or request command is sent to the SmartUPS, all polls are removed from the jobqueue until the next poll. This class was borrowed from 123's viziarf driver.

Polling
To enable polling, set polling to a value greater than 10 seconds using the PollingInterval property found under the SmartUPS device in custom devices. Code for the Polling class was also borrowed from 123's viziarf driver.

Watchdog Timers
The timer JobTimeOut will trigger a retry to resend the job. If after 3 failed jobs (a failed job could be that no info was sent back from the SmartUPS etc...) the job is counted as a consecutive failed job. If there are more than 3 consecutive failed jobs (ie 9 consecutive retrys) the serial port is automatically reset as a means to cure the problem. If there are more than 3 consecutive port resets, the driver will stop working until the cable issue is fixed and the port is manually reset.
 

Attachments

  • APC_SmartUPS.GIF
    APC_SmartUPS.GIF
    22.6 KB · Views: 50
  • APC_Beta_5.zip
    APC_Beta_5.zip
    20.7 KB · Views: 52
...
JobQueue
... all polls are removed from the jobqueue until the next poll. ...

Is this procedure truly necessary for the APC device? I believe removing low-priority (polling) commands from the Job queue was necessary exclusively for Thermostat-related commands in the ViziaRF driver (owing to timing delays related to propagating z-wave commands).
 
123, thanks for taking a look, good catch! I'm trying to remember why I removed low priority commands after a high priority job was received... You're right, I don't think this is necessary here. The APC SmartUPS is super fast at processing and responding to rs232 commands and there really is no need to purge the jobs in queue for polling; I'm 99% certain of this.

Since we are on a similar topic, as you taught me before, the job queue will automatically handle the command timing. Using it, commands will never over take the APC SmartUPS (the protocol manual stated that sending commands too fast will make the APC unresponsive). This feature of yours works great on the APC with 100% accuracy after a million or so commands!
 
Back
Top