Multi sensor dimming programming help

Discussion in 'C-Bus Wired Hardware' started by Lliam, Jun 30, 2018.

  1. Lliam

    Lliam

    Joined:
    Nov 15, 2015
    Messages:
    28
    Likes Received:
    2
    Location:
    Adelaide
    Hi
    I am currently trying to program some multi sensors to the specific requirements defined in the specs for job i am working on.

    The area the sensors are located in are the public corridors of an apartment building. Different sections of corridor are split into seprate lighting groups with upto 4 sensors controling one lighting group. Its not just one long corridor, there are 90 degree corners and sections where the corridors stop at lift lobbys then start again on the other side of the lift lobby.

    The requirements are:
    During daytime the sensors are set to Day Move/ Night Move with Light Level target set to around 250 lux (lights ON under 250 lux, lights OFF above 250 lux)
    At night time (so after sunset) all corridor lights need to dim to 50%, when movement is detected by a multisensor the lighting needs to ramp upto 100% for the set time (10 min atm) then return to 50% when the timer expires.
    Then at sunrise the corridors need to return to normal Day Move/Night move functionality.

    I have a touchscreen on different network that i can send a 50% dim at sunset command to all the corridor lighting so thats not an issue. But I am struggling with how i can get the multi sensors to go to 50% as minimum on expiry of timer during this night time period.

    Additional Information:
    All lights are DALI controlled through a gateway
    I am not currently using full Light Level Maintenance on the multisensors. I know i could be since the lighting is Dali dimmable but I just want to get above requirements working before I consider turning it on (It has normally just caused me more headaches than its worth when i have used it in the past so I normally stick with straight ON or OFF based on the ambient light level)

    Thanks
    Lliam
     
    Lliam, Jun 30, 2018
    #1
  2. Lliam

    Wonkey

    Joined:
    Aug 3, 2004
    Messages:
    386
    Likes Received:
    37
    Location:
    Adelaide
    Depending on how you networks are interconnected this may work.
    if your networks are using bridges (5500NB) then
    configure the sensor expiry as recall 1 set at 50%
    In the C touch hopefully it has logic, write some logic that says if between sunrise and sunset GA is below 51% then turn the GA off
     
    Wonkey, Jul 17, 2018
    #2
  3. Lliam

    Lliam

    Joined:
    Nov 15, 2015
    Messages:
    28
    Likes Received:
    2
    Location:
    Adelaide
    Thanks for you reply Wonkey.
    Yes I have 5 networks all connected with bridges. One of the networks is acting as the main transit backbone network on which the primary touch screen resides which holds all schedules for site.


    I think I understand what you mean. Took me a few re-reads but if you (or anyone else reading this) can confirm that I am understanding this correctly:
    "configure the sensor expiry as recall 1 set at 50%" - meaning the sensors will dim the GA(s) to 50% when the timer expires (instead of the default 0/off). So this means the sensors are essentially in the "night time" mode by default (dimming to 50% when no movement is detected at night and timer expires) ?

    "In the C touch hopefully it has logic, write some logic that says if between sunrise and sunset GA is below 51% then turn the GA off" - so what you are saying here I need some logic that states that if it is "Day Time" (between sunrise and sunset) and the GA is below 51% (essentially meaning if the GA is at 50% as that is now the sensors new "off" state) then turn the GA completely off/0. Thus achieveing a full OFF state during day time.

    Looks like i will have to take crash course in logic programming, have been able to avoid it so far in my cbus programming career. I knew this day would come eventually though.

    Also would the fact I am running a DALI dimming system cause any issues with the use of this logic? Specifically with the CBUS system actually getting accurate level (like when the lighst are at 50%) reports back from the DALI system as I have had some issues with this in past.

    Thanks
    Lliam
     
    Lliam, Jul 18, 2018
    #3
  4. Lliam

    Wonkey

    Joined:
    Aug 3, 2004
    Messages:
    386
    Likes Received:
    37
    Location:
    Adelaide
    Your correct in how you have interpreted my explanation.
    With regard to the logic required its reasonably simple for this.
    Open up the logic engine in PICED and use the provided wizard to do the programming.
    You should end up with something like this. (don't just copy and paste this one)

    once (GetCBusLevel("first floor", "Lighting", "corridor") < 51%) and
    and
    ( (Time >= sunset) or
    (Time < sunrise) )then
    begin
    SetCBusState("first floor", "Lighting", "corridor", OFF);
    end;

    Pointers to save you time you need to use an OR statement here
    (Time >= sunset) OR
    (Time < sunrise) )then
    you may thing it should be an AND statement but change you though process to think about it as a single day (not 2 days hence across midnight)
    So if its before sunrise OR after sunset ( on the same day) CORRECT
    We naturally think if its after sunset AND before sunrise ( this is over the 2 days ) THIS IS WRONG

    You should also add a extra set of brackets to achieve the desired results to encompass the OR statement
    ( (Time >= sunset) or
    (Time < sunrise) )then
    begin
    You will get a warning when you finish the logic, you can then add the extra brackets
    Colin
     

    Attached Files:

    Wonkey, Jul 24, 2018
    #4
  5. Lliam

    Wonkey

    Joined:
    Aug 3, 2004
    Messages:
    386
    Likes Received:
    37
    Location:
    Adelaide
    Sorry
    I just checking and realised that the above code would turm the lghts off at night not during the day
    something like this would be be the results you get from the wizard
    Note an AND statement is used as it is on the same day not across midnight.

    once GetCBusLevel("first floor", "Lighting", "corridor")) < 51%) and
    (Time > sunrise) and
    (Time < sunset) then
    begin
    SetCBusState("first floor", "Lighting", "corridor", OFF);
    end;
     
    Wonkey, Jul 27, 2018
    #5
  6. Lliam

    Lliam

    Joined:
    Nov 15, 2015
    Messages:
    28
    Likes Received:
    2
    Location:
    Adelaide
    Hi Wonkey

    I literally just came back to report that the logic seems to be working but the wrong way around (turning lights completely off during the night instead of the desired during the day). But it looks like you already realised this and beat me to it :D.

    My code ended up looking like this:
    if (GetCBusLevel("DB.L3", "Lighting", "L10-5 600 LOBBY WEST D (L3)") < 51%) and
    ((Time >= sunset) or
    (Time < sunrise)) then
    begin
    SetCBusState("DB.L3", "Lighting", "L10-5 600 LOBBY WEST D (L3)", OFF);
    end;


    But your saying now that I don't actually need an "or" statement. So the code would look like this:

    if (GetCBusLevel("DB.L3", "Lighting", "L10-5 600 LOBBY WEST D (L3)") < 51%) and
    (Time >sunset) and
    (Time < sunrise) then
    begin
    SetCBusState("DB.L3", "Lighting", "L10-5 600 LOBBY WEST D (L3)", OFF);
    end;

    I will test this new code once I get back on site (later this week hopefully).

    One minor issue is that I started getting the following error when running the logic in PICED:

    "Logic Run-time Error R009 at line 35:0 - C-Bus Messages are being sent on every Scan"


    After investigating the error code in the help files it seems this is a normal error you get when using "if" statements. But the strange thing is i didn't get this error the first time i created, compiled and ran the logic. It was only after I noticed the outcome was the wrong way around and i tried to edit the code and the error started poping up after 20 scans then still continued to pop up even after reverting back to the original code. Is this normal and can I just ignore this error and my logic code will still run fine on the C-Touch? or have I done something to cause this error?

    Thanks
    Lliam
     
    Lliam, Jul 31, 2018
    #6
  7. Lliam

    Wonkey

    Joined:
    Aug 3, 2004
    Messages:
    386
    Likes Received:
    37
    Location:
    Adelaide
    Simply change the 'If' statement to a 'Once' statement.

    This implies that Once the condition is true then the logic will run. For it to happen again the condition would have to be not true then become true again. This will prevent the Run time error.
    See the help file for the difference between If and Once should my explanation not make sense.

    Do not ignore the error as the code will not run in the C-Touch

    With regard to the AND or OR statement its all to do with how the logic engine perceives sunset and sunrise.
    Which happens first? obviously sunrise does.
    So if we want something to happen between Sunrise AND Sunset then use AND logic
    Greater than sunrise AND Less than sunset

    But if we want something to happen between Sunset and Sunrise the next day, then the logic engine has no concept of the next day therefore
    Less than sunset Or greater than sunset (which expresses this in a single day term) makes more sense.
    You could and probably would put it as
    greater than sunset or Less than sunset.
    Colin
     
    Wonkey, Jul 31, 2018
    #7
  8. Lliam

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,521
    Likes Received:
    173
    Location:
    Adelaide, Australia
    I think you mean:

    Less than SUNRISE Or greater than sunset (which expresses this in a single day term) makes more sense.
    You could and probably would put it as
    greater than sunset or Less than SUNRISE.
     
    Ashley, Aug 1, 2018
    #8
  9. Lliam

    Wonkey

    Joined:
    Aug 3, 2004
    Messages:
    386
    Likes Received:
    37
    Location:
    Adelaide
    Thanks Ashley for picking this up.
    Colin
     
    Wonkey, Aug 2, 2018
    #9
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.