PAC Logic Timer

Discussion in 'C-Touch/HomeGate/SchedulePlus/PICED Software' started by Lucky555, Jan 20, 2009.

  1. Lucky555

    Lucky555

    Joined:
    Aug 13, 2007
    Messages:
    229
    Likes Received:
    0
    Hello fellow C-Bus Logic coders and or Darren (if I am lucky)...

    I have display requirement where an event starts a PAC Logic Timer.

    I would like to pulse a C-Bus GA (same GA each time) every 4th second of the timer for a period of about 5 minutes.

    What is the most efficient way to code this ???
     
    Lucky555, Jan 20, 2009
    #1
  2. Lucky555

    filpee

    Joined:
    May 31, 2006
    Messages:
    204
    Likes Received:
    0
    Location:
    Western Australia
    Dont know if its the most efficient but how about

    if (timerTime(timer) % 4) == 0 then pulse GA

    mod divide the current timerTime by 4, if the remainder is 0 then it divides by 4 correctly so pulse the GA.

    obviously my syntax is wrong and I dont know if mod divide is supported but it was the first thing that sprung to my mind.

    //timerTime>1 because if the timer is 0 then mod 4 will probably also equal 0 and cause a cbus command on every loop
    //another option would be to put this in a module and enable/disable that when the timer is running/not running
    if ((timerTime(timer) mod 4) = 0) AND (timerTime(timer)>1) then
    begin
    PulseCBusLevel("network", "application", "group", 100%, "0s", "0:00:02", 0%);
    end;
     
    Last edited by a moderator: Jan 20, 2009
    filpee, Jan 20, 2009
    #2
  3. Lucky555

    Lucky555

    Joined:
    Aug 13, 2007
    Messages:
    229
    Likes Received:
    0
    Thanks filpee, I will give that a crack and let you know - that is if we don't hear from Daren before hand as to whether it is supported.
     
    Lucky555, Jan 21, 2009
    #3
  4. Lucky555

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    filpee has it essentially correct. Obviously he has done programming in C before.

    Try this:
    Code:
    once TimerRunning(1) and (TimerTime(1) mod 4 = 0) then
    begin
      PulseCBusLevel("Local", "Lighting", "Group 1", 100%, "0s", "0:00:01", 0%);
      if TimerTime(1) > "0:05:00" then
        TimerStop(1);
    end;
     
    Darren, Jan 21, 2009
    #4
  5. Lucky555

    Lucky555

    Joined:
    Aug 13, 2007
    Messages:
    229
    Likes Received:
    0
    filpee - thanks again that worked fine...

    if ((TimerTime(TimerAlarm) mod 4) = 0) AND (TimerRunning(TimerAlarm)) then
    begin
    PulseCBusLevel("LOCAL", "Lighting", "Test1", 100%, "0s", "0:00:02", 0%);
    end;
     
    Lucky555, Jan 21, 2009
    #5
  6. Lucky555

    Lucky555

    Joined:
    Aug 13, 2007
    Messages:
    229
    Likes Received:
    0
    Whilst writing the post above Darren slipped a post in.

    Thank guys... ;)
     
    Lucky555, Jan 21, 2009
    #6
  7. Lucky555

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    You will need to make sure that you use "once", not "if", otherwise you will get 5 C-Bus pulses sent in a row (the logic engine runs 5 times per second).
     
    Darren, Jan 21, 2009
    #7
  8. Lucky555

    Lucky555

    Joined:
    Aug 13, 2007
    Messages:
    229
    Likes Received:
    0
    Thanks Darren - I am always very careful using if in C-Bus Logic especially if the action is a C-Bus message.

    When I wrote the real code for the project where I also dealt with the timer as per your suggestion I definitely used "once" a you pointed out.

    Thanks again, I knew there would be a very simple math based solution for this.
    ;););)
     
    Lucky555, Jan 21, 2009
    #8
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.