Home AMX User Forum AMX Technical Discussion
Options

Using I/0'S

Hello,

Having problems using I/O's on a Netlinx Controller. What I want to accomplish is sense a logic low or high (doesn't matter) and then turn on a relay on the controller. I've tried to figure this out on my own... but so far no luck! If this has been discussed previously I apologize but when I searched I couldn't find what I was looking for. Any help would be greatly appreciated. Thanks in advance for your replies.

Comments

  • Options
    PhreaKPhreaK Posts: 966
    Hey TCAV, both relays and IO's within NI controllers use channels for all their interaction. For your situation there are two parts to it:
    1. listening for the channel change on the IO
    2. setting a channel state on the relay

    Listening for the IO to flick between its two states is done in a channel event. Assuming that you've defined your IO device as 'dvIO' you would listen for the first IO changing like so:
    define_event
    
    channel_event[dvIO, 1] {
    
      on: {
        // this will fire when the IO goes high (by default - it can be inverted)
      }
    
      off: {
        // ...and it doesn't take a rocket scienctist to figure out this one considering the info above
      }
    
    }
    

    Now for setting the state of the relay this is done like so:
    on[dvRelay, 1]
    
    or
    off[dvRelay, 1]
    
    Again, assuming dvRelay has been previously defined.

    Now combining the two you would get something like this:
    define_event
    
    // link relay 1's state to the status of IO 1
    channel_event[dvIO, 1] {
    
      on: {
        on[dvRelay, 1]
      }
    
      off: {
        off[dvRelay, 1]
      }
    
    }
    

    Check out the NetLinx Keywords Help from within the help menu of NetLinx Studio for some more info.
  • Options
    ericmedleyericmedley Posts: 4,177
    Phreak's advice is for the programming side. But, are you asking about the physical side? are you having issues getting the IOs to fire correctly from your physical connection to the logic board of which you speak? If this is the case more discussion will be needed.
  • Options
    For some reason, on a recent job I could not get the IO's to work from a Channel_Event...
    I ended up getting it to work in a Button_Event...
    i.e.
    Button_Event[dvIO, ioInputs]
    {
    PUSH:
    {
    DebugMsg("'_Event[dvIO, ioInputs] PUSH: ', itoa(Button.Input.Channel)");
    HandlePodiumIO(Button.Input.Channel, True);
    TPWake(dvTPMenu);
    TPGotoPage(dvTPMenu, SCR_MAIN);
    TPPopupKillAll(dvTPMenu);
    TPPopupShow(dvTPMenu, SCR_MENU_1);
    }
    RELEASE:
    {
    DebugMsg("'_Event[dvIO, ioInputs] RELEASE: ', itoa(Button.Input.Channel)");
    HandlePodiumIO(Button.Input.Channel, False);
    }
    }
  • Options
    TCAVTCAV Posts: 4
    PhreaK wrote: »
    Hey TCAV, both relays and IO's within NI controllers use channels for all their interaction. For your situation there are two parts to it:
    1. listening for the channel change on the IO
    2. setting a channel state on the relay

    Listening for the IO to flick between its two states is done in a channel event. Assuming that you've defined your IO device as 'dvIO' you would listen for the first IO changing like so:
    define_event
    
    channel_event[dvIO, 1] {
    
      on: {
        // this will fire when the IO goes high (by default - it can be inverted)
      }
    
      off: {
        // ...and it doesn't take a rocket scienctist to figure out this one considering the info above
      }
    
    }
    

    Now for setting the state of the relay this is done like so:
    on[dvRelay, 1]
    
    or
    off[dvRelay, 1]
    
    Again, assuming dvRelay has been previously defined.

    Now combining the two you would get something like this:
    define_event
    
    // link relay 1's state to the status of IO 1
    channel_event[dvIO, 1] {
    
      on: {
        on[dvRelay, 1]
      }
    
      off: {
        off[dvRelay, 1]
      }
    
    }
    

    Check out the NetLinx Keywords Help from within the help menu of NetLinx Studio for some more info.

    Thanks Phreak it worked great... I also got it to work using a button event. The reason I was having so much trouble getting it to work was because I mistakenly assigned I0 as 5001:1:9 on a NI-2000 Controller...Duh!
  • Options
    TCAVTCAV Posts: 4
    ericmedley wrote: »
    Phreak's advice is for the programming side. But, are you asking about the physical side? are you having issues getting the IOs to fire correctly from your physical connection to the logic board of which you speak? If this is the case more discussion will be needed.

    Thanks for your reply ericmedley, no it was purely a programming issue that I was having.
  • Options
    TCAVTCAV Posts: 4
    For some reason, on a recent job I could not get the IO's to work from a Channel_Event...
    I ended up getting it to work in a Button_Event...
    i.e.
    Button_Event[dvIO, ioInputs]
    {
    PUSH:
    {
    DebugMsg("'_Event[dvIO, ioInputs] PUSH: ', itoa(Button.Input.Channel)");
    HandlePodiumIO(Button.Input.Channel, True);
    TPWake(dvTPMenu);
    TPGotoPage(dvTPMenu, SCR_MAIN);
    TPPopupKillAll(dvTPMenu);
    TPPopupShow(dvTPMenu, SCR_MENU_1);
    }
    RELEASE:
    {
    DebugMsg("'_Event[dvIO, ioInputs] RELEASE: ', itoa(Button.Input.Channel)");
    HandlePodiumIO(Button.Input.Channel, False);
    }
    }

    Thanks for the info and your reply... what is the advantage of using a channel event vs a button event in this situation?
Sign In or Register to comment.