This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Calculate value to procent
#3
(11.06.2021, 02:51)benanderson_475 Wrote: Looks like the above function you posted is javascript... are you running this in the custom javascript scripting part of lm? 
if not and assuming you want lua try the below.

Code:
function rangePercentage (input, range_min, range_max, range_2ndMax)

   percentage = ((input - range_min) * 100) / (range_max - range_min)

  if percentage > 100 then

    if  range_2ndMax then
     percentage = ((range_2ndMax - input) * 100) / (range_2ndMax - range_max)
      if percentage < 0 then
          percentage = 0
         else
          percentage = 100
      end
     
    end
   
    else if percentage < 0 then
        percentage = 0
      end
  end
 
    return percentage
   
  end


log(rangePercentage (65, 46, 195, 195))

Just to clearify. I picked this script up site describing the calculation, so i was sure i was missing something Smile
I am using this script to sum the Supply air vav. 
Code:
function tag_sum(tag)
  local objects, result

  result = 0
  objects = grp.tag(tag)

  for _, object in ipairs(objects) do
    result = result + object.data
  end

  return result
end



sum = tag_sum('Supply')


grp.checkwrite('1/1/1', sum)

Since i only have one central extract vav. I then want to convert the supply sum to an control value 0-100 % to control the Extract vav.
Given that i know the Min/Max flow values of the Vav.
Been searching forum, but have not seen anything.
Reply


Messages In This Thread
Calculate value to procent - by Tokatubs - 10.06.2021, 18:55
RE: Calculate value to procent - by Tokatubs - 11.06.2021, 08:05
RE: Calculate value to procent - by admin - 11.06.2021, 08:11
RE: Calculate value to procent - by Tokatubs - 11.06.2021, 08:27
RE: Calculate value to procent - by tomnord - 07.05.2022, 14:29
RE: Calculate value to procent - by admin - 02.05.2022, 13:08

Forum Jump: