gsd Posted April 15, 2020 Report Share Posted April 15, 2020 Hello first time poster and entry level user to the Unitronics products. I have a current project where I would like to set a Timer duration based off of a calculation from a formula. Basically the formula is: (A*XX) I would like to populate the timer duration based off the output from that formula. I believe I need a TON Timer as I want it to set an output once it has timed out. Is this possible? How do I set the timers duration based off the my formula output? See attached image for what i am intending to do. Thank you Quote Link to comment Share on other sites More sharing options...
gsd Posted April 15, 2020 Author Report Share Posted April 15, 2020 I created a Timer Tag and found the "preset" "current" and "out" tags. How can i set the preset time based on what is output from my formula? Currently i have my formula outputting a REAL # I see the Timer preset tag is a unsigned integer 32 bits long type. Can someone guide me as to how I can translate my formula output into the timer preset? Im sorry if this is really basic. I am a newbie when it comes to this kind of stuff. Thank you Quote Link to comment Share on other sites More sharing options...
MVP 2022 Flex727 Posted April 15, 2020 MVP 2022 Report Share Posted April 15, 2020 First of all, why is your formula outputting a REAL number? You should avoid that if at all possible. Do your calculations with integers and keep track of the decimal place (in your mind) as you go. Then you can use the number to whatever decimal precision you require with some simple math. The timer Preset is in milliseconds, so if you want the preset to be 6 seconds, use the number 6000. If the preset is 3 minutes & 40 seconds, then the preset value would be 220,000. Make sure your calculated value is in milliseconds (do whatever math is required to obtain milliseconds), then place that number into the Preset operand. Quote Link to comment Share on other sites More sharing options...
gsd Posted April 15, 2020 Author Report Share Posted April 15, 2020 6 minutes ago, Flex727 said: First of all, why is your formula outputting a REAL number? You should avoid that if at all possible. Do your calculations with integers and keep track of the decimal place (in your mind) as you go. Then you can use the number to whatever decimal precision you require with some simple math. The timer Preset is in milliseconds, so if you want the preset to be 6 seconds, use the number 6000. If the preset is 3 minutes & 40 seconds, then the preset value would be 220,000. Make sure your calculated value is in milliseconds (do whatever math is required to obtain milliseconds), then place that number into the Preset operand. Thanks for the response Flex727 I guess i'm using REAL # out of ignorance. I will change the type back to integer. With that being said how do i automatically populate the timer's countdown time? (converting from milliseconds isn't an issue) Let me give you some more background: The formula output is dependent on what the HMI user inputs to the numeric box on the HMI screen. So the formula output will constantly be changing every-time the timer is reset and a new value is input into the numeric box. So I need the Timers count down time to "auto populate" with the value from the formula output being presented to it at the time. The count down time is not a static value. I must be using the wrong ladder logic functions because I couldn't find a function that would allow me to populate into the Timers Struct. Let me toil some more and I will report back if I find my mistake. Thank you! Quote Link to comment Share on other sites More sharing options...
gsd Posted April 15, 2020 Author Report Share Posted April 15, 2020 Good News! Using the "Store" function It looks like I'm able to place my formula "output" into the "tag to store" box which in turn allows me to set the timer "preset" by setting that in the B "Store in to tag" box. Now I just gotta make sure i carry out my integer math properly. Thanks! 1 Quote Link to comment Share on other sites More sharing options...
MVP 2022 Flex727 Posted April 15, 2020 MVP 2022 Report Share Posted April 15, 2020 1 hour ago, gsd said: Using the "Store" function Yes, that's correct. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.