get input command
Thomas Hayes
Posts: 1,164
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
}
}
}
}
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
}
}
}
}
0
Comments
'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')
Wouldn't that be...
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
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'.