logic module scan frequency appears to vary from 5Hz

Discussion in 'C-Touch/HomeGate/SchedulePlus/PICED Software' started by simonhac, Jan 17, 2017.

  1. simonhac

    simonhac

    Joined:
    Jan 8, 2017
    Messages:
    51
    Likes Received:
    0
    Location:
    Melbourne
    i have a project with a SytemIO variable called heaterTicks. it keeps track of how much longer (in counts of 200ms duration ticks) to run a hydronic boiler. the specific application requires that the heater runs no more than 72 hours without being reenabled (since the LPG powering the heater is very expen$ive). i'm using my own ticker variable because the built in timers can't handle times up to 72 hours.

    my logic relies upon a module being run every 200ms (i.e. 5Hz), which i can see happens in PICED. however i?m finding that on the MKII controller the module appears to be scanning much less frequently, closer to 1Hz.

    according to the logic manual (pg. 6):

    (a similar thing is said on pg 21.

    i?m showing the progress of the ticker with am ASCII-art spinner ? yes, old school, but that?s the aesthetic that i?m after, and has the advantage of providing a ?heartbeat? to show that the heating is on. here?s what it looks like:

    spinner.gif

    oddly, i find that while i hold down a button on the touchscreen, the animation scan frequency jumps back up to 5Hz, and reverts to c. 1 Hz when i release the button.

    does the MKII have an ?idle? or ?power saving? mode that i?m running into. any ideas?

    thanks,
    simon


    ps. according to PICED, i'm only using a tiny fraction of the resources of the system:

    resources.png

    so i don?t believe that i?m coming close to overloading the processor.


    my logic is very simple. a main module calls`decrementHeater` every scan:

    Code:
    procedure decrementHeater;
    var
      ticks: integer;
    begin
    // decrement counter if active
      ticks := GetIntSystemIO("heaterTicks");
      if (ticks > 0) then
      begin
        SetIntSystemIO("heaterTicks", ticks - 1);
        updateHeaterIO;
      end;
    end;
    
    when the counter is above zero, that procedure calls updateHeaterIO:

    Code:
    procedure updateHeaterIO;
    var
      days: integer;
      hours: integer;
      minutes: integer;
      seconds: integer;
      ticks: integer;
      durationStr: string;
      hoursStr: string;
      minutesStr: string;
      
    begin
      ticks := GetIntSystemIO("heaterTicks");
      seconds := (ticks div kTicksPerSecond) mod 60;
      minutes := (ticks div kTicksPerMinute) mod 60;
      hours := ticks div kTicksPerHour mod 24;
      days := ticks div kTicksPerDay;
    
      format(durationStr, days:1, 'd ');
    
      if hours < 10 then
      begin
        append(durationStr, '0');
      end;
      format(hoursStr, hours:1, 'h ');
      append(durationStr, hoursStr);
      
      if minutes < 10 then
      begin
        append(durationStr, '0');
      end;
      format(minutesStr, minutes:1, 'm ');
      append(durationStr, minutesStr);
    
      if (ticks < 10) then
      begin
        append(durationStr, ' ')
      end
      else
      begin
        case (ticks mod 4) of
          0: append(durationStr, '|');
          1: append(durationStr, '\');
          2: append(durationStr, '-');
          3: append(durationStr, '/');
        end;
      end;
    
      // WriteLn(hours, 'h', minutes, 'm', seconds, 's (', ticks, 't)', durationStr);
      SetIntSystemIO("heaterSeconds", seconds);
      SetStringSystemIO("heaterDisplay", durationStr);
    end;
    
     
    simonhac, Jan 17, 2017
    #1
  2. simonhac

    simonhac

    Joined:
    Jan 8, 2017
    Messages:
    51
    Likes Received:
    0
    Location:
    Melbourne
    some browsers will show an looping animated gif for this:
    spinner.gif
     
    simonhac, Jan 17, 2017
    #2
  3. simonhac

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    I tried this and got the same result. However I then added another routine to print out the tick value every second and it updates by 5 each time which indicates the logic is in fact running every 200mS. I think the problem you are experiencing is with the display update rate and not the logic. Why it updates faster when a button is pressed would be a good question for the designers.

    If you really want the spinner I suggest you just create an animated gif.

    Also, given you don't really need tick resolution you can trigger a routine say every minute with ONCE SECOND = 0 THEN etc
     
    Ashley, Jan 17, 2017
    #3
  4. simonhac

    simonhac

    Joined:
    Jan 8, 2017
    Messages:
    51
    Likes Received:
    0
    Location:
    Melbourne
    thanks ashley for going to the trouble of running a test -- greatly appreciated. nice catch. so it looks like the screen buffer flush frequency changes, probably depending on whether the panel 'thinks' it is under active use.

    a shame that PICED doesn't emulate this and that this is not obvious in the docs, but i admit that what i'm doing is a bit unusual. that said, it's very cool to have dynamic strings -- makes the controller feel more 'fun'.

    it's a pretty fiddly, but i guess i could use an animated gif on the MKII. thanks for the idea.

    if there's a designer reading this (or you know one, ashley?), is there a command or some other way to force frequent screen flushing?

    nice snippet -- thank you. my logic currently requires second accuracy because i use it for a little bit of hysteresis to stop the boiler being switched off and coming back on when the user hits a `reset` closely followed by a `+12 h`. i guess i could check for something like:

    Code:
    ONCE lastSecond != SECOND then
    begin
     lastSecond = SECOND;
     doSomething;
    end;
    
    thanks again ashley -- much appreciated.
     
    simonhac, Jan 17, 2017
    #4
  5. simonhac

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    I would assume the screen update rate is just a function of the processing power available (not much in a MKII touchscreen :) ). Running PICED on a desktop has a whole lot more grunt available to it. The touchscreens were probably never intended for programmed animations.
     
    Ashley, Jan 18, 2017
    #5
  6. simonhac

    simonhac

    Joined:
    Jan 8, 2017
    Messages:
    51
    Likes Received:
    0
    Location:
    Melbourne
    thanks ashley, since the display appears able to update at 5Hz when a button is actively held down, it would seem that the processor and screen are able to support that rate -- but perhaps it is at the limit and other compromises are made that can't be sustained for long...

    i don't know, but if any c-bus engineers with intimate knowledge of this are monitoring this thread, please feel free to chime in! (please also consider adding a comment to a logic FAQ explaining what's going on.)
     
    simonhac, Jan 18, 2017
    #6
  7. simonhac

    simonhac

    Joined:
    Jan 8, 2017
    Messages:
    51
    Likes Received:
    0
    Location:
    Melbourne
    @ashley is there anyone you can ask about how to force a 5 Hz screen refresh?
    much appreciated,
    simon
     
    simonhac, Jan 24, 2017
    #7
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.