Home AMX User Forum AMX General Discussion

get input command

Hello All
I am using the 'get input' # command to querie the status of an IO port. The problem I'm having is the data coming into the buffer never seems to change regardless of the ports value. Does this command work with the NI-3100 series?
What I have:

Send_command DOOR,'get input 2'

DATA_EVENT [DOOR]
{
STRING:
{
SELECT
{
ACTIVE (FIND_STRING (DATA.TEXT,'INPUT2 ACTIVE ',1)):
{
DOOR_JUNK=REMOVE_STRING (DATA.TEXT,'INPUT2 ACTIVE ',1)
DOOR_INFO=MID_STRING(DATA.TEXT,1,4)
IF(DOOR_INFO='LOW ')
{
SOURCE_PAGE='SELECTION'
SYSTEM_DUEL=0
}
IF(DOOR_INFO='HIGH')
{
SOURCE_PAGE='SELECTION_2'
SEND_COMMAND TP2140,"'PAGE-OFFLINE'"
CALL 'ROOM 2140 ON'
SYSTEM_DUEL=1
}
//CLEAR_BUFFER DOOR_BUFFER
}
}


}
}

Comments

  • DHawthorneDHawthorne Posts: 4,584
    I've never used that command. Is there some reason you can't simply test [DOOR, 2]?
  • HedbergHedberg Posts: 671
    Hello All
    I am using the 'get input' # command to querie the status of an IO port. The problem I'm having is the data coming into the buffer never seems to change regardless of the ports value. Does this command work with the NI-3100 series?
    }

    'GET INPUT' does not return the status of the port, it returns the value of a configuration parameter, either 'HIGH' or 'LOW'. This configuration parameter is set via the 'SET INPUT' command.

    Basically, if the input is set 'HIGH', an open circuit is detected as a 'on' and a closed circuit as a 'off'.. If set to 'LOW' (the default), an open circuit is an 'off' and a closed circuit is 'on.' Also, if you want to use the port as an output port, you need to use 'LOW'. There are some more details about how the ports work depending on how they are configured and what the detected voltage is, but if you're just working with detecting a contact closure, you needn't worry about it.

    In order to sense a state change, either monitor the port, as Dave suggest, or create button_events -- a status change will generate either a push or release depending on configuration.

    For example, this would "do something' when io port #1 goes from open circuit to closed (assuming set 'LOW')
    button_event[dvIO,1]
    {
       push:
       {
          'DO_SOMWTHING'
       }
    }
    
  • Thanks for the info, after reading more about this command I realised that it was only checking the 'set status' and not any activity on the port that might be either high or low.
  • ericmedleyericmedley Posts: 4,177
    Hedberg wrote:
    button_event[dvIO,1]
    {
       push:
       {
          'DO_SOMWTHING'
       }
    }
    

    Wouldn't that be...
    channel_event[dvIO,1]
    {
    ON:
      {
      // do something
      }
    }
    
  • I got the code working with the button_event and 'push', 'release' . I was using the channel_event but had a couple of issues with it. Thanks for the help.
    I am thinking AMX should add a few new code words to help make such things easier.

    -What_is[level, value, condition of a port or device]
    -Verify [checks value, condition, etc]
    -Check_status
  • HedbergHedberg Posts: 671
    ericmedley wrote:
    Wouldn't that be...
    channel_event[dvIO,1]
    {
    ON:
      {
      // do something
      }
    }
    

    In either 'HIGH' or 'LOW', making or breaking the pin to ground on an IO port will generate either a button press or a button release, as appropriate, and a button_event will work. In 'LOW', the output channel will cycle along with the button press, but I don't believe it will in 'HIGH'. as output is disabled in 'HIGH'. So, I don't think the channel_event will work with 'SET INPUT n HIGH'.
Sign In or Register to comment.