Home AMX User Forum NetLinx Studio

controling APC Smart-UPS

I need to control outs on APC Smart-ups, and recieve information by axcent3 when bettery is low. Could you give me some examples of code which contols a smart ups.
Sorry fot my bad english, and thanks for advice

Comments

  • DHawthorneDHawthorne Posts: 4,584
    I started putting together a module for the Smart-UPS years ago, but the need went away, and I never finished it. Here are the references I found at the time. Make sure you unpack the ZIP with folder names.
  • NMarkRobertsNMarkRoberts Posts: 455
    I have one under my desk if you need any help. I don't have a module to control it but I could help you sort things out.

    One approach to working it out would be to install the APC software and sniff the strings.
  • DHawthorneDHawthorne Posts: 4,584
    Take mind, the Smart-UPS is RS-232 controllable, the BACK-UPS series is not. The Back UPS outputs voltages on the various pins, and can be controlled with relay closures ... kind of messy. It's in one of those documents in the zip file.
  • TassadarTassadar Posts: 11
    My SMART-UPS series is 2200. Can i control it using common com-cable?
    Now i need, to check where the bettery is low.
  • DHawthorneDHawthorne Posts: 4,584
    I believe so - check those docs and give it a whirl :).
  • joelwjoelw Posts: 175
    Tassadar wrote:
    Can i control it using common com-cable?

    A standard com-cable will not work. Check Dave's docs.
  • NMarkRobertsNMarkRoberts Posts: 455
    I can confirm that the cable attached to my APC UPS has the truly bizarre pinout that is described in the docs:
     Signal Computer                  UPS
             DB9F                     DB9M
       RxD    2   --------------------  2  TxD  Send
       TxD    3   --------------------  1  RxD  Receive
       GND    5   --------------------  9  Ground
    
  • AMXJeffAMXJeff Posts: 450
    NetLinx Module

    I had to write this module for a project, does not do a hell of alot, but it will give you an idea how I had to go about it.
    MODULE_NAME='APC Smart-UPS,Rev 0' (Dev vdvUPS, Dev dvUPS)
    (*{{PS_SOURCE_INFO(PROGRAM STATS)                          *)
    (***********************************************************)
    (*  FILE CREATED ON: 08/06/2003 AT: 18:02:03               *)
    (***********************************************************)
    (*  FILE_LAST_MODIFIED_ON: 08/19/2003 AT: 20:06:56         *)
    (***********************************************************)
    (*  ORPHAN_FILE_PLATFORM: 1                                *)
    (***********************************************************)
    (*!!FILE REVISION: Rev 0                                   *)
    (*  REVISION DATE: 08/19/2003                              *)
    (*                                                         *)
    (*  COMMENTS:                                              *)
    (*                                                         *)
    (***********************************************************)
    (*!!FILE REVISION: Rev 0                                   *)
    (*  REVISION DATE: 08/06/2003                              *)
    (*                                                         *)
    (*  COMMENTS:                                              *)
    (*                                                         *)
    (***********************************************************)
    (*}}PS_SOURCE_INFO                                         *)
    (***********************************************************)
    
    (***********************************************************)
    (* System Type : Netlinx                                   *)
    (***********************************************************)
    (* REV HISTORY:                                            *)
    (***********************************************************)
    
    (***********************************************************)
    (*          DEVICE NUMBER DEFINITIONS GO BELOW             *)
    (***********************************************************)
    DEFINE_DEVICE
    
    (***********************************************************)
    (*               CONSTANT DEFINITIONS GO BELOW             *)
    (***********************************************************)
    DEFINE_CONSTANT
    // TimeLines 
    TL_POLL             = 2;
    
    //  Status Mode
    RUNTIME_CALIBRATE = 100;
    SMART_TRIM        = 101;
    SMART_BOOST       = 102;
    LINE_POWER        = 103;
    BATTERY_POWER     = 104;
    OVERLOAD          = 105;
    BATTERY_LOW       = 106;
    REPLACE_BATTERY   = 107;
    
    // Battery Mode
    CHARGING          = 110;
    FULL              = 111;
    
    
    // Parse Mode
    EMPTY             = 0;
    STATUS_MODE       = 1;
    BATTERY_MODE      = 2;
    
    (***********************************************************)
    (*              DATA TYPE DEFINITIONS GO BELOW             *)
    (***********************************************************)
    DEFINE_TYPE
    
    (***********************************************************)
    (*               VARIABLE DEFINITIONS GO BELOW             *)
    (***********************************************************)
    DEFINE_VARIABLE
    Volatile Char cUPSBuffer[1000];
    Volatile Integer nParseMode = EMPTY;
    Volatile Long lPollTimes[] = {5000,5000};
    (***********************************************************)
    (*               LATCHING DEFINITIONS GO BELOW             *)
    (***********************************************************)
    DEFINE_LATCHING
    
    (***********************************************************)
    (*       MUTUALLY EXCLUSIVE DEFINITIONS GO BELOW           *)
    (***********************************************************)
    DEFINE_MUTUALLY_EXCLUSIVE
    
    (***********************************************************)
    (*        SUBROUTINE/FUNCTION DEFINITIONS GO BELOW         *)
    (***********************************************************)
    Define_Function StatusMode(Integer nStatus)
    {
      [vdvUPS,RUNTIME_CALIBRATE]  = (nStatus Band $01)
      [vdvUPS,SMART_TRIM]         = (nStatus Band $02)
      [vdvUPS,SMART_BOOST]        = (nStatus Band $04)
      [vdvUPS,LINE_POWER]         = (nStatus Band $08)
      [vdvUPS,BATTERY_POWER]      = (nStatus Band $10)
      [vdvUPS,OVERLOAD]           = (nStatus Band $20)
      [vdvUPS,BATTERY_LOW]        = (nStatus Band $40)
      [vdvUPS,REPLACE_BATTERY]    = (nStatus Band $80)
    }
    
    Define_Function BatteryMode(Integer nStatus)
    {
      [vdvUPS,CHARGING]  = (nStatus < 100)
      [vdvUPS,FULL]      = (nStatus == 100)
    }
    
    
    Define_Function ParseUPS(Char cBuffer[])
    {
      Local_vAR Char cMsg[100]
      lOCAL_Var Integer nStatus;
      
      cMsg = Remove_String(cBuffer,"13,10",1);  
      If (Length_String(cMsg))
      {
        Set_Length_String(cMsg,Length_String(cMsg)-2);
        
        Select
        {
          Active (Find_String(cMsg,'SM',1)):
          {
          }
          Active (Find_String(cMsg,'BYE',1)):
          {
          }
          Active (1):
          {      
            SWITCH (nParseMode)
            {
              CASE STATUS_MODE:
              {
                nStatus = Type_Cast(HexToI(cMsg));
                StatusMode(nStatus)
                nParseMode = EMPTY;
              }
              CASE BATTERY_MODE:
              {
                BatteryMode(Atoi(cMsg))
                nParseMode = EMPTY;
              }
            }
          }  
        }
      }
    }
    (***********************************************************)
    (*                STARTUP CODE GOES BELOW                  *)
    (***********************************************************)
    DEFINE_START
    
    Create_Buffer dvUPS,cUPSBuffer
    
    Timeline_Create(TL_POLL,lPollTimes,2,TIMELINE_RELATIVE,TIMELINE_REPEAT);
    (* System Information Strings ******************************)
    (* Use this section if there is a TP in the System!        *)
    (*
        SEND_COMMAND TP,"'!F',250,'1'"
        SEND_COMMAND TP,"'TEXT250-',__NAME__"
        SEND_COMMAND TP,"'!F',251,'1'"
        SEND_COMMAND TP,"'TEXT251-',__FILE__,', ',S_DATE,', ',S_TIME"
        SEND_COMMAND TP,"'!F',252,'1'"
        SEND_COMMAND TP,"'TEXT252-',__VERSION__"
        SEND_COMMAND TP,"'!F',253,'1'"
        (* Must fill this (Master Ver) *)
        SEND_COMMAND TP,'TEXT253-'
        SEND_COMMAND TP,"'!F',254,'1'"
        (* Must fill this (Panel File) *)
        SEND_COMMAND TP,'TEXT254-'
        SEND_COMMAND TP,"'!F',255,'1'"
        (* Must fill this (Dealer Info) *)
        SEND_COMMAND TP,'TEXT255-'
    *)
    (***********************************************************)
    (*                THE EVENTS GOES BELOW                    *)
    (***********************************************************)
    DEFINE_EVENT
    
    Channel_Event[vdvUPS,0]
    {
      On:
      {
      }
      Off:
      {
      }
    }
    
    Data_Event[dvUPS]
    {
      Online:
      {
        Send_Command dvUPS,'SET BAUD 2400,N,8,1';
        Send_Command dvUPS,'HSOFF';
        Send_Command dvUPS,'CHARDM-255';
      }
      
      String:
      {
         If (Find_String(Data.Text,"10",1))
          ParseUPS(cUPSBuffer);
      }
    }
    
    Timeline_Event[TL_POLL]
    {
      Switch (Timeline.Sequence)
      {
        Case 1:
        {
          Send_String dvUPS,'YQR'
          nParseMode = STATUS_MODE;
        }
        Case 2:
        {
          Send_String dvUPS,'YfR'
          nParseMode = BATTERY_MODE;
        }
      }
    }
    (***********************************************************)
    (*            THE ACTUAL PROGRAM GOES BELOW                *)
    (***********************************************************)
    DEFINE_PROGRAM
    
    (***********************************************************)
    (*                     END OF PROGRAM                      *)
    (*        DO NOT PUT ANY CODE BELOW THIS COMMENT           *)
    (***********************************************************)
    
    
    
Sign In or Register to comment.