Is there a neat way to test if 2 variables are different by less than a small amount? For my application I need to be able to test across a rollover as well.
The application is an MSF clock. This normally returns time in hours and minutes. I convert that to total minutes, a word variable mn in range 0-1440. When the MSF clock receiver fails, I use the 14M2 TIME to increment mn as the minutes pass. I know it's not very accurate but it generally performs well enough - the clock receiver never fails for more than a handful of minutes.
Very occasionally, in spite of parity checking the results, the MSF clock returns the wrong time. I hope to apply a sanity check to each MSF-returned time by comparing new mn to old mn. Because of inaccuracy in TIME, it's feasible that new mn could be a bit different from old mn + 1.
Arithmetically, I want to test if |oldmn-newmn|<smalldiff where smalldiff is ~5. My maths isn't up to describing the test when oldmn and/or newmn is near to 0 or 1440.
The application is an MSF clock. This normally returns time in hours and minutes. I convert that to total minutes, a word variable mn in range 0-1440. When the MSF clock receiver fails, I use the 14M2 TIME to increment mn as the minutes pass. I know it's not very accurate but it generally performs well enough - the clock receiver never fails for more than a handful of minutes.
Very occasionally, in spite of parity checking the results, the MSF clock returns the wrong time. I hope to apply a sanity check to each MSF-returned time by comparing new mn to old mn. Because of inaccuracy in TIME, it's feasible that new mn could be a bit different from old mn + 1.
Arithmetically, I want to test if |oldmn-newmn|<smalldiff where smalldiff is ~5. My maths isn't up to describing the test when oldmn and/or newmn is near to 0 or 1440.