11.06.2021, 08:05
(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
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.