Home AMX User Forum NetLinx Studio

Problems with the delay

Dear all,

I am working with a Ademco Vista Security System and a AMX system which control the lighting of the house.

I send, by AMX, in each 5 seconds, a string by serial interface to the Ademco Vista requesting the report of all zones of the security system.

Like this:

IF (WAITING=0)
{
WAITING=1
SEND_STRING ALARME_RS,"'08zs004B',13"
WAIT 50
{WAITING=0}
}

Here I get the report and divide it for show the status of the windows and doors in Modero panels, if open, closed...etc



The problem is that 5 seconds is a big delay for the answer in the panels, and if I use a lower time for send the request, the lighting of the house has a big dalay too...I think is that the AMX is so busy...I think so

Someone has some ideia for eliminate the delay to request the status of the zones without to harm the lighting system?

Thank you very much

Comments

  • GSLogicGSLogic Posts: 562
    You should only get information sent from the security panel when changes happen. You are ask the security panel to report every 5 seconds which will slow everything down. One other thing, don't send information to a touchpanel if it's not viewing the security section.
  • mpullinmpullin Posts: 949
    Ademco claims that the 'AS' and 'zs' queries should be used once only, and not as a polling command. In practice, the information that should come to the AMX Master by itself when alarm panel changes happen, never come, and need to be solicited. Ademco has been very slow to get back to me on this issue.

    So there is some polling that needs to be done, but you need to be careful. Test the alarm liberally, if you poll it too much it will interfere with the alarm's ability to dial out. This is what happens when you put RS-232 control into your product as an afterthought, IMHO.
  • Chip MoodyChip Moody Posts: 727
    And not for nothing, but

    WAIT 50 SEND_STRING Dev,'blah'

    shrinks the code you have down by several lines and works the same...

    - Chip
  • ericmedleyericmedley Posts: 4,177
    The Ademco is pretty slow and doesn't like polling. I don't think it's AMXs fault in this case. I can't even imagine one controlling lights.
    creepy...
  • SensivaSensiva Posts: 211
    m.quinti wrote:
    IF (WAITING=0)
    {
    WAITING=1
    SEND_STRING ALARME_RS,"'08zs004B',13"
    WAIT 50
    {WAITING=0}
    }

    Would you please tell us, Which section is this code added to?

    If in Define_Program, I think your master is suffering a never ending nightmare.
  • Joe HebertJoe Hebert Posts: 2,159
    Sensiva wrote:
    If in Define_Program, I think your master is suffering a never ending nightmare.
    Only if it considers the execution of the SEND_STRING once every 5 seconds frightening. :)
  • On this note, Does anyone have a better way of delaying a repeating string. I'm using something similar to find out the state of NEC Projectors.

    DEFINE_PROGRAM

    IF (ASKPROJ = 0)
    {
    ASKPROJ = 1
    WAIT 50
    {
    SEND_STRING dvLCDProjector,"$00,$85,$00,$00,$01,$01,$87"
    ASKPROJ = 0
    }
    }

    This seems to work just fine and doesnt seem to completely gum up the processing speed, but I would love to be able to get away from making an IF comparative every time it runs through the main line of code. Any ideas?
  • SensivaSensiva Posts: 211
    Timeline
    mschardt wrote:
    On this note, Does anyone have a better way of delaying a repeating string. I'm using something similar to find out the state of NEC Projectors.

    >>>>>>

    This seems to work just fine and doesnt seem to completely gum up the processing speed, but I would love to be able to get away from making an IF comparative every time it runs through the main line of code. Any ideas?

    Although there is no reason to dislike this( as Joe Hebert mentioned ), but I don't like it t00 , so I create a timeline to poll all devices status every 5 or 10 seconds
  • AMXJeffAMXJeff Posts: 450
    Not to say the same thing that Chip did, but when he is right, he is right!!!! You do not need the variable or the if. This does the exact same thing as your code does. Your wait will not be put in the wait list again until the wait has expired. so this string will be sent every 5 seconds.

    WAIT 50
    {
    SEND_STRING dvLCDProjector,"$00,$85,$00,$00,$01,$01,$87"
    }

    mschardt wrote:
    On this note, Does anyone have a better way of delaying a repeating string. I'm using something similar to find out the state of NEC Projectors.

    DEFINE_PROGRAM

    IF (ASKPROJ = 0)
    {
    ASKPROJ = 1
    WAIT 50
    {
    SEND_STRING dvLCDProjector,"$00,$85,$00,$00,$01,$01,$87"
    ASKPROJ = 0
    }
    }

    This seems to work just fine and doesnt seem to completely gum up the processing speed, but I would love to be able to get away from making an IF comparative every time it runs through the main line of code. Any ideas?
  • SensivaSensiva Posts: 211
    Why?
    AMXJeff wrote:
    Your wait will not be put in the wait list again until the wait has expired. so this string will be sent every 5 seconds.

    So , What would prevent the wait from being added to the list?
  • Spire_JeffSpire_Jeff Posts: 1,917
    I am using the Ademco FBP128 and FBP250 panels quite a bit recently. The new protocol they released about a year ago changed enough to break all of the old comm modules that were developed. I'm not sure if the most recent comm module handles the zone feedback correctly yet as I have written my own code to parse that information.

    That being said, most of the time there is only about a 1-2 second delay from the time a motion sensor is tripped until the time it is reported by the panel. I have noticed that occasionally an event is lost when there are multiple events happening at once. I am toying with the idea of polling every 5-15 minutes just to catch those occasional misses, but as was said earlier, polling definitely breaks any dial out communication. I am also thinking that I might be able to monitor for call back requests and program mode entry/exits that will disable the polling to help alleviate some of the problems caused by polling.

    If the alarm panel is not sending the information automatically, you either have the old firmware, or the settings on the alarm panel aren't correct. Make sure that the following are set:

    *05 = 1
    *14 = 1
    1*78 = 1
    1*79 = 1
    2*30 = 0
    3*19 = 1

    Those are the settings I normally use and they work well.

    Ohhh, also be sure to make your own serial wire. I just tried an FBP250 on my test bench with the wires that are included and it wouldn't work until I put a custom cable in the mix.

    Jeff
  • AMXJeffAMXJeff Posts: 450
    The fact that it is already in the list. NetLinx checks to see if the wait is in the list already, it wont get removed from the list until time has expired.
    Sensiva wrote:
    So , What would prevent the wait from being added to the list?
  • SensivaSensiva Posts: 211
    Nopeee
    AMXJeff wrote:
    The fact that it is already in the list. NetLinx checks to see if the wait is in the list already, it wont get removed from the list until time has expired.

    No, this is not right, the wait will be added to the list no matter what, I have tried it by my self, If you are right , then tell me how can NetLinx identify if this wait already there or not. and support your idea with a document :)
  • mpullinmpullin Posts: 949
    Sensiva wrote:
    No, this is not right, the wait will be added to the list no matter what, I have tried it by my self, If you are right , then tell me how can NetLinx identify if this wait already there or not. and support your idea with a document :)
    NL assigns each wait an id at compile time.
  • AMXJeffAMXJeff Posts: 450
    I am right..try it again...NetLinx will NOT add the wait to the list if it is currently in the list. It stays in the list until expired. No document needed!!!!!!!!!!!!!!!!!!!!!!!!!!
    Sensiva wrote:
    No, this is not right, the wait will be added to the list no matter what, I have tried it by my self, If you are right , then tell me how can NetLinx identify if this wait already there or not. and support your idea with a document :)
  • Joe HebertJoe Hebert Posts: 2,159
    Sensiva wrote:
    No, this is not right, the wait will be added to the list no matter what, I have tried it by my self, If you are right , then tell me how can NetLinx identify if this wait already there or not. and support your idea with a document :)
    Load this program and you'll see that the SEND_STRING 0 only happens once every 5 seconds

    DEFINE_PROGRAM

    WAIT 50 SEND_STRING 0, 'AMXJeff is correct!'
  • Spire_JeffSpire_Jeff Posts: 1,917
    Here is some documentation that I found:

    http://www.amx.com/techsupport/techNote.asp?id=208

    You could also name the WAIT statement which allows you to pause and cancel the WAIT in addition to only executing one instance of the wait:
    Naming Waits
    Supplying a unique name in the wait statement allows the wait to be identified for purposes of canceling, pausing or restarting the wait request. The name must not conflict with previously defined constants, variables, buffers, subroutines, or functions. Unlike other NetLinx identifiers, wait names may contain spaces.

    If a wait instruction that uses a name currently in the wait list is encountered, the new wait instruction is thrown away, so as not to conflict with the one currently in progress. If this feature is not desired, the current wait must be canceled before processing the new request. For information, refer to the Canceling Waits sub-section below.
  • You need a queue. Polling every 5 seconds is a fine thing, but what if you happen at that moment to have sent another command and you are waiting for its response?
  • Jeff BJeff B Posts: 37
    You need a queue. Polling every 5 seconds is a fine thing, but what if you happen at that moment to have sent another command and you are waiting for its response?

    A queue is fine if you have the time to set it up.

    I just name the wait and then CANCEL_WAIT before sending a command.

    Polling will start again next time through main line.

    Quick, dirty, simple, and works.
  • Jeff B wrote:
    A queue is fine if you have the time to set it up.

    You only have to code your queue include once; then you can use it as many times as you like for the rest of your career.
  • SensivaSensiva Posts: 211
    I'll Check

    I'll Check and reply back in a different thread, we are already off topic

    Thanks Jeff
  • You are incorrect. An unnamed wait is still tracked internally by the compiler - if it is pending (already on the WAIT list) it will NOT re-enter itself.

    If that were not the case, the classic "blink" code from the dawn of forever would not work:
    WAIT 5 FLASH = !FLASH
    
    [TP,ErrorButton] = (ErrorStateExists AND FLASH)
    

    When ErrorStateExists is non-zero, the button on TP with channel ErrorButton will blink on and off with half-second cycles. If what you believe was in reality correct, the button would blink extremely erratically.

    - Chip

    Sensiva wrote:
    No, this is not right, the wait will be added to the list no matter what
  • yuriyuri Posts: 861
    use a timeline. it can be paused, restarted, etc...
    furthermore, do what others have said. Only check status when entering the "security" page :)
  • Interesting debate Sensiva and AMX Jeff. I would have assumed that calling a WAIT 50 in the mainline of code would have called a new wait every time it passed that section of code. I''m going to give that a try this and watch the feedback in debug.

    As for using Timelines, maybe its just me but i cant stand using them. At least in the form that I have used them, by creating timeline arrays, and constants. It just seems to go a bit overly complicated for something as simple as repeating a RS232 String.
  • Joe HebertJoe Hebert Posts: 2,159
    mschardt wrote:
    Interesting debate Sensiva and AMX Jeff. I would have assumed that calling a WAIT 50 in the mainline of code would have called a new wait every time it passed that section of code. I''m going to give that a try this and watch the feedback in debug.
    There is no debate. AMXJeff is indisputably correct. Seeing with your own eyes though always helps.
Sign In or Register to comment.