Logic error

Discussion in 'C-Touch/HomeGate/SchedulePlus/PICED Software' started by brodsky, Feb 16, 2010.

  1. brodsky

    brodsky

    Joined:
    Mar 10, 2005
    Messages:
    138
    Likes Received:
    0
    Hi,

    I have installation with PAC unit and MK2 touch screen without logic. The client requires irrigation control, but obviously there is no irrigation manager.
    We have 20 irrigation zones.

    I'm trying to use the binary principle to allow irrigation times to be set from 1 minute up to 31 minutes. See screenshot of touch screen page.

    The code written does work, but I'm unable to do all 20 zones as I get
    the following error: R199 : Logic has taken too long.
    The code is way too much for the PAC unit.

    Could you please guide me to try and write the code more efficient to actually work with PAC.

    The code looks like this;

    {Set Irrigation counter values for each integer}
    once (GetLightingState("IT1-swembad") = ON)then
    begin
    IrrCounter1:=1;
    end;

    once (GetLightingState("IT1-swembad") = OFF)then
    begin
    IrrCounter1:=0;
    end;

    once (GetLightingState("IT2-swembad") = ON)then
    begin
    IrrCounter2:=2;
    end;

    once (GetLightingState("IT2-swembad") = OFF)then
    begin
    IrrCounter2:=0;
    end;

    once (GetLightingState("IT4-swembad")= ON)then
    begin
    IrrCounter4:=4;
    end;

    once (GetLightingState("IT4-swembad") = OFF)then
    begin
    IrrCounter4:=0;
    end;

    once (GetLightingState("IT8-swembad") = ON)then
    begin
    IrrCounter8:=8;
    end;

    once (GetLightingState("IT8-swembad") = OFF)then
    begin
    IrrCounter8:=0;
    end;

    once (GetLightingState("IT16-swembad") = ON)then
    begin
    IrrCounter16:=16;
    end;

    once (GetLightingState("IT16-swembad") = OFF)then
    begin
    IrrCounter16:=0;
    end;




    {Once "Start" button is activated, sumtotal of irrigation timers is calculated}
    once(GetLightingState("Istart-swembad") = ON)then
    begin
    IrrCounterT:= IrrCounter1+IrrCounter2+IrrCounter4+IrrCounter8+IrrCounter16;
    end;

    {Irrigation timers set}
    once(GetLightingState("Istart-swembad") = ON)then
    begin
    if IrrCounterT=0 then
    begin
    SetLightingState("I_Swembad Area", OFF);
    ExitModule;
    end;
    end;

    once(GetLightingState("Istart-swembad") = ON)then
    begin
    if IrrCounterT=1 then
    begin
    PulseCBusLevel("Local", "Lighting", "I_Swembad Area", 100%, 0, "0:01:00", 0%);
    ExitModule;
    end;
    end;

    once(GetLightingState("Istart-swembad") = ON)then
    begin
    if IrrCounterT=2 then
    begin
    PulseCBusLevel("Local", "Lighting", "I_Swembad Area", 100%, 0, "0:02:00", 0%);
    ExitModule;
    end;
    end;


    This code is repeated for every minute up to 31 minutes, and this is duplicated in 20 different modules for the different zones.

    Please help!

    Thanks,
    Brodsky
     

    Attached Files:

    • PAC1.JPG
      PAC1.JPG
      File size:
      44.2 KB
      Views:
      562
    brodsky, Feb 16, 2010
    #1
  2. brodsky

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    Why not just use a group address to control the irrigation time?

    You could set the level of the group using nudge up and down on C-Touch and the PAC could read the level of this group and use it as a time value.
     
    Darren, Feb 16, 2010
    #2
  3. brodsky

    ashleigh Moderator

    Joined:
    Aug 4, 2004
    Messages:
    2,397
    Likes Received:
    26
    Location:
    Adelaide, South Australia
    Darren: What a hideous grotty hack.

    A suppose it would work. Still grotty though.
     
    ashleigh, Feb 16, 2010
    #3
  4. brodsky

    brodsky

    Joined:
    Mar 10, 2005
    Messages:
    138
    Likes Received:
    0
    Hi, Darren I have 2 problem.
    1) I can't get the nudge up and down functions to work.
    2) The logic does not seem to work consistently.

    Is there any sample of the above somewhere that I can use as a reference?

    Appreciate the feedback.
     
    brodsky, Feb 17, 2010
    #4
  5. brodsky

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    Unfortunately, I don't have access to a computer with PICED on it at the moment, so I will have to do this from memory.

    On the Black and White C-Touch, place a couple of buttons on a page. Set them to use the nudge up and nudge down key functions respectively. Set the "level" (the nudge amount) to 1 (not 1 %). Set them to control a group which I will call "Irrig Time" for the sake of this post. This group level will be the time in minutes.

    Place a level indicator component on the page. Set it to show the status of the "Irrig Time" group address. On the "value" tab, select "group address level" (not percent).

    You will now be able to nudge up and down the "Irrig Time" group by 1 and see the current value.

    In the PAC logic, you can just have something like:

    Code:
    once(GetLightingState("Istart-swembad") = ON)then
    begin
      if GetLightingLevel("Irrig Time") > 0 then
      begin
        PulseCBusLevel("Local", "Lighting", "I_Swembad Area", 100%, 0, GetLightingLevel("Irrig Time")  * 60, 0%);
      end;
    end;
    As Ashleigh says, this is a dodgy hack, but it will work fine.
     
    Darren, Feb 17, 2010
    #5
  6. brodsky

    brodsky

    Joined:
    Mar 10, 2005
    Messages:
    138
    Likes Received:
    0
    Hi, Darren

    It seems to be working fine. Exactly what I want to achieve.:)

    Regards,
    Brodsky
     
    brodsky, Feb 18, 2010
    #6
  7. brodsky

    brodsky

    Joined:
    Mar 10, 2005
    Messages:
    138
    Likes Received:
    0
    Hi all,

    Still with the irrigation...
    The scenario;

    I use one module in my logic engine to enable and disable another module.

    The problem is that, on re-enabling, the disabled module just continues from the point it was when I disabled it and I don't want it to run until it receives a user input.

    Please advise.

    Thanks
    Brodsky
     
    brodsky, Mar 23, 2010
    #7
  8. brodsky

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    This might happen if the module which is disabled was in some sort of a delay at the time (either a Delay function or a WaitUntil). Is that what was happening?

    Ideally, provide an extract of the code showing where it resumed from.
     
    Darren, Mar 24, 2010
    #8
  9. brodsky

    brodsky

    Joined:
    Mar 10, 2005
    Messages:
    138
    Likes Received:
    0
    H Darren,

    This module force all zones to stop;

    "Istop_111" is the force stop button.
    "Iswitch_167" switch toggles between manual or scheduled irrigation pages.
    "Stop Irrigation" just shuts down all zones.


    This module disables the scheduled irrigation module to avoid scheduled activity when manually watering the plants.


    This is the problem child. The OFF state of the trigger button (bell press) and the irrigation zone, triggers the next zone etc. The "Istart-xxx" buttons are the triggers.

    Thanks
    Brodsky
     
    brodsky, Mar 24, 2010
    #9
  10. brodsky

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    Is the last module you listed the one called "sequencing" ?

    You may not get what you expect by having "once" inside a module which gets disabled. The "once" compares the condition each loop with the last time that the condition was evaluated. If the module has been disabled for a period, then the last time that the condition was evaluated would have been just before the module was disabled.

    If the once condition is false, then the module gets disabled and the condition becomes true while the module is disabled (even though the condition does not actually get evaluated), then when the module is enabled again, the once will be executed because it has seen the condition go from false to true.

    Could this be the cause of your problem?
     
    Darren, Mar 25, 2010
    #10
  11. brodsky

    brodsky

    Joined:
    Mar 10, 2005
    Messages:
    138
    Likes Received:
    0
    Hi Darren,

    Yes, the last listed module is the "sequencing" module. I also believe that to be the problem.

    My next obvious question is; How do I get around this without major code rewrite?

    Regards,
    Brodsky
     
    brodsky, Mar 25, 2010
    #11
  12. brodsky

    brodsky

    Joined:
    Mar 10, 2005
    Messages:
    138
    Likes Received:
    0
    Hi Darren,

    In addition to my last post. Are there any plans to expand the irrigation manager in CTC to cover more zones?

    This installation has 20 zones and I believe that an upsell to CTC with the expanded capacity will solve all my headaches.

    Thanks
    Brodsky
     
    brodsky, Mar 25, 2010
    #12
  13. brodsky

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    It is hard to say without knowing exactly what you are wanting to do and seeing the rest of the code.
     
    Darren, Mar 25, 2010
    #13
  14. brodsky

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    Seeing as you asked so nicely, I will update it in the next release :)
     
    Darren, Mar 25, 2010
    #14
  15. brodsky

    brodsky

    Joined:
    Mar 10, 2005
    Messages:
    138
    Likes Received:
    0
    Hi Darren,

    The whole story is sent as private message.

    Regards,
    Brodsky
     

    Attached Files:

    brodsky, Mar 29, 2010
    #15
  16. brodsky

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    In your code you are pulsing C-Bus groups and using the falling edge of one pulse to trigger the next. This will only work in the following circumstances:
    1. All zones have a time > 0
    2. The zones are never switched manually

    The other problem is that each zone has separate code. This makes additions and changes very hard.

    A better way to do this is to write a small bit of code which does all of the timing and zone switching for you. By looping through a list of zones, the logic is much smaller. Adding additional zones does not change the size of the code.

    I have attached an example project showing this. To fully meet your requirements, you will need to:
    1. Increase from 4 to 20 zones
    2. Add a second irrigation "program" to cater for different watering requirements on different days.
     

    Attached Files:

    Darren, Mar 30, 2010
    #16
  17. brodsky

    brodsky

    Joined:
    Mar 10, 2005
    Messages:
    138
    Likes Received:
    0
    Thanks Darren,

    I'll have a look and keep you posted.

    Appreciate the input.

    Cheers,
    Brodsky
     
    brodsky, Mar 30, 2010
    #17
  18. brodsky

    brodsky

    Joined:
    Mar 10, 2005
    Messages:
    138
    Likes Received:
    0
    Hi Darren,

    Thanks for the pointer, the program works like a charm.

    I do have a glitch though and it has to do with the multiple schedules?

    Do you mind just helping me in the right direction again?

    Regards,
    Brodsky
     
    brodsky, Apr 12, 2010
    #18
  19. brodsky

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    You will need to basically duplicate all of the code and components so that you have a second, independent, irrigation controller. The two can then have different settings for use on different days.

    The tidiest way to do it would be to use a two dimensional array to store the irrigation times for each "irrigation program", but this might make it more complex in other ways.

    I am not sure if you noticed, but colour C-Touch now supports over 20 irrigation zones.
     
    Darren, Apr 14, 2010
    #19
  20. brodsky

    brodsky

    Joined:
    Mar 10, 2005
    Messages:
    138
    Likes Received:
    0
    IM on Monochrome MK2

    Hi Darren,

    Thanks for your input on this irrigation issue.
    It seems to be working ok.

    Just a question; What will it take to include a full version of Irrigation Manager on the monochrome screen with logic?

    Will you guys consider it?

    Regards,
    Brodsky
     
    brodsky, May 25, 2010
    #20
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.