C-Bus thermostat to AC (Coolmaster) using 5500PACA with RS232

Discussion in 'Pascal Logic Code Examples' started by nickrusanov, Mar 14, 2013.

  1. nickrusanov

    nickrusanov

    Joined:
    Aug 5, 2004
    Messages:
    308
    Likes Received:
    0
    Location:
    russia
    This code is from the main post here

    Based on Darren example. If anyone feels he could help to optimize it, please do. I tried use ELSE, it did not work, so I had to use IF's all the time. Maybe some feedback could be added, but I could not make any, being not a programmer myself.

    This controls:
    1 AC addressed 001
    with the thermostat Communication Group 3
    through COM1 of 5500PACA device

    Once in Cool mode - thermostat controls the AC.
    Once in Heat mode - thermostat controls only heating device using internal logic and relays, does not control AC until we allow it to. Group "heat on" turns AC control in Heat mode on.
    AC goes to Heat mode with another module, which is not here (because you have to turn all AC's to Heat, you cannot do just one).

    Code:
    { global variables }
    s3 : string;
    LastSetPoint3 : real;
    LastOnOff3 : real;
    m3 : string;
    
    { Initialisation }
    OpenSerial(1, 1, 9600, 8, 1, 0, 0);
    LastOnOff3 := 0;
    LastSetPoint3 := 0;
    
    { module code }
    {room 3 - cond 01 ON/OFF}
    if (GetIntIBSystemIO("HVAC Operating Type", 3, HVACZoneU) <> LastOnOff3) then
    begin
    if (GetIntIBSystemIO("HVAC Operating Type", 3, HVACZoneU) = 0)
    then
    begin
      format(m3, 'off 001', #13);
      WriteSerial(1, m3);
      LastOnOff3 := GetIntIBSystemIO("HVAC Operating Type", 3, HVACZoneU);
    end
    end;
    
    {room 3 - cond 01 cool}
    if (GetIntIBSystemIO("HVAC Operating Type", 3, HVACZoneU) <> LastOnOff3) then
    begin
      if (GetIntIBSystemIO("HVAC Operating Type", 3, HVACZoneU) = 2)
    then
    begin
      format(m3, 'on 001', #13);
      WriteSerial(1, m3);
      LastOnOff3 := GetIntIBSystemIO("HVAC Operating Type", 3, HVACZoneU);
    end
    end;
    
    {room 3 - cond 01 HEAT if "heat on" is on}
    if (GetIntIBSystemIO("HVAC Operating Type", 3, HVACZoneU) <> LastOnOff3) then
    begin
    if (GetIntIBSystemIO("HVAC Operating Type", 3, HVACZoneU) = 1) and (GetLightingState("heat on") = ON)
    then
    begin
      format(m3, 'on 001', #13);
      WriteSerial(1, m3);
      LastOnOff3 := GetIntIBSystemIO("HVAC Operating Type", 3, HVACZoneU);
    end
    end;
    
    {room 3 setpoint send to AC}
      if (GetRealIBSystemIO("HVAC Set-Level", 3, HVACZoneU) <> LastSetPoint3) then
    begin
      format(s3, 'temp 001 ',GetRealIBSystemIO("HVAC Set-Level", 3, HVACZoneU):0, #13);
      WriteSerial(1, s3);
      LastSetPoint3 := GetRealIBSystemIO("HVAC Set-Level", 3, HVACZoneU);
    end;
    {room 3 end}
    
     

    Attached Files:

    Last edited by a moderator: Mar 14, 2013
    nickrusanov, Mar 14, 2013
    #1
  2. nickrusanov

    Pie Boy

    Joined:
    Nov 21, 2012
    Messages:
    248
    Likes Received:
    31
    Location:
    New Zealand
    This Part
    format(m3, 'off 001', #13);
    WriteSerial(1, m3);

    Can be replaced by declaring it as a string constant

    m3 = 'off 001'#13;

    and how dose this module run as there are quite a few if statements which will put a lot of traffic on c bus every scan
     
    Pie Boy, Mar 17, 2013
    #2
  3. nickrusanov

    nickrusanov

    Joined:
    Aug 5, 2004
    Messages:
    308
    Likes Received:
    0
    Location:
    russia
    Thank you!
    It runs ok, because "if (GetIntIBSystemIO("HVAC Operating Type", 3, HVACZoneU) <> LastOnOff3)" makes it almost identical to ONCE, I guess.

    I tried to make less IF's, more ONCE's, but it stops working
     
    nickrusanov, Mar 27, 2013
    #3
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.