Bathroom Fan Control Via Digital Temp Sensor 5100DTST

Discussion in 'C-Bus Wired Hardware' started by chrisd4021, May 4, 2016.

  1. chrisd4021

    chrisd4021

    Joined:
    May 12, 2011
    Messages:
    44
    Likes Received:
    0
    Location:
    South Yorkshire
    Hi Chaps,

    Calling Logic gurus out there!!!

    I've seen a few older posts relating to switching bathroom fan's on via flow or temperature in the shower pipe which sounds a great idea.

    I have 5104 DTSI (digital temp sensor input unit) and 5100DTST (digital probe) attached to the shower inlet pipe. Due to the location and mounting options available the temperature will vary during the day by a fair margin but over a long period of time (maybe 5 degrees per hour).

    However when the shower is in use the temperature increase is pretty dramatic.

    I'm wondering if it's possible within the logic to check the current temperature every 15 seconds or so and only switch the fan group on once that temperature has increased say 4 degrees by the next 15 seconds? therefore ignoring the long slow increases like morning-midday.

    I've had a rubbish bash as you'll see my logic is just above caveman standard but i can only think of a way using a fixed temperature start point say 20degrees and switch at 24 within 15seconds but that won't help in summer as we will be over 24 most of the time, thats actually rather optimistic border line ridiculous statement in UK but you understand my point ;).

    Thanks for any help in advance Guys.....

    Once (GetRealIBSystemIO("Measurement App Real Value", 254, 254, 2) >20)then
    begin
    TimerStart(1);

    Once TimerTime(1) = 15 and
    (GetRealIBSystemIO("Measurement App Real Value", 254, 254, 2) >24)then
    begin
    TimerStart(2)
    end;

    Once Timertime (2) = 1 then
    begin
    SetLightingState("Bathroom Fan", ON);
    end;

    Once
    TimerTime(2) = 300 then
    SetLightingState("Bathroom Fan", OFF);
    end;
     
    chrisd4021, May 4, 2016
    #1
  2. chrisd4021

    Roosta

    Joined:
    Nov 22, 2011
    Messages:
    560
    Likes Received:
    1
    Location:
    Australia
    Hey mate,

    You were on the right track.. What u need to do is read the temperature into a variable every 15 seconds (i would go 30/60 seconds myself) and then compare the current temperature to the variable..

    Ie


    Once timer => 00:00:15 then
    If Current temp-last temp>=4 then
    Turn on fan
    Last temp = current temp
    Reset timer

    Not in a position to give you a cut n paste of code at the moment but the above should be a good enough guide ;-P
     
    Roosta, May 4, 2016
    #2
  3. chrisd4021

    NickD Moderator

    Joined:
    Nov 1, 2004
    Messages:
    1,420
    Likes Received:
    62
    Location:
    Adelaide
    The other thing to remember is that when you read the temperature value in logic it is only using the most recent temperature it received from the sensor itself..

    The frequency with which the temperature measurement is broadcast is set in the sensor configuration.

    You probably don't want to set your sensor to be broadcasting every 15s all the time, but fortunately the clever people who designed it put in a feature to cope with this... you can set it to broadcast, say, every minute, and also when it changes by x degrees. This way it will broadcast more often when you're really interested, but still regularly to keep things up to date when there's not so much happening.

    Nick
     
    NickD, May 5, 2016
    #3
  4. chrisd4021

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,521
    Likes Received:
    173
    Location:
    Adelaide, Australia
    Try this:

    Code:
    Global Variable Section:
    
    prevTemp: real;
    currentTemp: real;
    
    Initialisation Section:
    
    prevTemp := 100.0; // So on startup we don't trigger a change
    
    Module:
    
    currentTemp := GetRealIBSystemIO("Measurement App Real Value", 254, 254, 2);
    if (currentTemp - prevTemp) > 4 then
      PulseCBusLevel("Local", "Lighting", "B1 Main", 100%, "0s", "0:05:00", 0%);
    prevTemp := currentTemp; // and save as previous temperature
    delay(15);
    
    As Roosta pointer out the idea is to save the last temperature read then compare it with the next temperature.

    To turn a group on for a certain period of time just use the pulse command.

    The delay pauses the module for 15 seconds. This is much simpler and much more efficient than using timers as the module will only run every 15 seconds whereas yours will run every 200mS.

    Note I have used an If statement rather than a Once statement. This means every scan that the temperature goes up by 4 degrees the timer will be re-triggered and extend the time which is probably a good thing, although unlikely to happen. Because the module is only running every 15 seconds there is no possibility of flooding the bus which is the main point of the ONCE function. ONCE would work fine though, but as there is a limit on how many you can use, I tend to only use them when necessary.
     
    Last edited by a moderator: May 5, 2016
    Ashley, May 5, 2016
    #4
  5. chrisd4021

    chrisd4021

    Joined:
    May 12, 2011
    Messages:
    44
    Likes Received:
    0
    Location:
    South Yorkshire
    Hi Guys,

    Thanks for the help, I own you all a cold beer ;)...

    Ashley thats works a treat, very detailed, i own you 2 beers :)

    Chris
     
    chrisd4021, May 5, 2016
    #5
  6. chrisd4021

    kevinpham

    Joined:
    Sep 16, 2016
    Messages:
    1
    Likes Received:
    0
    Location:
    CA
    Hey, is it programming? How can i use this code?
     
    Last edited by a moderator: Jan 28, 2017
    kevinpham, Sep 16, 2016
    #6
  7. chrisd4021

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,521
    Likes Received:
    173
    Location:
    Adelaide, Australia
    Yes

    Buy a CBUS logic enabled device, install PICED, read the logic manual and a Pascal manual and off you go
     
    Ashley, Sep 17, 2016
    #7
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.