Can anybody see the fault with this PICED logic?

Discussion in 'C-Touch/HomeGate/SchedulePlus/PICED Software' started by jdriver, Jan 26, 2014.

  1. jdriver

    jdriver

    Joined:
    Oct 24, 2013
    Messages:
    4
    Likes Received:
    0
    Location:
    UK
    I have been struggling with this bit of code all day, and just can't see what the problem is.
    I have set up a DLT button called 'Theatre Heating' it has a 4s timer on it and then runs this code below:
    {When button pressed in theatre heating goes until for a 10 minutes, unless it reaches target temp }

    once (GetLightingState("Theatre Heating") = ON) then
    begin
    TimerStart(2);
    while TimerTime(2)< 600 do
    begin
    if (GetRealIBSystemIO("HVAC Temperature", 2, HVACZone3) <= HouseTargetTemp) then
    begin
    SetCBusState("LONGHEADS", "Heating Zones", "Theatre",ON);
    end
    else
    begin
    SetCBusState("LONGHEADS", "Heating Zones", "Theatre",OFF);
    end;
    end;
    SetCBusState("LONGHEADS", "Heating Zones", "Theatre",OFF);
    TimerStop(2)
    end;

    The code is not turning on the heating valve or even showing the valve to be actuated on the WISER web interface. I have tried breaking it in to smaller segments and still got nowhere. I know that the identities are correct as I have proven that in other modules.
     
    jdriver, Jan 26, 2014
    #1
  2. jdriver

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    Firstly if you are running this inside PICED make sure you are connected to Cbus (OPTIONS/CONNECT TO CBUS) or nothing will happen.

    Otherwise most likely the IF statement is never being satisfied. If you open a logging window (view/log) you can see what's happening. This will also show you a serious problem with your logic.

    Once the While statement is entered, it will try and continually output Cbus commands at a huge rate for the next 6 minutes. The logic engine will abort the module after a few hundred milliseconds and then it won't run again until the next key press.

    Loops inside logic must be handled with care and knowledge of how the modules are executed.

    Start by adding a delay (say 10 seconds) inside the loop. The logic engine will then pause the module and continue it at the same spot after the delay time. There are better ways of handling this type of problem though. I'll post an example when I have a bit more time.


    The LogMessage procedure is very useful to print values inside logic.
     
    Last edited by a moderator: Jan 27, 2014
    Ashley, Jan 27, 2014
    #2
  3. jdriver

    jdriver

    Joined:
    Oct 24, 2013
    Messages:
    4
    Likes Received:
    0
    Location:
    UK
    Hi Ashley,
    Thanks for the reply. I have now put a 2 minute delay immediately after setting the heating ON or OFF and it works! I should have tried this before as I use it for the routine heating in other areas of the house. I was going to put it in this code 'after I had got it working'. I really want to set this routine to run for 3 hours not 10 minutes, that was just to test it out.

    I haven't seen the flooding of the controller you mentioned documented in the manuals, is there anything else like this I should be aware of?

    I haven't managed to get LogMessage working. Can you point me to a relevant area of the manual?

    If there is a better way to control heating valves by testing temperature and time I would love to be told...

    Best regards
    Julian
     
    jdriver, Jan 27, 2014
    #3
  4. jdriver

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    You need to enable logic debug messages in the event log. Open the log and click on the OPTIONS tab. Select "Show Logic Debug Messages".

    Unlike most programming languages, the Logic Engine is not event driven, it is a purely polled environment. Each module is executed in sequence every 200mS unless suspended by a delay command. All modules must complete execution within this 200mS time allotment or they will be cancelled. There are certain conditions under which modules are allowed extra time (e.g. setting a large scene), but on average they must all complete withing this 200mS window. This means you can't just loop for extended periods without inserting a delay or waitFor, and even then this is not the best way to handle these type of problems.

    When you set a Cbus level in logic it will be transmitted onto the bus irrespective of its current level. i.e. the logic engine does not suppress a set state on if the state is already on etc. There are good reasons for this behavior. This is the reason the ONCE command was implemented. Setting a state inside a ONCE condition ensures it will not be continuously output. e.g the statement IF group = on then setCbusState etc would issue the set state command every 200mS all the while the If group was on. The logic engine will detect cbus commands being issued every scan and abort the module. It is always a good idea to look at the log file which will show you the frequency of cbus commands being issued.
     
    Ashley, Jan 31, 2014
    #4
  5. jdriver

    poldim

    Joined:
    Dec 7, 2010
    Messages:
    166
    Likes Received:
    2
    Location:
    San Francisco, CA
    Any chance you want to circle back on this?
     
    poldim, Nov 2, 2016
    #5
  6. jdriver

    Ingo

    Joined:
    Dec 2, 2006
    Messages:
    290
    Likes Received:
    1
    Location:
    South Africa
    I would probably add a check to see if the "Theatre" group is already On or not. If already On then skip it, don't send another On command.
     
    Ingo, Nov 2, 2016
    #6
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.