Best way for Temperature Measurement?

Discussion in 'C-Touch/HomeGate/SchedulePlus/PICED Software' started by Ingo, May 20, 2010.

  1. Ingo

    Ingo

    Joined:
    Dec 2, 2006
    Messages:
    290
    Likes Received:
    1
    Location:
    South Africa
    What is the best way to read Temperature from a sensor?

    The way I understand it is that the monitor object periodically gets the value from the Temperature Sensor and then saves it in a 'bucket' - for the lack of a better word.

    Once the value is in the 'bucket' I can then use GetUnitParameter to read the value from the 'bucket' but only after I checked to see if it's valid using the GetUnitParamStatus command.

    What I am trying to achieve is to read the value right after it has been placed into the 'bucket' and not write my own little loop to check the bucket every x seconds. Here is some code I currently use, it's polling based but I want it to be notification based so that I only read the value when it's put inside the 'bucket'.

    Code:
    if GetUnitParamStatus("Local Network", 20, ptTemperature) then
    begin
      Temperature := GetUnitParameter("Local Network", 20, ptTemperature);
      Delay (20);
    end;
    Changing the 'if' statement to a 'once' statement doesn't work. Any ideas how I can change the behaviour or can I remove the delay and have it scan on every cycle?

    Ingo
     
    Ingo, May 20, 2010
    #1
  2. Ingo

    NickD Moderator

    Joined:
    Nov 1, 2004
    Messages:
    1,427
    Likes Received:
    64
    Location:
    Adelaide
    You can read the the value as often as you like... it doesn't result in any extra messages.

    The monitor retrieves the value from the sensor on a regular basis, and stores the value in RAM. When you call GetUnitParameter, it just returns whatever the latest value is from RAM.

    The reason for calling the "GetUnitParamStatus" first is to make sure that the value in RAM is actually valid. This will only return false if the unit fails to respond to the monitor, which is why the "once" command doesn't work (once needs to see it go false and then true again for it to retrigger).

    Is this because you're trying to minimise traffic, or because you only want to do something when the value has changed?

    If it's the former, then (in this case) you don't need to worry, as you can call "GetUnitParameter" as ofter as you like and it won't affect the traffic.

    If it's the latter, then have a look at the "HasChanged" function.

    BTW - if it's a new temperature sensor (5031RDTSL) - then it supports broadcast on the measurement application, which is a much nicer way of doing things.

    Nick
     
    NickD, May 21, 2010
    #2
  3. Ingo

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    Generally we don't like to poll things on C-Bus. The "monitors" in the touch screens, PAC and HomeGate are only there for getting data which is not broadcast onto C-Bus.

    The measurement application is much better because you get the change immediately and you don't need to poll. If possible, always use the measurement application in preference to using a monitor.
     
    Darren, May 21, 2010
    #3
  4. Ingo

    Ingo

    Joined:
    Dec 2, 2006
    Messages:
    290
    Likes Received:
    1
    Location:
    South Africa
    Thanks guys. In the never ending quest to conserve bandwidth and cpu cycles one never stops looking for more efficient ways to do things. I'll remove my delay command so as to grab the new temperature value as it enters.

    I actually use the HasChanged command command already but that is only further down the line where I check the major value (24.xx) of the temperature. Including the decimal (xx.73) values makes it change almost on every poll.

    Ingo
     
    Ingo, May 21, 2010
    #4
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.