jeepers52004 Posted August 9, 2015 Report Share Posted August 9, 2015 Hello, I'm just starting up the Unitronics/Unistream learning curve and attempting to map features from Automation Direct PLC programming to Unistream. One of the first functions I need to replicate is cycle timing. When using the TON, I can subtract the current value from the preset value of the timer to get a "raw" value for cycle time. This comes out as an unsigned integer in milliseconds. I would like to divide that number by 1000 to get the result in seconds. That's simple enough but takes another tag and is limited to the unsigned integer format. Is there a way to do all the math in floating point to provide fractions of a second (or minute)? When I tried to use a formula, I was unable because the default values for the timer function are unsigned integer which meant I couldn't assign those tags to the variables in the formula editor. Also, are there count up timer functions? Like others, I'm new to Unitronics so if I'm missing something, feel free to enlighten me. Thanks!! Michael Link to comment Share on other sites More sharing options...
Alexander Posted August 11, 2015 Report Share Posted August 11, 2015 Do you need to log this value into a table or use it for calculations? If you are only displaying it on the HMI there is an option to display the elapsed time within a Timer Box. Link to comment Share on other sites More sharing options...
jeepers52004 Posted August 12, 2015 Author Report Share Posted August 12, 2015 Yes. There are occasions when we log cycle times as part of our DAQ process and I believe the test I'm working on will require logging of the cycle times. Link to comment Share on other sites More sharing options...
Alexander Posted August 12, 2015 Report Share Posted August 12, 2015 Yes, it should absolutely be possible to use a few of the math functions to convert the value into a real value with a decimal point. Once you have the elapsed time calculated into a UINT32 value using the Sub funciton you can then use the Div (Divide) function and divide by 1000 to return a whole integer value for second. Then the Mod (Modulo) function can be used also using a divisor of 1000 to return the remainder or fractional part of the seconds. With these two separate pieces you can then use the Int to Real part and use the result from the Div operation as the integer part, and the result of the Mod operation as the fractional part. Since you will be using a timer you can then use a decimal position of 3. Ex. Timer A Preset Value: 10.000 seconds, Current Time: 5.125 seconds Subtraction function result: 4875 Div by #1000 result: 4 Mod #1000 result: 875 Int to Real result using 3 decimal places: 4.875 All of the timers within UniLogic are count down timers so this would be the best method to store a true floating point value into the data tables. Link to comment Share on other sites More sharing options...
jeepers52004 Posted August 13, 2015 Author Report Share Posted August 13, 2015 That's great! Thanks for the assistance; it's much appreciated. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now