On Wed, May 24, 2017 at 01:14:10PM -0400, Dan Roganti via vcf-midatlantic wrote:
so you just need the decimal value, this is a 16bit binary counter, so in decimal it's 0 to 65535 ???T1 = PEEK(78) + 256 * PEEK(79)
This code can give errors in the count since say the counter was 78 = 255 and 79 = 1 when you execute the peek(78) and then it increments to 0, 2 before the peek(79) You will then get 255, 2. Don't know if its important to our usage. There are techniques to handle this such as reading high, then low, then high again to see if you read over a rollover. I can provide more if interested.
You'll have to use this calibration test code and a stopwatch to find how many ticks of that Counter will get 1sec of time eg 10 T1 = PEEK(78) + 256 * PEEK(79) 20 FOR J=1 TO 1000:NEXT J 30 T2 = PEEK(78) + 256 * PEEK(79) 40 PRINT T2-T1 50 END
Then adjust J for 1sec before the PRINT displays the answer
But it will wrap around, cause this Counter is non-stop so sometimes T2-T1 will be negative just convert it back to positive if T2 <0 by multiplying this with -1
That's not really correct. Say T1 was 255,255 = 65535 and T2 is 0,0. Subtract is -65535. Just flipping the sign gives 65535. The correct difference is 1. Correct correction if negative time is 65536 + difference I think. This type of stuff is a lot harder than it looks.