I think a timer in Basic is feasible to be accurate within .05 seconds. This is my idea (some errors to be worked out but it gets the idea across)-

Code:

ClrHome
­1→Q
0→T
0→A
0→O
0→P
0→U
0→S
0→D
Output(5,4,"PRESS ANY FOR START"
Repeat Ans   //waits till button is pressed
getKey
End
ClrHome
Repeat not(C)+(startTmr=A)+getKey
O+(P-T→O   //O is the offset between the start of a second of the RTC and where you pressed the button... in ticks
If Q=0
33-P→O  //33 is the estimated ticks/ sec for times under one second
P→T
O
While (Ans>0)not(getKey   // counts down offset
Ans-1
End
Ans→D
Q+(Ans=0→Q
U+P+(O-D→U
Output(5,13,Q
D=0→C
0
startTmr→A 
While Cnot(getKey)(startTmr=A // waits till RTC changes and counts ticks till then
Ans+1

End
Ans→P
End
ClrHome
//calculate Seconds
Output(5,12,S

I've been yelled at a lot on SAX for this Very Happy please give me your logical, well reasoned thoughts below. And feel free to ask any questions about the code Good Idea
Readable code, which is run a few times to get an "average" of the "sub-second" time offset.


Code:
// Mateo Note: This is the core of the program:

0->B
startTmr->A
While startTmr=A    // Mateo Note: This is asynchronous. The RTC will never align at the same PC every loop
B+1->B
End

// Mateo Note: He tries to use the B variable as the new "sub-second time" offset.
A timer in basic IS possible, just not how you're trying to do it. Misleading title.
As Mateo said, you just need to get an average time (over many runs) since the 1-second accuracy of the time functions isn't very accurate. But regardless, you could just use an asm timer like this one which will be wayy more accurate.

EDIT: This was not what Mateo was trying to say.
mr womp womp wrote:
As Mateo said, you just need to get an average time (over many runs) since the 1-second accuracy of the time functions isn't very accurate. But regardless, you could just use an asm timer like this one which will be wayy more accurate.

I didn't say that. I just said what his code is doing. It isn't accurate at all, and it won't work for multiple reasons. Of course, he won't listen to me, so I no longer feel like answering any of his questions.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement