Jump to content

Timing a Process


Recommended Posts



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.




Link to comment
Share on other sites

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

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...