Home AMX User Forum NetLinx Studio

io ports

adysadys Posts: 395
hi

How can i listen to io ports changes ?

is this suppose to work?

button_event[dvKJPreAmpIO, 1]
{
push :
{
SEND_STRING dvDebug, "'IO ON'"
}
release :
{
SEND_STRING dvDebug, "'IO OFF'"
}
}

from some reason it does not work...

I tired also to change the io setting with no success....

send_command dvKJPreAmpIO,"'SET INPUT 1 LOW'"
send_command dvKJPreAmpIO,"'SET INPUT 2 HIGH'"

What am I doing wrong?

the wire is connected to the + and to the 1 of the IO on the NI3000

thanks

ady.

Comments

  • HedbergHedberg Posts: 671
    Your code looks right to me at a glance.

    For using the IO ports as inputs:

    If you are using "LOW", a short between IO port 1 and gnd (not +12v)will cause a push.
    If you are using "HIGH", a short between IO port 1 and gnd will cause a release and the port will read a push when you open circuit the IO pin. That's what I see, anyway.

    To use the port as an output requires that the port be set to "LOW".

    So, I think maybe what you are doing wrong is connecting to the +12v pin instead of the gnd pin. That's assuming that you are trying to detect a contact closure.
  • viningvining Posts: 4,368
    DATA_EVENT   [dv_IO]                 /// I/O sensor input port 17 of NI4000 
    
         {
         online:
    	  {
    	  send_command dv_IO,'SET INPUT 1 LOW'
    	  send_command dv_IO,'SET INPUT 2 LOW'
    	  send_command dv_IO,'SET INPUT 3 LOW'
    	  send_command dv_IO,'SET INPUT 4 LOW'
    	  send_command dv_IO,'SET INPUT 5 LOW'
    	  send_command dv_IO,'SET INPUT 6 LOW'
    	  send_command dv_IO,'SET INPUT 7 LOW'
    	  send_command dv_IO,'SET INPUT 8 LOW'
    	  }                               
         }
    
    CHANNEL_EVENT[dv_IO,1]///  IO 1
         {
         ON:
    	  {
    	  //do something
    	  }
         OFF:
    	  {
    	  //do something
    	  }
         }
    CHANNEL_EVENT[dv_IO,2]///  IO 2
         {
         ON:
    	  {
    	  //do something
    	  }
         OFF:
    	  {
    	  //do something
    	  }
         }
    CHANNEL_EVENT[dv_IO,3]///  IO 3
         {
         ON:
    	  {
    	  //do something
    	  }
         OFF:
    	  {
    	  //do something
    	  }
         }
    


    Example:
    This example is for a PCS2 which is connected to IO 3 and uses waits and cancel waits to eliminate executing events until the PCS stabilizes from the initial AC current in rush when the TV is first turned which genereates an "ON", which then drops off enough to generate an "OFF" and final reaches an adequate level again which generates the "ON" state which it then maitains.
    CHANNEL_EVENT[dv_IO,3]///  IO current sensor for TV
         {
         ON:
    	  {
    	  If (nIO_DeBug)
    	       {
    	       SEND_STRING 0,"'IO Port ',itoa(channel.channel),' ON <-Line-<',ITOA(__LINE__),'>',CRLF" ;
    	       }
    	  cancel_wait 'TV_Cur_Sensor_Delay' ;//wait for sensor to stabilize.
    	  wait 30 'TV_Cur_Sensor_Delay' 
    	       {
    	       if([dv_IO,3])//redundant checking
    		    {
    		    fnSystemPwrOnTvRemote() ;
    		    If (nIO_DeBug)
    			 {
    			 SEND_STRING 0,"'IO Port ',itoa(channel.channel),' ON, Executed fnSystemPwr"On"TvRemote()<-Line-<',ITOA(__LINE__),'>',CRLF" ;
    			 }
    		    }
    	       }
    	  }
         OFF:
    	  {
    	  If (nIO_DeBug)
    	       {
    	       SEND_STRING 0,"'IO Port ',itoa(channel.channel),' OFF <-Line-<',ITOA(__LINE__),'>',CRLF" ;
    	       }
    	  cancel_wait 'TV_Cur_Sensor_Delay' ;//wait for sensor to stabilize.
    	  wait 30 'TV_Cur_Sensor_Delay' 
    	       {
    	       if(![dv_IO,3])//redundant checking
    		    {
    		    fnSystemPwrOffTvRemote() ;
    		    If (nIO_DeBug)
    			 {
    			 SEND_STRING 0,"'IO Port ',itoa(channel.channel),' OFF, Executed fnSystemPwr"Off"TvRemote()<-Line-<',ITOA(__LINE__),'>',CRLF" ;
    			 }
    		    }
    	       }
    	  }
         }
         
    
  • adysadys Posts: 395
    Thanks guys, for the answers and the examples.

    We added an external 12 DC source and now it works...

    That was the problem. Our IO trigger didn't gave enough power.

    Now I undestand we could do it by connecting it to the GND and not the +?




    Ady.
  • HedbergHedberg Posts: 671
    adys wrote:
    Thanks guys, for the answers and the examples.

    We added an external 12 DC source and now it works...

    That was the problem. Our IO trigger didn't gave enough power.

    Now I undestand we could do it by connecting it to the GND and not the +?




    Ady.

    How you hook it up depends on what you are trying to do. As the name implies, you can use the ports as either inputs or outputs. If you are using the port to detect a contact closure (for example. a relay output that is closing or a sensing switch attached to a door or "air wall" ), it is most common to monitor this by connecting the switch/relay to the IO port pin and gnd and using 'LOW'. When the "detector's" circuit is closed, you will detect a button push. When it is opened, you will detect a release. You can program this in two ways (at least). You can detect the change in IO port state as either a button event or a channel event. Or, for quick and dirty, you can just use the state of the IO port as if it were a parameter if it's controlled by a current or video sensor.

    I believe that if you set the port 'HIGH' that it will be on if nothing is connected to it and that it will be turned off (a button release) if the port pin is connected to ground (either directly or by an external device like a switch or relay output).

    As an output, the IO port can be used as a very light duty relay. When you turn the port on, it appears like a contact closure (a logic low). So, you can control another device that is looking for a logic low or you can control power to a device so long as it draws no more than 200 ma.
Sign In or Register to comment.