scene transitions with DMX

Discussion in 'C-Touch/HomeGate/SchedulePlus/PICED Software' started by Smokey240, Apr 16, 2012.

  1. Smokey240

    Smokey240

    Joined:
    Sep 5, 2011
    Messages:
    5
    Likes Received:
    0
    Location:
    brisbane
    hi
    i have a DMX controlled RGB Led strip the customer would like a scene in which it gradually changes colour over a set time continuesly until stopped by the user
    HOWEVER
    to achieve set colors in the RGB the other channels must be at 0%
    ie if you transition from red to green, red must be set to 0% otherwise another colour will result.
    i have created scenes for the different colours ect
    but im lost as to how i can get these to run one after the other until told to stop.


    cheers
     
    Smokey240, Apr 16, 2012
    #1
  2. Smokey240

    ashleigh Moderator

    Joined:
    Aug 4, 2004
    Messages:
    2,391
    Likes Received:
    24
    Location:
    Adelaide, South Australia
    Because R, G, B will blend (and make other colours) you can't just transition from R to G, to G to R etc etc in some kind of cycle. Its not possible.

    The ONLY way to come close it to fade the R up, then down to 0. Then fade the B up, then down to 0, and so on. This gives the effect of slow flashing, not colour changing.

    Alternatively, live with the fact that mixing colours makes other colours, and then exploit that. Go to town will all kinds of mixes.
     
    ashleigh, Apr 16, 2012
    #2
  3. Smokey240

    Smokey240

    Joined:
    Sep 5, 2011
    Messages:
    5
    Likes Received:
    0
    Location:
    brisbane
    hmm
    i see your point i will run with that.
    however is it possible to have a scene that continues to repeat until told to stop?
    i have a B&W touch logic available model

    from what you have said i should create a scene that has timed ramp groups to fade through the colours?

    i have already made a few scenes of the main colours
    ie red being 100% blue @ 0% and green @ 0% to obtain red and the other colours the same.

    if i can trigger a scene to start then trigger the rest in an order of events this would create a colour change ?


    cheers
     
    Smokey240, Apr 17, 2012
    #3
  4. Smokey240

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,522
    Likes Received:
    173
    Location:
    Adelaide, Australia
    Changing through all colours (not just red, green and blue) actually looks quite nice as is probably what the customer is thinking of anyway. Ideally to do this you need to work in the HSV (hue, saturation, value) colour space where hue gives you the colour, saturation the intensity of the colour (or amount of white light in it), and value is the overall brightness. Hue is usually measured in degrees from 0 to 360, and saturation and value in percent (type 'color wheel' into google). To just change colours you keep the saturation at 100% (which means only 2 of the primary colours are on at any time, as adding a third just adds white), and the value at 100% for maximum brightness. Then to vary the hue, you need six scenes as follows:
    Start with red at 100%
    Scene 1: Ramp green from 0-100% - this gives the red, oranges and yellows
    Scene 2: Ramp red from 100% to 0 - this gives yellows to greens
    Scene 3: Ramp blue from 0 to 100% - this gives greens to cyans
    Scene 4: Ramp green from 100% to 0 - this gives cyans to blues
    Scene 5: ramp red from 0 to 100% - this gives blues, purples, magentas
    Scene 6: ramp blue from 100% to 0 - this gives magentas back to red
    Start again.

    Probably the easiest way to trigger this is a logic module that has the 6 set scene command with delays between them equal to the ramp rate enclosed in a repeat loop. Alternatively you could set a scene then wait on the appropriate value to get to 0 or 100%.

    In the end I decided it was easier (for me anyway) to program up a microcontroller to accept Hue, Saturation and Value parameters direct from C-bus and convert them to RGB. I'm sure there must be something around commercailly that does this, or perhaps Clipsal could put it on their todo list given the huge growth in colour led technology.
     
    Ashley, Apr 17, 2012
    #4
  5. Smokey240

    Smokey240

    Joined:
    Sep 5, 2011
    Messages:
    5
    Likes Received:
    0
    Location:
    brisbane
    hmmm
    yeah that sounds good.
    i think logic is going to be my way out
    i had a go at that and could not get it to trigger
    the rgb is being controlled by the touch screen only
    to use a button on the touchscreen to trigger a logic string i used an empty group address but i did nothing.

    im very new to logic can you point me in the right direction a post about ect
    i have searched but im not having much luck



    cheers
     
    Smokey240, Apr 18, 2012
    #5
  6. Smokey240

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    To cycle through the colours, put this code in a module called "Cycle Colour" with no other code in the module:

    Code:
    // Cycle through colours
    // Group 1 = Red
    // Group 2 = Green
    // Group 3 = Blue
    // Group 4 enables this module
    
    // Set to red initially
    SetLightingLevel("Group 1", 100%, "4s");
    SetLightingLevel("Group 2", 0%, "4s");
    SetLightingLevel("Group 3", 0%, "4s");
    delay(4);
    
    // cycle through colours until module is stopped
    repeat
      SetLightingLevel("Group 2", 100%, "8s");
      delay(8);
      SetLightingLevel("Group 1", 0%, "8s");
      delay(8);
      SetLightingLevel("Group 3", 100%, "8s");
      delay(8);
      SetLightingLevel("Group 2", 0%, "8s");
      delay(8);
      SetLightingLevel("Group 1", 100%, "8s");
      delay(8);
      SetLightingLevel("Group 3", 0%, "8s");
      delay(8);
    until false;
    Change the groups to use the correct groups for red, green and blue.

    In another module, put this code to control the colour cycling:

    Code:
    // Control the colour cycling using Group 4
    once GetLightingState("Group 4") = On then
      EnableModule("Cycle Colour");
      
    once GetLightingState("Group 4") = Off then
    begin
      DisableModule("Cycle Colour");
      SetLightingLevel("Group 1", 0%, "4s");
      SetLightingLevel("Group 2", 0%, "4s");
      SetLightingLevel("Group 3", 0%, "4s");
    end;
    In the Initialisation section, put this code:

    Code:
    DisableModule("Cycle Colour");
    SetLightingState("Group 4", OFF);
     
    Darren, Apr 19, 2012
    #6
  7. Smokey240

    Nick G

    Joined:
    Jun 19, 2014
    Messages:
    6
    Likes Received:
    0
    Location:
    New Zealand
    Hi,

    I am about to purchase a DMX Gateway to control a RGB light fitting.
    I already have a PAC and would like to use the above logic but with a few extras. This will be my first attempt at using any logic.

    What I would like to achieve is the following.

    1. Push a button on a DLT called "Blend" to ON. This starts the colours blending as shown in the above logic from the previous post.

    2. Push the button to OFF, the blending stops on the colour that is being shown at that exact moment.

    Code:
     // Control the colour cycling using Group 6 Colour Blend
    
    once GetLightingState("ENABLE BLEND") = On then  
      EnableModule("BLEND");
    
    
    once GetLightingState("ENABLE BLEND") = Off then
    begin
      DisableModule("BLEND");            //Stops the sequence of ramp to level commands being sent.
      StoreScene("colour blend stop");   //Stores the current colour of the blend.
      SetScene("colour blend stop");     //Acts as an end ramp (terminate ramp) so that the blend can be stopped on any mix of colour. 
    end;
    3. Push the button to ON again. The blending process resumes from the colour it was stopped on.

    This is where I get stuck. Not too sure how to proceed to make this work. Is it possible?

    Any help would be greatly appreciated.

    Regards
    Nick.
     
    Nick G, Jun 19, 2014
    #7
  8. Smokey240

    Roosta

    Joined:
    Nov 22, 2011
    Messages:
    560
    Likes Received:
    1
    Location:
    Australia
    You should just be able to use the same code as above but in the code that says:

    Once group 4 = off then
    Disable module etc


    Delete the set to off lines for the 3 colours..

    However how do you plan to turn it off?

    (Edit) hmm maybe not.. Might be a matter of playing around in piced to test..
     
    Roosta, Jun 19, 2014
    #8
  9. Smokey240

    MHeaton

    Joined:
    Apr 22, 2008
    Messages:
    103
    Likes Received:
    1
    Location:
    London
    If you work in the HSL colour space instead of RGB you can get the effect of a colour wheel by varying the Hue:

    This is VBA code I built in an Excel experimenting with this problem. I was thinking that the Saturation and Luminence would be fixed or work well with a slider type input. The hue really does need a wheel/rotary type control.

    Regards
    Mark

    Private Function Hue2RGB(p As Single, q As Single, t As Single) As Single
    If (t < 0) Then t = t + 1
    If (t > 1) Then t = t - 1
    If (t < 1 / 6) Then
    Hue2RGB = p + (q - p) * 6 * t
    Exit Function
    ElseIf (t < 1 / 2) Then
    Hue2RGB = q
    Exit Function
    ElseIf (t < 2 / 3) Then
    Hue2RGB = p + (q - p) * (2 / 3 - t) * 6
    Exit Function
    Else
    Hue2RGB = p
    End If
    End Function

    Function Hsl2RGB(Hue As Single, Saturation As Single, Luminence As Single) As Variant
    Dim Result() As Variant
    ReDim Result(0 To 2)

    Dim R As Single, G As Single, B As Single, q As Single, p As Single
    If (Saturation = 0) Then
    'Anachromatic
    Result(0) = 1
    Result(1) = 1
    Result(2) = 1
    Else
    If (Luminence < 0.5) Then
    q = Luminence * (1 + Saturation)
    Else
    q = Luminence + Saturation - Luminence * Saturation
    End If
    p = 2 * Luminence - q
    Result(0) = Round(255 * Hue2RGB(p, q, Hue + 1 / 3), 0)
    Result(1) = Round(255 * Hue2RGB(p, q, Hue), 0)
    Result(2) = Round(255 * Hue2RGB(p, q, Hue - 1 / 3), 0)

    End If
    Hsl2RGB = Result
    End Function
     
    MHeaton, Jun 19, 2014
    #9
  10. Smokey240

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,522
    Likes Received:
    173
    Location:
    Adelaide, Australia
    I posted logic to do HSV to RGB conversion some time ago:

    http://www.cbusforums.com/forums/showthread.php?p=41861#post41861

    To cycle through colours you just need a module to increment the Hue at whatever rate you need. Given that modules run every 200mS, incrementing the hue at each run would cycle though all colours in about 72 seconds, although I wouldn't recommend this as it will be executing 15 cbus commands per second which is not good. You would probably want to limit it to a change every second and step by more than one to get the rate you wanted, although this will probably result in noticeable steps. To start/stop it just enable/disable the module.

    Cbus isn't really designed for this sort of thing (i.e. dynamic light control). That's why I eventually built a dedicated box to do the cycling and let cbus just set the rate:

    http://www.cbusforums.com/forums/showthread.php?t=7417
     
    Last edited by a moderator: Jun 20, 2014
    Ashley, Jun 20, 2014
    #10
  11. Smokey240

    Nick G

    Joined:
    Jun 19, 2014
    Messages:
    6
    Likes Received:
    0
    Location:
    New Zealand
    Thanks everyone for your suggestions.

    I am very new to writing logic so I have to admit that the logic posted above didn't make too much sense to me. I will continue reading up on this stuff and hopefully one day I will be able to decipher "MHeaton"s code.

    I have however being testing out some more code myself.
    The below code allows the user to:

    1)start the colours blending.
    2)stop the blending process and stay on that colour.
    3)resume cycling through the colours. Starting from the colour that has just been stopped on. (as opposed to sending the RGB channels to 0% after the module is disabled)

    I am posting this because I would like feedback if there is a better, or more streamline way of doing this. I have tested it in PICED and it does what I want it to do. Do I need to have 8 modules? or is there a much simpler way of achieving this? Any suggestions are welcome.

    Thanks

    Code:
    {global variables}
    stageofblend : integer;
    {Module "control"}

    Code:
    once GetLightingState("colourblend") = On then
    if (stageofblend = 0) then                         
      EnableModule("BLEND STAGE 0")                  
    else
    if (stageofblend = 1) then                         
      EnableModule("BLEND STAGE 1")                    
    else
    if (stageofblend = 2) then                         
      EnableModule("BLEND STAGE 2")                   
    else
    if (stageofblend = 3) then                         
      EnableModule("BLEND STAGE 3")                    
    else
    if (stageofblend = 4) then                         
      EnableModule("BLEND STAGE 4")                 
    else
    if (stageofblend = 5) then                         
      EnableModule("BLEND STAGE 5")                   
    else
    if (stageofblend = 6) then                       
      EnableModule("BLEND STAGE 6");                   
    
     
     
     
    once GetLightingState("colourblend") = Off then
    begin
      DisableModule("BLEND STAGE 0");                //Stops the sequence of ramp to level commands being sent.
      DisableModule("BLEND STAGE 1");
      DisableModule("BLEND STAGE 2");
      DisableModule("BLEND STAGE 3");
      DisableModule("BLEND STAGE 4");
      DisableModule("BLEND STAGE 5");
      DisableModule("BLEND STAGE 6");
      StoreScene("colour blend stop");               //Stores the current colour of the blend.
      SetScene("colour blend stop");                 //Acts as an end ramp (terminate ramp) so that the blend can be stopped on any mix of colour.
    end;
    {Module "BLEND STAGE 0"}

    Code:
    // This module is enabled by the 'control' module when the group address "colourblend" = ON and the variable 'stageofblend' = 0
    // This module is disabled by the 'control' module when the group address "colourblend = OFF.
    
    stageofblend := 0;
    SetLightingLevel("RED", 100%, "4s");                      
    SetLightingLevel("GREEN", 0%, "4s");                      
    SetLightingLevel("BLUE", 0%, "4s");
    delay(4);
    
    // cycle through colours until module is stopped
    repeat
      stageofblend := 1;                                      
      SetLightingLevel("GREEN", 100%, "4s");                  
      delay(4);
      stageofblend := 2;                                      
      SetLightingLevel("RED", 0%, "4s");                      
      delay(4);
      stageofblend := 3;                                      
      SetLightingLevel("BLUE", 100%, "4s");                   
      delay(4);
      stageofblend := 4;                                      
      SetLightingLevel("GREEN", 0%, "4s");                    
      delay(4);
      stageofblend := 5;                                     
      SetLightingLevel("RED", 100%, "4s");                    
      delay(4);
      stageofblend := 6;                                      
      SetLightingLevel("BLUE", 0%, "4s");                    
      delay(4);
    until false;                                               
      
    {Module "BLEND STAGE 1"}

    Code:
    repeat
      stageofblend := 1;                                      
      SetLightingLevel("GREEN", 100%, "4s");                  
      delay(4);
      stageofblend := 2;                                      
      SetLightingLevel("RED", 0%, "4s");                      
      delay(4);
      stageofblend := 3;                                     
      SetLightingLevel("BLUE", 100%, "4s");                   
      delay(4);
      stageofblend := 4;                                     
      SetLightingLevel("GREEN", 0%, "4s");                   
      delay(4);
      stageofblend := 5;                                      
      SetLightingLevel("RED", 100%, "4s");                    
      delay(4);
      stageofblend := 6;                                     
      SetLightingLevel("BLUE", 0%, "4s");                     
      delay(4);
    until false;                                                 
      
    {Module "BLEND STAGE 2"}

    Code:
    repeat
      stageofblend := 2;                                     
      SetLightingLevel("RED", 0%, "4s");                      
      delay(4);
      stageofblend := 3;                                     
      SetLightingLevel("BLUE", 100%, "4s");                   
      delay(4);
      stageofblend := 4;                                      
      SetLightingLevel("GREEN", 0%, "4s");                   
      delay(4);
      stageofblend := 5;                                      
      SetLightingLevel("RED", 100%, "4s");                   
      delay(4);
      stageofblend := 6;                                      
      SetLightingLevel("BLUE", 0%, "4s");                     
      delay(4);
      stageofblend := 1;                                     
      SetLightingLevel("GREEN", 100%, "4s");                  
      delay(4);
    until false;                                              
      
    {Module "BLEND STAGE 3"}

    Code:
    repeat
      stageofblend := 3;                                      
      SetLightingLevel("BLUE", 100%, "4s");                  
      delay(4);
      stageofblend := 4;                                      
      SetLightingLevel("GREEN", 0%, "4s");                    
      delay(4);
      stageofblend := 5;                                      
      SetLightingLevel("RED", 100%, "4s");                    
      delay(4);
      stageofblend := 6;                                     
      SetLightingLevel("BLUE", 0%, "4s");                    
      delay(4);
      stageofblend := 1;                                      
      SetLightingLevel("GREEN", 100%, "4s");                  
      delay(4);
      stageofblend := 2;                                     
      SetLightingLevel("RED", 0%, "4s");                      
      delay(4);
    until false;                                              
      
    {Module "BLEND STAGE 4"}

    Code:
    repeat
      stageofblend := 4;                                      
      SetLightingLevel("GREEN", 0%, "4s");                    
      delay(4);
      stageofblend := 5;                                      
      SetLightingLevel("RED", 100%, "4s");                    
      delay(4);
      stageofblend := 6;                                      
      SetLightingLevel("BLUE", 0%, "4s");                     
      delay(4);
      stageofblend := 1;                                      
      SetLightingLevel("GREEN", 100%, "4s");                  
      delay(4);
      stageofblend := 2;                                     
      SetLightingLevel("RED", 0%, "4s");                      
      delay(4);
      stageofblend := 3;                                      
      SetLightingLevel("BLUE", 100%, "4s");                  
      delay(4);
    until false;                                            
      
    {Module "BLEND STAGE 5"}

    Code:
    repeat
      stageofblend := 5;                                      
      SetLightingLevel("RED", 100%, "4s");                    
      delay(4);
      stageofblend := 6;                                      
      SetLightingLevel("BLUE", 0%, "4s");                     
      delay(4);
      stageofblend := 1;                                      
      SetLightingLevel("GREEN", 100%, "4s");                 
      delay(4);
      stageofblend := 2;                                     
      SetLightingLevel("RED", 0%, "4s");                     
      delay(4);
      stageofblend := 3;                                      
      SetLightingLevel("BLUE", 100%, "4s");                   
      delay(4);
      stageofblend := 4;                                      
      SetLightingLevel("GREEN", 0%, "4s");                    
      delay(4);
    until false;                                               
      
    {Module "BLEND STAGE 6"}

    Code:
    repeat
      stageofblend := 6;                                     
      SetLightingLevel("BLUE", 0%, "4s");                     
      delay(4);
      stageofblend := 1;                                      
      SetLightingLevel("GREEN", 100%, "4s");                  
      delay(4);
      stageofblend := 2;                                     
      SetLightingLevel("RED", 0%, "4s");                     
      delay(4);
      stageofblend := 3;                                      
      SetLightingLevel("BLUE", 100%, "4s");                   
      delay(4);
      stageofblend := 4;                                      
      SetLightingLevel("GREEN", 0%, "4s");                    
      delay(4);
      stageofblend := 5;                                      
      SetLightingLevel("RED", 100%, "4s");                   
      delay(4);
    until false;                                                
      
     
    Nick G, Jun 22, 2014
    #11
  12. Smokey240

    Nick G

    Joined:
    Jun 19, 2014
    Messages:
    6
    Likes Received:
    0
    Location:
    New Zealand
    Also,

    by using the IF statement in my "control" module to enable other modules, will I be flooding the bus?
     
    Nick G, Jun 22, 2014
    #12
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.