Ramp times

Discussion in 'C-Bus Automation Controllers' started by ssaunders, Sep 13, 2022.

  1. ssaunders

    ssaunders

    Joined:
    Dec 17, 2008
    Messages:
    231
    Likes Received:
    31
    Location:
    Melbourne
    I think I understand ramps. Happy to be corrected.

    On a NAC/SHAC, if an object/group is at zero, and I specify a SetCBusLevel to 255 over eight seconds, then the ramp takes eight seconds.

    But if a group is zero, and I set it to go to 127 over eight seconds, then the ramp takes four seconds, being the time it would take getting to 127 on its way to an ultimate level 255, which it will never reach.

    The same goes for an eight second ramp of 127 to 145, which is an eventual total ramping time of around 0.6 seconds.

    So is this correct logic? Ramp = ramp rate, which is not the same as time to transition from one state to another.

    School me for why should my thinking be busted.
     
    ssaunders, Sep 13, 2022
    #1
  2. ssaunders

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    Correct. That's why it's called a ramp 'rate' not a ramp 'time' :)
     
    Ashley, Sep 13, 2022
    #2
    ssaunders likes this.
  3. ssaunders

    ssaunders

    Joined:
    Dec 17, 2008
    Messages:
    231
    Likes Received:
    31
    Location:
    Melbourne
    :D:D:D

    And "I think I understand" instantly turns into "Yup. I got it." Thanks @Ashley. I can not believe it's been over a decade until I've actually really looked at the detail of a ramp (rate). :oops:
     
    ssaunders, Sep 13, 2022
    #3
  4. ssaunders

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    Some more useless information:
    There a 16 ramp rates because the ramp rate is enconded using 4 bits in the protocol.
    The intervals are counted in about 16mS increments (can't remember the exact figure), so with a 16 bit counter you have a maximum time interval of 65536 * 16mS = 1048576mS = about 17.5 minutes, which is why 17 minutes is the longest ramp rate. Made it easy to implement in the original (slow) microprocessors of the late 90's.
     
    Ashley, Sep 14, 2022
    #4
    Mr Mark likes this.
  5. ssaunders

    Ks04

    Joined:
    Dec 28, 2019
    Messages:
    107
    Likes Received:
    9
    I've actually always wondered this! I'd love a ramp rate less than 4sec
     
    Ks04, Sep 14, 2022
    #5
  6. ssaunders

    ashleigh Moderator

    Joined:
    Aug 4, 2004
    Messages:
    2,392
    Likes Received:
    24
    Location:
    Adelaide, South Australia
    And if you look at DALI by comparison you will see that many things there use FADE TIMES, which are real times, not rates.

    For example with a fade time of 4 seconds, a fade from 0 to 254 (in DALI, level 255 is magic), would run for 4 seconds. But so would a fade from 10 to 12. Or 19 to 73. Or whatever.

    This is one of those things that makes the translation of cbus ramp rates to fade times VERY difficult, and any match is usually a matter of luck rather than anything else.
     
    ashleigh, Sep 14, 2022
    #6
    ssaunders and Mr Mark like this.
  7. ssaunders

    kojobomb

    Joined:
    May 27, 2019
    Messages:
    71
    Likes Received:
    6
    Location:
    Possum Brush
    so is there any way to produce a ramp rate over the 17.5ish (1020 seconds) minute ramp rate?
     
    kojobomb, Oct 26, 2023
    #7
  8. ssaunders

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    The longest ramp rate increments the group address by 1 every 4 seconds, so if you want longer ramp rates just use logic and a timer to increment the group address at the appropriate rate. You can use a combination of existing long ramp rates with delays between to stretch them out too.
     
    Ashley, Oct 26, 2023
    #8
  9. ssaunders

    kojobomb

    Joined:
    May 27, 2019
    Messages:
    71
    Likes Received:
    6
    Location:
    Possum Brush
    Hi Ashley, what logic and timer are you suggesting to use? toolkit or scripting in SHAC or NAC? i get that if i was to increment group address by 1 say every 16 seconds i could get a ramp rate of about 60 minutes but I'm not sure where you are suggesting to implement this.
     
    kojobomb, Oct 26, 2023
    #9
  10. ssaunders

    kojobomb

    Joined:
    May 27, 2019
    Messages:
    71
    Likes Received:
    6
    Location:
    Possum Brush
    Hi @Ashley , what logic and timer are you suggesting to use? toolkit or scripting in SHAC or NAC? i get that if i was to increment group address by 1 say every 16 seconds i could get a ramp rate of about 60 minutes but I'm not sure where you are suggesting to implement this.
     
    kojobomb, Oct 30, 2023
    #10
  11. ssaunders

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    One option would be to create a resident script that runs at the desired increment rate (i.e. 16 seconds). Create a dummy control group address that is the desired final level. Every time the script runs compare the group you are ramping with the control group. If they are different increment or decrement the actual group.
     
    Ashley, Oct 30, 2023
    #11
  12. ssaunders

    kojobomb

    Joined:
    May 27, 2019
    Messages:
    71
    Likes Received:
    6
    Location:
    Possum Brush
    So what is the method to increase GA level by '+1' "Desired increment rate" as apposed to a final level? then an increase of '+1' by 16 seconds would work. I haven't been able to find a command for increase level by set amount!!!
    I'm sorry to keep asking questions that should seem quite easy to search for answers but I'm only grasping this scripting 1 new task at a time and not getting much luck when searching for answers.
     
    kojobomb, Oct 30, 2023
    #12
  13. ssaunders

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    Read current value. Add one to it. Write new value.
     
    Ashley, Oct 31, 2023
    #13
  14. ssaunders

    kojobomb

    Joined:
    May 27, 2019
    Messages:
    71
    Likes Received:
    6
    Location:
    Possum Brush
    Thank you, I knew I was missing something that was right in front of me.
     
    kojobomb, Oct 31, 2023
    #14
  15. ssaunders

    kojobomb

    Joined:
    May 27, 2019
    Messages:
    71
    Likes Received:
    6
    Location:
    Possum Brush
    I now have Ramp times closer to my desired outcome, increment ramp up is 4 levels every minute (65 minutes in total) and decrement ramp is 20 levels every minute (12 minutes in total) the problem I'm having is the last increase or decrease if not exactly 4 levels or 20 levels I am getting a "Error Log"

    Library cbuslogic:0: Value -15 out of range, must be 0-255
    stack traceback:
    [C]: in function 'error'
    Library cbuslogic: in function '_ConvVal'
    Library cbuslogic: in function 'SetCBusLevel'

    Can I place a log and read the error and place an action like

    if (Value=negative)
    then SetCBusLevel(0, 56, 5, 0, 0)
    elseif (value =positive)
    then SetCBusLevel(0, 56, 5, 255, 0)
    end

    If so can someone help with how to read "error log" and how to place variable "positive" and "negative"

    Code:
    SOC= GetCBusMeasurement( 0, 50, 48)
    
    discharge = GetCBusMeasurement( 0, 50, 50)
    
    level = GetCBusLevel(0, 56, 5)
    
    state = GetCBusState(0, 56, 5)
    
    
    
    if  ( SOC>85) and ( discharge<250) and (level<255)
    
    
            then
    
                
    
                    -- Set '0/56/5' to "ON" over "?"
                            SetCBusLevel(0, 56, 5, level+4, 1000)
    
    log (SOC,discharge,level, state)
     
                                        elseif ( SOC<90) or ( discharge>500)and (level>1)
                                            then
     
                                                    -- Set '0/56/5' to "OFF" over 5 minutes
                                                            SetCBusLevel(0, 56, 5, level-20, 1000)
    
    log (SOC,discharge,level)
     
    end
    
    
     
    kojobomb, Oct 31, 2023
    #15
  16. ssaunders

    Pie Boy

    Joined:
    Nov 21, 2012
    Messages:
    248
    Likes Received:
    31
    Location:
    New Zealand
    error
    Library cbuslogic:0: Value -15 out of range, must be 0-255
    it is just saying you are attempting to set the value of the object to an value that is not accepted and not between 0-255

    what about this, added a bit in there to ensure that a level always in the 0-255 range

    SOC= GetCBusMeasurement( 0, 50, 48)

    discharge = GetCBusMeasurement( 0, 50, 50)

    level = GetCBusLevel(0, 56, 5)

    state = GetCBusState(0, 56, 5)



    if ( SOC>85) and ( discharge<250) and (level<255) then

    -- Set '0/56/5' to "ON" over "?"
    level = level + 4

    if level > 255 then
    level = 255
    end

    SetCBusLevel(0, 56, 5, level, 1000)

    log (SOC,discharge,level, state)

    elseif ( SOC<90) or ( discharge>500)and (level>1) then

    level = level -20

    if level < 0 then
    level = 0
    end

    -- Set '0/56/5' to "OFF" over 5 minutes
    SetCBusLevel(0, 56, 5, level, 1000)

    log (SOC,discharge,level)

    end
     
    Pie Boy, Oct 31, 2023
    #16
  17. ssaunders

    SgrAystar

    Joined:
    Oct 4, 2018
    Messages:
    57
    Likes Received:
    5
    Location:
    Melbourne, Australia
    just checking the elseif does what you want without extra brackets, did you mean it to be
    elseif ( SOC<90) or ( ( discharge>500) and (level>1) ) then -- the way it is now, or
    elseif ( ( SOC<90) or ( discharge>500) ) and (level>1) then -- needs the extra brackets​
     
    SgrAystar, Nov 1, 2023
    #17
  18. ssaunders

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    Why Lua thinks AND should have a higher precedence than OR is just insane. But then the whole language is so completely screwed up I often think it must have been an April fools joke that someone took seriously.
     
    Ashley, Nov 1, 2023
    #18
  19. ssaunders

    ssaunders

    Joined:
    Dec 17, 2008
    Messages:
    231
    Likes Received:
    31
    Location:
    Melbourne
    While I will say that LUA is "interesting", SQL, C++, Python and more always give higher precedence to AND over OR, with NOT trumping both. It's kind of a convention.

    Not so APL, which if you think LUA is an April Fools gag, check that basket case out! Left to right precendence with scope. So a plus before a multiply does the addition first...
     
    ssaunders, Nov 1, 2023
    #19
  20. ssaunders

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    Actually C++ does AND/OR left to right like C. SQL isn't a language and python is a toy that makes worse mistakes than Lua :).
     
    Ashley, Nov 1, 2023
    #20
    ssaunders likes this.
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.