Home AMX User Forum NetLinx Studio

screen relay issue

i know i have used this code before and worked fine. in this new project i have 4 screens controlled through relays. none are working. i know that the screens will go up and down if i short the wires.
DEFINE_DEVICE
dvRELAY				=		5001:8:0		//Draper 104306L LVC Controller (x4)

BUTTON_EVENT[dvTP_1189,50]
BUTTON_EVENT[dvTP_1189,51]
{
    PUSH:
    {
    PULSE[button.input.device, button.input.channel]
	IF (button.input.device = 50)
	    PULSE[dvRelay,1]					//Screen UP #1187
    ELSE
	IF (button.input.device = 51)
	    PULSE[dvRelay,2]					//Screen DOWN #1187
    }
}
BUTTON_EVENT[dvTP_1189,52]
BUTTON_EVENT[dvTP_1189,53]
{
    PUSH:
    {
    PULSE[button.input.device, button.input.channel]
	IF (button.input.device = 52)
	    PULSE[dvRelay,3]					//Screen UP #1188
    ELSE
	IF (button.input.device = 53)
	    PULSE[dvRelay,4]					//Screen DOWN #1188
    }
}
BUTTON_EVENT[dvTP_1189,54]
BUTTON_EVENT[dvTP_1189,55]
{
    PUSH:
    {
    PULSE[button.input.device, button.input.channel]
	IF (button.input.device = 54)
	    PULSE[dvRelay,5]					//Screen UP #1189
    ELSE
	IF (button.input.device = 55)
	    PULSE[dvRelay,6]					//Screen DOWN #1189
    }
}
BUTTON_EVENT[dvTP_1189,56]
BUTTON_EVENT[dvTP_1189,57]
{
    PUSH:
    {
    PULSE[button.input.device, button.input.channel]
	IF (button.input.device = 56)
	    PULSE[dvRelay,7]					//Screen UP #1190
    ELSE
	IF (button.input.device = 57)
	    PULSE[dvRelay,8]					//Screen DOWN #1190
    }
}

the TP buttons feedback are all set to Momentary.

Comments

  • Joe HebertJoe Hebert Posts: 2,159
    playskool1 wrote:
    in this new project i have 4 screens controlled through relays. none are working.
    IF (button.input.device = 50)
    

    You probably want this instead:
    IF (button.input.channel = 50)
    

    playskool1 wrote:
    the TP buttons feedback are all set to Momentary.
    If that?s true then the line below doesn?t do anything.
    PULSE[button.input.device, button.input.channel]
    

    If you want to control the feedback you?ll need to set the feedback to Channel and when the button is pushed you can try a simpler method like this instead:
    TO[BUTTON.INPUT]
    

    Or if you prefer:
    PULSE[BUTTON.INPUT]
    

    And as an FYI, you can also consolidate your code considerably by doing something like this to control all the screens:
    DEFINE_DEVICE
    
    dvRelay 	= 5001:8:0
    dvTP_1189	= 10001:1:0
    
    DEFINE_CONSTANT
    
    INTEGER nScreenButtons[] = {
    
       50,51,52,53,54,55,56,57
    }
    
    DEFINE_EVENT
    
    BUTTON_EVENT[dvTP_1189,nScreenButtons] {
    
       PUSH: {
    
          TO[BUTTON.INPUT]
          PULSE[dvRelay,GET_LAST(nScreenButtons)]
          
       }
    
    }
    
    
  • Thanks a lot Joe. I'll give that a try. I swear that I could possibly code blind. lol
  • patbpatb Posts: 140
    Try this....

    DEFINE_DEVICE
    dvRELAY = 5001:8:0 //Draper 104306L LVC Controller (x4)

    BUTTON_EVENT[dvTP_1189,50]
    BUTTON_EVENT[dvTP_1189,51]
    BUTTON_EVENT[dvTP_1189,52]
    BUTTON_EVENT[dvTP_1189,53]
    BUTTON_EVENT[dvTP_1189,54]
    BUTTON_EVENT[dvTP_1189,55]
    BUTTON_EVENT[dvTP_1189,56]
    BUTTON_EVENT[dvTP_1189,57]
    {
    PUSH:
    {
    PULSE[dvRelay,BUTTON.INPUT.CHANNEL-49]
    }
    }

    What Joe said was right also, same thing written a different way. You could probably write this same code 10 different ways and they would all be right and they would all work. This does not address feedback because typically with a screen you would want latching feedback to show the state of the screen. You also should have the pairs of relays defined mutually exclusive so you won't get both relays to turn on at the same time if the up and down buttons are pressed quickly.
  • HedbergHedberg Posts: 671
    patb wrote: »
    [...] You also should have the pairs of relays defined mutually exclusive so you won't get both relays to turn on at the same time if the up and down buttons are pressed quickly.

    with mutually exclusive relays, doesn't the last energized relay stay closed?

    except if you use total_off, of course.
  • patbpatb Posts: 140
    That only applies to the FEEDBACK for the relays, which I find to be quite useful. If you PULSE a relay that is part of a mutually exclusive group and you have a button that shows feedback, the up or down button will stay on even after the relay itself turns off at the end of the PULSE.
  • HedbergHedberg Posts: 671
    patb wrote: »
    That only applies to the FEEDBACK for the relays, which I find to be quite useful. If you PULSE a relay that is part of a mutually exclusive group and you have a button that shows feedback, the up or down button will stay on even after the relay itself turns off at the end of the PULSE.

    You're clearly correct. I didn't know that about mutually exclusive relays and pulse. I also never realized that relay feedback was different from relay status, but it is. I'm not sure what to make of this new knowledge. It seems troubling to me that by making relays mutually exclusive that the ability to query the status of the relays is lost, but perhaps that ability is superfluous.

    As for having a screen control button stay lit -- we do a lot of screen controls and we've never done one that way. Typically we do screen control button feedback with a "to", screen status being self evident.
  • vegastechvegastech Posts: 369
    So is there a way to change the feedback on said screen buttons when they are part of a MEG? I find it a little unnerving to see a button lit after I let go, especially if I don't see something moving. It makes me think that it's stuck. Can this ONLY be done when NOT using a MEG?

    [edit]
    Took a while, but found it, TOTAL_OFF. Awesome!
    [/edit]
Sign In or Register to comment.