Aggregation of Light Sensor Output

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

  1. ColinCamSmith

    ColinCamSmith

    Joined:
    Nov 25, 2004
    Messages:
    87
    Likes Received:
    0
    I have recently installed a C Bus system on my rural property and all systems including automatic fertilization to preset limits is working well. One issue I am not happy with is the way the Solar Hot Water System ("HWS") Booster is activated.

    At the moment the code in Logic is written so that if the light is below a certain level at 1630 (800 lux) (It triggers a virtual device), then at 1800 the HWS comes on for an hour. The problem with that of course is if the sun has been shining all day, but at 1630 clouds reduce the level below that trigger point, then the HWS Booster comes On at 1800 when it is not needed and still draws a certain amount of current and subsequent heating to a level I do not need.

    What I am looking for is code in Logic that will aggregate the light level say between 0900 and 1600 and then if it is greater than, say a total of 7000 lux (or an average of say greater than 1000 lux over 7 hours), the HWS would not be activated.

    Has anyone managed to write code to achieve a similar result.

    Regards,

    Colin
     
    ColinCamSmith, Feb 10, 2010
    #1
  2. ColinCamSmith

    Newman

    Joined:
    Aug 3, 2004
    Messages:
    2,203
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    You could do something like take a light level reading once every hour, between the hours of, say, 0900 and 1600. Keep a running total. Come evening time, compare the total to a fixed value. If the value is exceeded, then no need to run the booster.

    Very simple, but would iron out the "clouds at 1630" problem without making significant changes.
     
    Last edited by a moderator: Feb 10, 2010
    Newman, Feb 10, 2010
    #2
  3. ColinCamSmith

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    Here is a simple bit of code which gives you the average of the light level over the time 9AM to 4PM:

    Code:
    { Global Variables }
    Total : integer;
    Count : integer;
    Average : integer;
    
    { initialisation }
    Total := 0;
    Count := 0;
    Average := 0;
    
    { Module }
    once time = "9:00AM" then
    begin
      Total := 0;
      Count := 0;
      Average := 0;
    end;
    
    if (time >= "9:00AM") and (time =< "4:00PM") then
    begin
      Total := Total + round(GetUnitParameter("Local", 1, ptLightLevel));
      Count := Count + 1;
      Average := Total div Count;
    end;
     
    Darren, Feb 10, 2010
    #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.