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.

Scripting
#1
Hello guys i made a script and i need you help 
I have underfloor heating and i want to make zones o pwm vavles . what i mean that if the setpoint bigger than the actual temperature by 1C then the valves must be open 100% , if the setpoint bigger than the actual temperature by 0.7 C then the valves must be open 75% and so on.
here is the scrpict that i made but doest work and i dont get any error 

-- zone* = value of the valve
zone0 = 0
  zone1 = 25
  zone2 = 50
  zone3 = 75
  zone4 = 100
-- 3/1/1 set point
-- 12/0/5 actual temperature
  if grp.getvalue('3/1/1') > grp.getvalue('12/0/5') - 1
    then grp.write('4/1/1',zone4)
      elseif
          grp.getvalue('3/1/1') > grp.getvalue('12/0/5') - 0.7
            then grp.write('4/1/1',zone3)
              elseif
                  grp.getvalue('3/1/1') > grp.getvalue('12/0/5') - 0.5
                  then grp.write('4/1/1',zone2)
                    elseif
                  grp.getvalue('3/1/1') > grp.getvalue('12/0/5') - 0.3
                then grp.write('4/1/1',zone1)             
            elseif
          (grp.getvalue'3/1/1') == grp.getvalue('12/0/5')
      then grp.write('4/1/1',zone0)
 
   
end
thank you in advance
Reply
#2
Hello mariosp

You should create event script with tag, and this tag should be for two group addresses
for actual temperature object and for temperature set point

Code:
local actual_temp = grp.getvalue('12/0/5')
local setpoint = grp.getvalue('3/1/1')
local pwm_addr = '4/1/1'

local zone0 = 0
local zone1 = 25
local zone2 = 50
local zone3 = 75
local zone4 = 100

local temp_diff = setpoint - actual_temp

--log(temp_diff)

if temp_diff >= 1 then
  grp.write(pwm_addr, zone4)
elseif temp_diff >= 0.7 then
  grp.write(pwm_addr, zone3)
elseif temp_diff >= 0.5 then
  grp.write(pwm_addr, zone2)
elseif temp_diff >= 0.3 then
  grp.write(pwm_addr, zone1)
else
  grp.write(pwm_addr, zone0)
end
Reply
#3
(16.01.2025, 10:05)RomansP Wrote: Hello mariosp

You should create event script with tag, and this tag should be for two group addresses
for actual temperature object and for temperature set point

Code:
local actual_temp = grp.getvalue('12/0/5')
local setpoint = grp.getvalue('3/1/1')
local pwm_addr = '4/1/1'

local zone0 = 0
local zone1 = 25
local zone2 = 50
local zone3 = 75
local zone4 = 100

local temp_diff = setpoint - actual_temp

--log(temp_diff)

if temp_diff >= 1 then
  grp.write(pwm_addr, zone4)
elseif temp_diff >= 0.7 then
  grp.write(pwm_addr, zone3)
elseif temp_diff >= 0.5 then
  grp.write(pwm_addr, zone2)
elseif temp_diff >= 0.3 then
  grp.write(pwm_addr, zone1)
else
  grp.write(pwm_addr, zone0)
end
To many telegreams with result bus and cpu/io overload

Attached Files Thumbnail(s)
   
Reply
#4
Make sure you only tag the '12/0/5' and '3/1/1' but not '4/1/1'
------------------------------
Ctrl+F5
Reply
#5
(16.01.2025, 11:02)Daniel Wrote: Make sure you only tag the '12/0/5' and '3/1/1' but not '4/1/1'
yes that was for oveload but even when the actual temperature > setpoint open the valve
Reply
#6
What is 1.1.50 Dummy?
------------------------------
Ctrl+F5
Reply
#7
(16.01.2025, 11:29)Daniel Wrote: What is 1.1.50 Dummy?

dummy is Lm you simple put it ets for filter table
Reply
#8
Reboot LM and if still the same then drop some screenshots how you created the script.
------------------------------
Ctrl+F5
Reply
#9
(16.01.2025, 11:43)Daniel Wrote: Reboot LM and if still the same then drop some screenshots how you created the script.
Thanks its ok now !! 
can you describe when we must you use loac?
Reply
#10
Do you mean local variables?
Reply
#11
(16.01.2025, 11:59)RomansP Wrote: Do you mean local variables?
yes im trying to understand the difference between local and global
Reply
#12
local - is used when variable should not be global (by default variables in lua are global)

here is a good resource for a start (to understand really basics of lua language)

https://learnxinyminutes.com/lua/
Reply
#13
(16.01.2025, 12:09)RomansP Wrote: local - is used when variable should not be global (by default variables in lua are global)

here is a good resource for a start (to understand really basics of lua language)

https://learnxinyminutes.com/lua/

thank you !!!
Reply
#14
For you, you can ignore the Local declaration as variables in a script are only in this script. You cannot use them anywhere else. For this script it makes no difference but it is a good programing practice.
------------------------------
Ctrl+F5
Reply
#15
But in this type of script variables are only in this one script.
In LogicMachine it only make sense to use local declaration if you use
loops or functions. But for me putting local in this script is just like a
good practice, to do not use global variables.
Reply
#16
(16.01.2025, 12:26)RomansP Wrote: But in this type of script variables are only in this one script.
In LogicMachine it only make sense to use local declaration if you use
loops or functions. But for me putting local in this script is just like a
good practice, to do not use global variables.
Hello again unfortunately this doesnt work for me the script works fine but the heating actuator doesnt chages the actual value but only the status!
can you you help me write a script that i will write the value of the actual temperature to another group address but with -1C temperature lower i made this but doesnt work! thank you in advance!
Code:
local actual_temp = ('12/0/1')
local fake_temp_adr = ('32/1/68')
local value = ('12/0/1')-(1)
if grp.getvalue('32/1/66',1)
  then
  grp.write('32/1/68',value)
  else log()
 
  end
Reply
#17
Hi

If I understood you correctly, each time when will be new temperature value,
then this value will be subtracted by 1, and sent to another group address.
Then just create an event script for temperature object '12/0/1'

Code:
local value_temp = event.getvalue()
local fake_temp_addr = '32/1/68'

grp.write(fake_temp_addr, value_temp - 1)
Reply
#18
thank you for your help! I will heed your you help once again 
I ended up with the below script that is a event based on the setpoint to change the offset but only if the actual temperature is higher than the setpoint here is the script that i made that doesnt work.
Code:
local setpoint = event.getvalue()
local actual_temp = '12/0/5'
local zone1 = grp.getvalue('3/3/1') - (0.1)
local temp_diff = setpoint - actual_temp


   if temp_diff <= 0.1
  then grp.write('3/3/1',zone1)

end


thank you advance
Reply
#19
(18.01.2025, 08:14)mariosp Wrote: thank you for your help! I will heed your you help once again 
I ended up with the below script that is a event based on the setpoint to change the offset but only if the actual temperature is higher than the setpoint here is the script that i made that doesnt work.
Code:
local setpoint = event.getvalue()
local actual_temp = '12/0/5'
local zone1 = grp.getvalue('3/3/1') - (0.1)
local temp_diff = setpoint - actual_temp


   if temp_diff <= 0.1
  then grp.write('3/3/1',zone1)

end


thank you advance
local actual_temp = grp.getvalue('12/0/5')
Reply
#20
I already try that is not the issue.
Reply


Forum Jump: