Light Level Averaging

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

  1. remedy

    remedy

    Joined:
    Nov 22, 2008
    Messages:
    16
    Likes Received:
    0
    Is this possible. I have a project using multisensor and touchscreen with logic and a dsi gateway. What I want to do is alter the level of a group in the dsi gateway from an average of the lux level of 2 multisensors. I have assigned group addresses to the multisensors in light level broadcasting. Am I assuming wrong that I can average these readings out in logic.

    I have assigned sensor 1 group as LL1
    Sensor 2 group as LL2

    I want to average LL1 and LL2 and average these Lux readings out and get a result AVERAGELL which I would used to set conditions and light levels.


    I keep trying to write the logic for this but keep getting errors in compile. Could anyone help with the code or is what I want to achieve even possible???
     
    remedy, Feb 11, 2010
    #1
  2. remedy

    Newman

    Joined:
    Aug 3, 2004
    Messages:
    2,203
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    Newman, Feb 11, 2010
    #2
  3. remedy

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    Try this:

    Code:
    { global variables }
    AVERAGELL : real;
    
    { module }
    AVERAGELL := (GetUnitParameter("Local", 1, ptLightLevel) + GetUnitParameter("Local", 2, ptLightLevel)) / 2;
    Ideally, you should check that the light level data is valid before using it, so this would be better:

    Code:
    { global variables }
    AVERAGELL : real;
    
    { module }
    if GetUnitParamStatus("Local", 1, ptLightLevel) and GetUnitParamStatus("Local", 2, ptLightLevel) then
      AVERAGELL := (GetUnitParameter("Local", 1, ptLightLevel) + GetUnitParameter("Local", 2, ptLightLevel)) / 2
    else
      AVERAGELL := 0;
     
    Darren, Feb 11, 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.