Minimum delay time

Discussion in 'C-Touch/HomeGate/SchedulePlus/PICED Software' started by p0rt3r, Feb 29, 2012.

  1. p0rt3r

    p0rt3r

    Joined:
    Dec 16, 2010
    Messages:
    51
    Likes Received:
    0
    Location:
    Moscow
    Hello!

    What is the smallest amount of time I can use with delay() function? Can I use fraction of a second? The manual tells us that the cycle time is approx 0.2 second, an example in logic manual contains the line "delay(0.2);", but when I try to compile "delay(0.5);" an error appears. What to do?
     
    p0rt3r, Feb 29, 2012
    #1
  2. p0rt3r

    NickD Moderator

    Joined:
    Nov 1, 2004
    Messages:
    1,427
    Likes Received:
    64
    Location:
    Adelaide
    The logic executes every 0.2s, so you can't do a delay of 0.5s, you could have 0.4s or 0.6s though.

    Nick
     
    NickD, Feb 29, 2012
    #2
  3. p0rt3r

    p0rt3r

    Joined:
    Dec 16, 2010
    Messages:
    51
    Likes Received:
    0
    Location:
    Moscow
    Thanks! Tried to compile such lines "delay(0.4);", "delay(0.6);", "delay(1.2);", "delay(10.4);". After all got the same error: "Error C203 at line 783:11 - Constant exceeds range". "Delay(10);" compiled OK. Piced v. 4.10.1.0. So the questions:
    1. Does the logic support delays like fraction of a second?
    2. What is the minimum available delay?
    3. What is the time accuracy in this case? Is it +/- 0.2 second (scan-time) or different?
     
    p0rt3r, Mar 1, 2012
    #3
  4. p0rt3r

    Newman

    Joined:
    Aug 3, 2004
    Messages:
    2,203
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    Yes it does. The delay can be set in 0.2 second increments.
    The smallest delay possible is 0.2 seconds.
    In general the accuracy will be to 0.2 seconds. There are a few exceptional cases where the timer might run a couple tenths long but in general the accuracy is to 1 logic engine cycle, i.e. 0.2 seconds.

    I suspect something else must be up, like a misplaced bracket or something. I just tried all of the combinations you mention and they all worked just fine:
    Code:
     
    delay(0.2);
    delay(0.4);
    delay(0.6);
    delay(1.2);
    delay(10.4);
    
    I have had it occur on extremely rare occasion where the logic engine throws a compilation error despite the syntax being correct. I found that copying the line of logic code to notepad, completely deleting that line of logic in the logic engine, saving, closing and re-opening the project and then pasting in the line of logic once more fixed the problem. Bizarre and not readily understandable I know, but that's what happened to me so it's worth a shot.

    If you are trying to achieve a precise pulse on an output unit by sending C-Bus messages then a word of caution is in order. When the device running the logic engine is required to transmit it there needs to be no other devices transmitting at that time. The logic engine timing is in 0.2s increments. If the bus is busy or there's a status check in progress on the bus then the timing could be extended by up to about 120ms or so, waiting for the message to finish. Then there's the response time of the relay, which varies. Then, if other relays within the same unit are actuated at the same time there may be another tiny delay. If you're using a bus-powered relay then the delay could be up to a further second whilst it re-energises for the next switching operation.... I think you get the point. Trying to perform timing tighter than about 1 second across the bus is going to be a bit hit and miss.

    If you can explain what you're trying to do, we might be able to suggest a better approach.
     
    Last edited by a moderator: Mar 1, 2012
    Newman, Mar 1, 2012
    #4
  5. p0rt3r

    p0rt3r

    Joined:
    Dec 16, 2010
    Messages:
    51
    Likes Received:
    0
    Location:
    Moscow
    Lots of thanks again. But the compilation is unsuccessful. I just added the line "delay(0.4);" to the existing project, saved the project, compiled it. The error "Constant exceeds range" appeared. I closed Piced, then started it again. After the selection of the project, pop-up message "There is a compile error in logic" appeared. There is also the logic option "Enable range checking", it is on by default. Disabling this option had no effect, error didn't gone. This is not the accidental bug in Piced, the error is repeateable surely. This is not the syntax error according to the appearing error description, it is something else. So looking for another suggestions.
     
    p0rt3r, Mar 1, 2012
    #5
  6. p0rt3r

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    Most of the time the compiler will show the exact place in the code at which the error occurs. Sometimes, the error is somewhere close by, but the compiler can not indicate exactly where. This is the most likely cause.

    You could try deleting the delay and see if the logic compiles correctly. If you still can't work it out, send your project to Tech Support, or put the complete code in a post here for us to look at.
     
    Darren, Mar 1, 2012
    #6
  7. p0rt3r

    p0rt3r

    Joined:
    Dec 16, 2010
    Messages:
    51
    Likes Received:
    0
    Location:
    Moscow
    Here is absolutely blank project with two delays. The behavior remains the same: pop-up message with the compile error appears during opening, range error appears after the compilation attempt. The project is as simple as possible: one module, two lines of code. When the line "delay(0.4);" is commented out, compilation becomes successful.
     

    Attached Files:

    p0rt3r, Mar 2, 2012
    #7
  8. p0rt3r

    DarylMc

    Joined:
    Mar 24, 2006
    Messages:
    1,315
    Likes Received:
    49
    Location:
    Cleveland, QLD, Australia
    I'm not even sure that logic should compile but it has and is running for me on Piced 4.10.1.0 and Toolkit 1.11.10 on Windows7 SP1 64 bit.
    The project is PICEDMRA and set for PAC.
    Maybe you should do a File/ Archive/ Export to Archive and post the .cta so someone can import the whole project including Toolkit files and have a look.
     
    DarylMc, Mar 2, 2012
    #8
  9. p0rt3r

    Newman

    Joined:
    Aug 3, 2004
    Messages:
    2,203
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    That project compiles and runs just fine for me.
     
    Newman, Mar 2, 2012
    #9
  10. p0rt3r

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    Me too.

    Post the cta archive (as suggested above) with exact details of the error message.

    Also provide PICED version, and details of operating system.
     
    Darren, Mar 2, 2012
    #10
  11. p0rt3r

    p0rt3r

    Joined:
    Dec 16, 2010
    Messages:
    51
    Likes Received:
    0
    Location:
    Moscow
    Unbelieveable!

    My system: Windows 7 Pro 32-bit ru, Toolkit v.1.11.10, Piced v. 4.10.1.0. cta file is attached. The error in this project is "Error C203 at line 27:7 - Constant exceeds range". The description of this error in Piced's Help is

    But the erroneous delay time is not integer, it is a real number obviously. So according to the help delay function supports only integers as arguments.
     

    Attached Files:

    p0rt3r, Mar 5, 2012
    #11
  12. p0rt3r

    Newman

    Joined:
    Aug 3, 2004
    Messages:
    2,203
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    Left field thought for the day....

    What language is your W7 32-bit set to? If your location/language is set to something other than English (e.g. Russian), is it possible that Windows is using a different system character for the decimal separator, one that PICED doesn't interpret as a decimal separator?
     
    Newman, Mar 5, 2012
    #12
  13. p0rt3r

    p0rt3r

    Joined:
    Dec 16, 2010
    Messages:
    51
    Likes Received:
    0
    Location:
    Moscow
    Location/language is Russia/russian of course. The decimal separator is comma ",". Can this be the clue for such behavior? What to do then?
     
    p0rt3r, Mar 5, 2012
    #13
  14. p0rt3r

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    It is a good thought, but it doesn't look like it would cause the behaviour you are seeing.

    Try using a comma for a decimal separator in your code and see what happens.

    Another thing to try is:

    Code:
    x := 0.4;
    delay(x);
    Or try this:

    Code:
    delay(2/5);
     
    Last edited by a moderator: Mar 6, 2012
    Darren, Mar 5, 2012
    #14
  15. p0rt3r

    p0rt3r

    Joined:
    Dec 16, 2010
    Messages:
    51
    Likes Received:
    0
    Location:
    Moscow
    Hello!

    1. Comma as delimiter causes an error "illegal symbol".
    2. The code

    x : real; in Global Variables section
    x:=0.4;
    delay(x);

    causes the same error "Constant exceeds range".

    3. The code "delay(2/5);" compiles OK. Interested in how this will be working in real life. The line "delay(10/3);" also complies OK. What is real time delay this line will create? It seems to me there is simply no argument checking in this case. So does this error prone?
     
    p0rt3r, Mar 6, 2012
    #15
  16. p0rt3r

    DarylMc

    Joined:
    Mar 24, 2006
    Messages:
    1,315
    Likes Received:
    49
    Location:
    Cleveland, QLD, Australia
    Hello porter
    The .cta imported and the logic ran fine for me.
    I changed my region and language settings, format to Yakut (Sorry I dont know much about Russian if thats the wrong language)
    It uses a comma decimal symbol.
    Then I restarted your project and the logic failed and threw a compile error.
    I think Newman was very much on the right track.
    Perhaps you could change your region and language format to English just to confirm the problem.
    Or try change the decimal symbol on the additional settings tab and see how it goes.
     
    DarylMc, Mar 6, 2012
    #16
  17. p0rt3r

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    I have confirmed that it is definitely the operating system setting for the decimal separator which causes the problem.

    This is issue number 23015 and it will be fixed in the next release of PICED.

    As a work-around, using a fraction (like 1/5) instead of a decimal value (like 0.2) will work correctly.
     
    Darren, Mar 7, 2012
    #17
  18. p0rt3r

    p0rt3r

    Joined:
    Dec 16, 2010
    Messages:
    51
    Likes Received:
    0
    Location:
    Moscow
    Thanks to everybody for this discussion. The issue is clear right now, there is work-around addressing it. Best wishes to CIS developers and support. Looking for new releases.
     
    p0rt3r, Mar 7, 2012
    #18
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.