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.

Changing negative value to zero
#1
Hi,

I have a variable that can range from 40...-10 and I'd like to make a script with the FB editor that checks if the value goes to below zero, and when it does I'll rewrite it to 0. I tried using the 'less than' block comparing the value to 0 but with no luck. Is there any easy IF type of block I could import to the fb editor or any other suggestions how to go around?
Reply
#2
Use maximum function:
   
Reply
#3
Thanks for a quick advice.

The variable (modbus register) my heatpump is calculating is degree minutes for my cooling system. So it calculates positive values when the temperature in my buffer tank is above my setpoint and the cooling activation treshold is 10 DM. Highest DM it calculates is 40 and lowest is -10. I basically want to get rid of the negative DM's so I can get my cooling cycle to start earlier.

So I put the same address for the input and the output, but it didn't work. (tried both 5sec timer and event) It's a mystery to me what happens but after I activate the script the seems like the heatpump isn't able to write the new variable which it calculates and the script overwrites the variable with the last value so it doesn't change. Even after I deactivate the script it does something odd very long until it recovers.

   

Here is a log of the variable and at this page the script is already been deactivated. It seems the heatpump tries to overwrite the next calculated value which is 3, but the script somehow stays with the 2. When the heatpump tries to write the value 10, my cooling cycle starts and after it I think the system recovers from the script somehow and now the heatpump can write reasonable values to variable.

Any advice on that? Do I need to make the timer time longer or do I need some kind of middle step where I compare the output of the maximum value and the modbus register and only rewrite it if they differ?

Attached Files Thumbnail(s)
   
Reply
#4
You must use a different object for the output. Right now you've created an infinite loop.
Reply
#5
How can I do that when the the modbus register is the same where I read the data which my heatpump calculates and where I should write the corrected value?
Reply
#6
You can't do it this way. Your heat pump should have dedicated object for this. Feadback as status and control object.
------------------------------
Ctrl+F5
Reply
#7
With this arrangement I can delay the message a bit, but it still messes a bit with the DM calculation of the heatpump because the delay can only be set to 60sec. Is there any way that I can prevent the data being sent to bus when the DM gets above 0 or run this script only when the DM is below zero?

   
Reply
#8
If you don't want to use a separate object then you need to read the Modbus register via a script and do the conversion before writing to the object. But that's a lot more complicated than using a separate object.
Reply


Forum Jump: