CABLES

First, you will need a serial port cable between the APC UPS and your computer running apcupsd. You can use either the special cable which is enclosed with the PowerChuteTM software or you can make your own cable. We highly recommend that you obtain your cable directly from APC.

To make your own cable, first, you must know whether you have a Smart UPS that sends ASCII characters called Smart Signalling, or a "dumb" UPS that uses serial port line voltage signalling, called Simple Signalling.

The "dumb" UPSes are older models such as the BackUPS (not BackUPS Pro) and the ShareUPS Basic Port that use Simple Signalling. Most other UPSes use Smart Signalling. If in doubt consult the Configuration Section of this manual, or the documentation that came with your UPS.

Smart Signalling Cable for SmartUPSes

For Smart UPSes, the cable is as follows:
    SMART-CUSTOM CABLE
		
PC (9 pin)      APC (9 pin)
2 RxD           2
3 TxD           1
5 GND           9

Simple Signalling Cable for "dumb" UPSes

For "dumb" UPSes using Simple Signalling, the cable is as follows:
         SIMPLE-CUSTOM CABLE
		
Computer Side   |  Description of Cable           |  UPS Side
DB9f  |  DB25f  |                                 |    DB9m
 4    |   20    |  DTR (5vcc)             *below  |    n/c
 8    |    5    |  CTS (low battery)      *below  | <-  5
 2    |    3    |  RxD (no line voltage)  *below  | <-  3
 5    |    7    |  Ground (Signal)                |     4
 1    |    8    |  CD (on battery from UPS)       | <-  2
 7    |    4    |  RTS (kill UPS power)           | ->  1
n/c   |    1    |  Frame/Case Gnd (optional)      |     9

Note: the <- and -> indicate the signal direction.
List of components one needs to make the Simple cable:
  1. One (1) male DB9 connector, use solder type connector only.
  2. One (1) female DB9/25F connector, use solder type connector only.
  3. two (2) 4.7K ohm 1/4 watt 5% resistors.
  4. one (1) foot of 3/32" (inch)
  5. shrink wrap/boot.
  6. resin core solder.
  7. three (3) to five (5) feet of 22AWG multi-stranded five (5) conductor cable.

Solder both of the resistors into pin# (4) DB9 or (20) DB25 the DTR.
This will be used as the Vcc pull-up voltage for testing the outputs on any "UPS by APC" in Simple Signalling mode. This cable may not work on a BackUPS Pro if the default communications are Smart Signalling mode. This cable is also valid for "ShareUPS" BASIC Port mode and is also reported to work on SmartUPSes. However, the Smart Cable described above is much simpler.

Next bend each of the resistors so that one connects to (8) DB9 or (5) DB25 the CTS (battery low signal) and the other to (2) DB9 or (3) DB25 the RxD (other on battery signal). This second line is not currently used, but it may be in the near future (this second line fail does not seem to be used in apcupsd-3.7.1 -- KES Feb 2000).

(*) 8/5 is also wired to pin# 5 on the UPS cable side.
(*) 2/3 is also wired to pin# 3 on the UPS cable side.
(*) we use the DTR as our +5 volts power for the circuit.

To have a better idea of what is going on inside apcupsd, for the SIMPLE cable apacupsd reads three signals and sets three:

Reads:
  CD, which apcupsd uses for the On Battery signal when high.
   
  CTS, which apcupsd uses for the Battery Low signal when high.

  RxD (SR), which apcupsd uses for the Line Down 
      signal when high. This signal isn't used for much.

Sets:
  DTR, which apcupsd sets when it detects a power failure (generally
       5 to 10 seconds after the CD signal goes high). It
       clears this signal if the CD signal subsequently goes low
       -- i.e. power is restored.

  TxD (ST), which apcupsd clears when it detects that the CD signal
       has gone low after having gone high - i.e. power is restored.

  RTS, which apcupsd sets for the killpower signal -- to cause the UPS
       to shut off the power.

Please note that these actions apply only to the SIMPLE cable, the signals used on the other cables are different.

Apcupsd will also support the following off the shelf cables that are supplied by APC:

940-0020B Simple Signal Only, all models.
940-0023A Simple Signal Only, all models.
940-0119A Simple Signal Only, Back-UPS Office (under development).
940-0024[B/C/G] SmartMode Only, SU and BKPro only.
940-0095[A/B/C] PnP (Plug and Play), all models.
940-1524C SmartMode Only

RS232 Wiring and Signal Conventions

DB-25
Pin #
DB-9
Pin #
Name DTE-DCE Description
1 -- FG --- Frame Ground/Chassis GND
2 3 TD ---> Transmitted Data, TxD
3 2 RD <--- Received Data, RxD
4 7 RTS ---> Request To Send
5 8 CTS <--- Clear To Send
6 6 DSR <--- Data Set Ready
7 5 SG ---- Signal Ground, GND
8 1 DCD <--- Data Carrier Detect
9 -- -- --- Positive DC test voltage
10 -- -- --- Negative DC test voltage
11 -- QM <--- Equalizer mode
12 -- SDCD <--- Secondary Data Carrier Detect
13 -- SCTS <--- Secondary Clear To Send
14 -- STD ---> Secondary Transmitted Data
15 -- TC <--- Transmitter (signal) Clock
16 -- SRD <--- Secondary Receiver Clock
17 -- RC ---> Receiver (signal) Clock
18 -- DCR <--- Divided Clock Receiver
19 -- SRTS ---> Secondary Request To Send
20 4 DTR ---> Data Terminal Ready
21 -- SQ <--- Signal Quality Detect
22 9 RI <--- Ring Indicator
23 -- -- ---> Data rate selector
24 -- -- <--- Data rate selector
25 -- TC <--- Transmitted Clock

Pin Assignment for the Serial Port (RS-232C), 25-pin and 9-pin

        13                         1         5         1
      _______________________________      _______________
      \  . . . . . . . . . . . . .  /      \  . . . . .  /    RS232-connectors
       \  . . . . . . . . . . . .  /        \  . . . .  /     looking into the
        ---------------------------          -----------      end of the cable.
        25                      14            9       6

   DTE : Data Terminal Equipment (i.e. computer)
   DCE : Data Communications Equipment (i.e. UPS)
   RxD : Data received; 1 is transmitted "low", 0 as "high"
   TxD : Data sent; 1 is transmitted "low", 0 as "high"
   DTR : DTE announces that it is powered up and ready to communicate
   DSR : DCE announces that it is ready to communicate; low=modem hangup
   RTS : DTE asks DCE for permission to send data
   CTS : DCE agrees on RTS
   RI  : DCE signals the DTE that an establishment of a connection is attempted
   DCD : DCE announces that a connection is established

Ioctl to RS232 Correspondence

#define TIOCM_LE        0x001
#define TIOCM_DTR       0x002
#define TIOCM_RTS       0x004
#define TIOCM_ST        0x008
#define TIOCM_SR        0x010
#define TIOCM_CTS       0x020
#define TIOCM_CAR       0x040
#define TIOCM_RNG       0x080
#define TIOCM_DSR       0x100
#define TIOCM_CD        TIOCM_CAR
#define TIOCM_RI        TIOCM_RNG
#define TIOCM_OUT1      0x2000
#define TIOCM_OUT2      0x4000

Modes Supported by Apcupsd for Various Cables

The following table shows the modes supported by the current version of Apcupsd (3.8.0) for various cables running the UPS in Simple Signalling mode.

Cable Power Loss Low Battery Kill Power Cable Disconnected
940-0020B Yes Yes Yes No
940-0023A Yes No No No
940-0119A Yes Yes Yes No
940-0095A/B/C Yes Yes Yes No
simple Yes Yes Yes No

Simple UPSes Signalling

Apparently, all signalling UPSes have the same signals on the output pins of the UPS. The difference at the computer end is due to different cable configurations. Thus, by measuring the connectivity of a cable, one can determine how to program the UPS. This is to be verified.

The signals presented or accepted by the UPS on its DB9 connector using the numbering scheme listed above is:

UPS Pin         Signal meaning
   1     <-     Shutdown when set by computer for 1-5 seconds.
   2     ->     On battery power
   3     ->     Mains down (line fail)
   5     ->     Low battery
   6     ->     Inverse of mains down signal
   7     <-     Turn on/off power (only on advanced UPSes only)

The Back-UPS Office 500 signals

The Back-UPS Office UPS has a telephone type jack as output, which looks like the following:
Looking at the end of the connector:

     6 5 4 3 2 1
    _____________
   | . . . . . . |
   |             |
   |  |----------|
   |__|

It appears tht the signals work as follows:

    UPS            Signal meaning
 1 (brown)    <-   Shutdown when set by computer for 1-5 seconds.
 2 (black)    ->   On battery power
 3 (blue)     ->   Low battery
 4 (red)           Signal ground 
 5 (yellow)   <-   Begin signalling on other pins
 6 (none)          none

940-0119A Cable Wiring

    UPS      Computer
    pins     pins      Signal             Signal meaning
 1 (brown)    4,6      DSR DTR     <-   Shutdown when set by computer for 1-5 seconds.
 2 (black)    8,9      RI  CTS     ->   On battery power
 3 (blue)     1,2      CD  RxD     ->   Low battery 
 4 (red)       5       Ground
 5 (yellow)    7       RTS         <-   Begin signalling on other pins 
 6 (none)     none

Internal Apcupsd Actions for Simple Cables

This section describes how apcupsd 3.7.2 (September 2000)
treats the serial port line signals for simple cables.

apcaction.c: 
   condition = power failure detected
   cable = CUSTOM_SIMPLE
   action = ioctl(TIOCMBIS, DTR)      set DTR (enable power bit?)

apcaction.c: 
   condition = power back
   cable = CUSTOM_SIMPLE
   action = ioctl(TIOCMBIC, DTR)      clear DTR (clear power bit)
   action = ioctl(TIOCMBIC, ST)       clear ST (TxD)

apcserial.c: 
   condition = serial port initialization
   cable = 0095A, 0095B, 0095C
   action = ioctl(TIOMBIC, RTS)       clear RTS (set PnP mode)

apcserial.c: 
   condition = save_dumb_status
   cable = CUSTOM_SIMPLE
   action = ioctl(TIOMBIC, DTR)       clear DTR (power bit?)
   action = ioctl(TIOMBIC, RTS)       clear RTS (killpower)

   cable = 0020B
   action = ioctl(TIOMBIC, DTR)       clear DTR (killpower)

   cable = 0095A, 0095B, 0095C
   action = ioctl(TIOMBIC, RTS)       clear RTS (killpower)
   action = ioctl(TIOMBIC, CD)        clear CD  (low batt)
   action = ioctl(TIOMBIC, RTS)       clear RTS (killpower) a second time!

apcserial.c:
   condition = check_serial

   cable = CUSTOM_SIMPLE
   action = OnBatt = CD
   action = BattLow = CTS
   action = LineDown = SR

   cable = 0020B
   action = OnBatt = CTS
   action = BattLow = CD
   action = LineDown = 0

   cable = 0023A
   action = Onbatt = CD
   action = BattLow = SR
   action = LineDown = 0

   cable = 0095A, 0095B, 0095C
   action = OnBatt = RNG
   action = BattLow = CD
   action = LineDown = 0


apcserial.c
   condition = killpower

   cable = CUSTOM_SIMPLE, 0095A, 0095B, 0095C
   action = ioctl(TIOMCBIS, RTS)      set RTS

   cable = 0020B
   action = ioctl(TIOMCBIS, DTR)      set DTR