RGB LED Lights & 10v Analogue Controller

Discussion in 'C-Touch/HomeGate/SchedulePlus/PICED Software' started by DiscoStu, Jan 5, 2010.

  1. DiscoStu

    DiscoStu

    Joined:
    Feb 23, 2007
    Messages:
    6
    Likes Received:
    0
    Thought it might be worthwhile asking what my options are to achieve the following:

    I have an RGB LED light that is controlled by a cbus analogue controller - Red is channel 1, Green ch 2 and Blue ch 3. Power is supplied through a 24v DC transformer which is switched through a standard cbus relay. The 5 lines feed into a LED controller and then to the load.

    I want a 'scene' where the light will cycle through various colours until switched off.

    1. My assumption is that I have to use code to do so?

    2. I dummied up some code:

    if GetLightingLevel("RGB Colour Cycle") = 100% then
    begin

    SetLightingLevel("RGB 24vPS", 100%);

    SetLightingLevel("RGB Red", 100%);
    SetLightingLevel("RGB Green", 0%);
    SetLightingLevel("RGB Blue", 0%);

    SetLightingLevel("RGB Red", 0%, ?60s?);
    SetLightingLevel("RGB Green", 100%, ?60s?);
    Delay("0:01:01");

    ......and so on through the states (6 in total)

    I haven't written any cbus piced code before so wanted to check that I was on the right track. One concern I have is that if the 'colour cycle' group is switched off mid routine will the rountine continue (because of the delays)?

    Any tips appreciated. :)
     
    DiscoStu, Jan 5, 2010
    #1
  2. DiscoStu

    ashleigh Moderator

    Joined:
    Aug 4, 2004
    Messages:
    2,398
    Likes Received:
    26
    Location:
    Adelaide, South Australia
    Sounds like you are on the right track to me.

    And if you turn that cycle group off there may be a small delay (sub 1/2 second) where the stuff continues to play out, but if you right the code right it will run happily to completion.

    sounds a bit like you might want to look at how "once" statement works.
     
    ashleigh, Jan 5, 2010
    #2
  3. DiscoStu

    filpee

    Joined:
    May 31, 2006
    Messages:
    204
    Likes Received:
    0
    Location:
    Western Australia
    I have something similar but needs 4 modules to work (well the way I have coded it I'm using 4 modules).
    This does not cycle through a stage of colours as it was designed to cycle through random colours.

    one module to control it all
    Code:
    {Random Canceled}
    once (GetBoolSystemIO("Random") = false) then
    begin
        DisableModule("Random Red");
        DisableModule("Random Green");
        DisableModule("Random Blue");
    end;
    {Set as random}
    once (GetBoolSystemIO("Random") = true) then
    begin
        EnableModule("Random Red");
        EnableModule("Random Green");
        EnableModule("Random Blue");
    end;
    
    then one module for each colour
    Code:
    randomRed := random("00:02:00")+60;
    SetCBusLevel("Network", "Application", "Red", 0%, randomRed);
    {WriteLn('Red Timer = ',randomRed);}
    Delay(GetCBusRampRate("Network", "Application", "Red")+1);
    
    
    randomRed := random("00:02:00")+60;
    SetCBusLevel("Network", "Application", "Red", 100%, randomRed);
    {WriteLn('Red Timer = ',randomRed);}
    Delay(GetCBusRampRate("Network", "Application", "Red")+1);
    
    This will set random ramp times for Off then On for each colour giving you a constant fading through various colours depending on the current level of each group address.
     
    Last edited by a moderator: Jan 5, 2010
    filpee, Jan 5, 2010
    #3
  4. DiscoStu

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    I would probably use two modules too - one to cycle through the colours, and one to enable and disable the other.

    Module 1:

    Code:
    once GetLightingLevel("RGB Colour Cycle") = 100% then
    begin
      SetLightingLevel("RGB 24vPS", 100%);
    
      SetLightingLevel("RGB Red", 100%);
      SetLightingLevel("RGB Green", 0%);
      SetLightingLevel("RGB Blue", 0%);
    
      EnableModule("Module 2");
    end;
    
    once GetLightingLevel("RGB Colour Cycle") = 0% then
    begin
      SetLightingLevel("RGB 24vPS", 0%);
    
      DisableModule("Module 2");
    end;
    
    Module 2:

    Code:
    SetLightingLevel("RGB Red", 0%, ?60s?);
    SetLightingLevel("RGB Green", 100%, ?60s?);
    Delay("0:01:01");
    
    SetLightingLevel("RGB Red", 100%, ?60s?);
    SetLightingLevel("RGB Green", 0%, ?60s?);
    Delay("0:01:01");
    ...
     
    Darren, Jan 5, 2010
    #4
  5. DiscoStu

    DiscoStu

    Joined:
    Feb 23, 2007
    Messages:
    6
    Likes Received:
    0
    thanks guys

    I did look at the once statement but i want the routine to continue to cycle until its manually stopped. My thinking is the once statement will see it run only for the first 7 minutes (it moves through 7 states before returning to the 'start' state). using the once in the 2 routine setup will work well however.

    thanks for the random colour tip - i like the idea of that as well.

    obvioulsy there will be other options/routines including fixed colour selection (thinking a CTS colour wheel page) and maybe choosing two colours to cycle between.

    it makes sense to have 2 routines and thanks for the syntax on that!
     
    DiscoStu, Jan 6, 2010
    #5
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.