Temperature Control Logic Troubles

Discussion in 'C-Touch/HomeGate/SchedulePlus/PICED Software' started by jakelanauze, Dec 19, 2013.

  1. jakelanauze

    jakelanauze

    Joined:
    Apr 19, 2013
    Messages:
    14
    Likes Received:
    0
    Location:
    Dunedin NZ
    Hi All.

    I'm having a wee bit of trouble sorting out some logic to control under tile heating in four zones in a house.

    All zones will ultimately function the same but just need a wee bit of help getting sorted as I have done very minimal work with logic, and touchscreens for that matter.

    What I'm doing is controlling 1 GA on and off via some logic, and then controlling when that logic can run via a schedule.

    This is what I have got for my code to turn the GA on and off.

    ON

    {control UTH on}
    once GetRealIBSystemIO("Measurement App Real Value", 254, 15, 1) <17 then
    begin
    SetCBusState("local","Lighting", "3 Ensuite UTH", ON);
    end;


    and for OFF


    { control UTH off }
    once GetRealIBSystemIO("Measurement App Real Value", 254, 15, 1) >18 then
    begin
    SetCBusState("local","Lighting", "3 Ensuite UTH", OFF);
    end;


    What I need to do but can't work out how, is write an initialization code to 'start' my logic if the turn on temp is below the turn on threshold as I believe when using a 'once' statement, the variable needs to be false then true to operate.

    Also I seem to be having trouble with one or two floors going rouge at random times and not obeying the turn off code.

    As for the scheduling, I have got a schedule set up that enables that group address to function withing a certain time.

    Sorry for rambling on a bit, but any and all help would as always be greatly appreciated.

    Thanks

    Jake
     
    jakelanauze, Dec 19, 2013
    #1
  2. jakelanauze

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,548
    Likes Received:
    178
    Location:
    Adelaide, Australia
    The way to do this is to create a GA that is used to enable/disable the system. Generally this would be created in the Enable Control application but doesn't have to be. Set up your schedule to turn this GA on or off as required. Doing it this way also allows you to control the system from anywhere else (i.e. a button etc) to override the schedule. Then just test the GA in the logic.

    Also, since the tile heating works very slowly, you don't really need to test it every scan (which is 200mS).

    I have also set up a setpoint as a system io so it can be changed from the touch screen. (You could also use a GA for this if you only wanted integer values)

    If you need to do this for multiple rooms you can either duplicate the code (a bit sloppy!), define it as a function (better) or use a loop with constant arrays defining the areas (best)

    Enable Control GA (set up in toolkit): "UTH Enabled"
    User System RealIO: (set up in PICED): "UTH SetPoint"

    Logic:

    Code:
      
    
    Global Variables: (local copy of System IO and GA's)
      UTHTemperature: real;
      UTHEnabled: boolean;
      UTHSetPoint: real;
      UTHState: boolean;
    
    Module:
    //
    // Read data into local variables once per scan
    //
    UTHTemperature := GetRealIBSystemIO("Measurement App Real Value", 254, 15, 1); // Read current temp once per scan
      UTHSetPoint := GetRealSystemIO("UTH SetPoint");
      UTHState := GetCBusState("local","Lighting", "3 Ensuite UTH");
      UTHEnabled := getCBusState("local", "enable control", "UTH Enabled");
    //
    // Turn on or off as required
    //
      if UTHEnabled and (UTHTemperature < (UTHSetPoint - 1.0)) and (UTHState = OFF) then
        SetCBusState("local","Lighting", 3 Ensuite UTH, ON)
      else if ( UTHState = ON) and ((not UTHEnabled) or (UTHTemperature >= UTHSetPoint)) then
        SetCBusState("local","Lighting", 3 Ensuite UTH, OFF) ;
    //
    // Wait 5 minutes (or whatever)
    //
      delay("00:05:00");
    
     
    Last edited by a moderator: Dec 19, 2013
    Ashley, Dec 19, 2013
    #2
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.