01-17-2011 07:13 AM
Hello.
I want to use this simple code to calculate the time in milliseconds passed during a cycle, accurate precision is not important.
Although it does work, in help file it says in the description:
"...Be careful when you use this function in comparisons because the value of the millisecond timer wraps from (2^32)–1 to 0."
How can I avoid this problem? This timing should be used to control the pump valves, and if it will bug one day it will blow up the engines.
Secerely.
Solved! Go to Solution.
01-17-2011 07:19 AM
If you subtract (as your example shows), then you should have no problem, because subtraction works correctly when the integer wraps around (i.e. if you were using a U8 10 minus 250 would correctly produce 16).
The only exception to this is if you wrap around twice before doing the substraction, because then you would miss one entire cycle, but since 4.2 billion ms is roughly 50 days, this is not very likely to happen.
01-17-2011 07:23 AM
Thanks!