0 Members and 3 Guests are viewing this topic.
Lbl 0ClrHomeMenu("Physics Tools","Car Timer",1,"Pendulum Timer",2,"Drop Timer",3,"Kinetic Energy",4,"Quit",5)Lbl 1ClrHomePause "Press Enter to Begin"Asm(prgmINWhile Ans=3Asm(prgmINEndstartTmrAsm(prgmINWhile Ans=1Asm(prgmINEndWhile Ans=3Asm(prgmINEndchckTmrDisp "Press 1 to Time Again"Disp "Or press 2 to Return to Menu"Prompt KIf K=1Goto 1Goto 0Lbl 2ClrHomeDisp "Pendulum Stuff!"Pause "Press Enter"Goto 0Lbl 3ClrHomeDisp "Drop It!"Pause "Press Enter"Goto 0Lbl 4ClrHomeDisp "Kinetic Energy!"Pause "Press Enter"Goto 0Lbl 5
;Setup up a timer that waits 2 seconds di ld a,$47 ;8 hz out ($30),a ld a,0 ; no loop, no interrupt out ($31),a ld a,16 ;16 ticks / 8 hz equals 2 seconds out ($32),await: in a,(4) bit 5,a ;bit 5 tells if timer 1 jr z,wait ;is done xor a out ($30),a ;Turn off the timer. out ($31),a
Ok, so am I to assume that I am being a little naive again and that this cannot be simply solve with a little asm program that starts and then another that just gets a time and stops the timer?
I hate to bother but I know next to nothing about asm and have messaged thepenguin77 about this as he wrote a nifty little timer that responds to the linkport actions shown here: https://www.omnimaga.org/ti-z80-calculator-projects/thepenguin77's-utilities/msg350488/#msg350488He has responded but is currently on vacation and I do not wish to interrupt the vacation any further. He linked me to the page below:
https://wikiti.brandonw.net/index.php?title=83Plus:Ports:30If I am understanding the asm from that page using what limited knowledge I have.Code: [Select] ;Setup up a timer that waits 2 seconds di ld a,$47 ;8 hz out ($30),a ld a,0 ; no loop, no interrupt out ($31),a ld a,16 ;16 ticks / 8 hz equals 2 seconds out ($32),await: in a,(4) bit 5,a ;bit 5 tells if timer 1 jr z,wait ;is done xor a out ($30),a ;Turn off the timer. out ($31),aWe are loading an 8hz clock into a ($47). The 8hz clock is turned on ($30). We load a with 0. Now loop control is started ($31) (This is where we are running processes to count ticks?). Below that we keep rolling until a is equal to 16 (counting 16 ticks at 8 hz equals 2 seconds). I am not sure what all the wait part is doing other than hitting the $30 which is the on/off switch.So as I understand using 8hz only gives an accuracy of 1/8th seconds but there are higher hz clocks available. Ticks will have to be counted and stored somewhere which may be able to be retrieved by the same or another program to then use some math and figure out the time based on the ticks that have passed.
So all this is running while the ti-basic processes are also running which I think would also use the CPU which could affect the accuracy of the calculated time?
I feel like I am getting somewhere and I feel like I am not. Am I making any sense at all here?
46h -> (33h) ; 128 Hz on timer21 -> (34h) ; no interrupts but loop; does this work?47h -> (36h) ; 8 Hz on timer31 -> (37h) ; no interrupts but loopStore ports 45h-48h to somewhere secret in ram. MD5Buffer?0 ->(35h); start timer2 in an infinite loop0 ->(38h); start timer3 in an infinite loop (does this work?)
timer2 = (35h) - 1 # subtract 1 so that 255 is the highest valuetimer3 = (38h) - 1simple_elapsed = Compare 45h-48h with stored time to get seconds# ok, the hard part is that the ti84 clock only has a resolution of 1 second# we need to be careful if we're really close to 32 secondstimer3_full_cycles = int( (simple_elapsed - 3) / 32 ) # 3 seconds is overkillseconds_into_current_cycle_safe = (simple_elapsed - 3) % 32 ; if this is -3 it underflows to 29if seconds_into_current_cycle_safe > 32 - 6: if timer3 > 128: timer3_full_cycles += 1# timer2 does a full cycle every 16 ticks of timer3timer3_elapsed = 255 - timer3timer2_full_cycles = int( (timer3_elapsed - 2) / 16 ) # 2 ticks of safetyticks_into_current_cycle_safe = (timer3_elapsed - 2) % 16if ticks_into_current_cycle_safe > 16 - 4: if timer2 > 128: timer2_full_cycles += 1timer2_elapsed = 255 - timer2final_time = timer3_full_cycles * 32 + timer2_full_cycles * 2 + timer2_elapsed / 128final_time -> ANS # how do you do this?
p_StoreAns: ;sets ans to hl B_CALL(_SetXXXXOP2) B_CALL(_OP2toOP1) B_CALL(_StoAns) retp_RecalAns: ;reads ans into hl B_CALL(_RclAns) B_CALL(_ConvOP1) ex de,hl ret
# Start the timersAsm(prgmTIMESTRT)# Store the elapsed time (at 1/128s resolution) into Ans# -1 if an error is detected (timers disabled or system clock went backwards)Asm(prgmTIMEIT)
Lbl 0ClrHomeMenu("Physics Tools","Car Timer",1,"Pendulum Timer",2,"Drop Timer",3,"Kinetic Energy",4,"Quit",5)Lbl 1ClrHomePause "Press Enter to Begin"Asm(prgmTIMESTRTAsm(prgmINWhile Ans=3Asm(prgmINEndAsm(prgmTIMEITDisp AnsAsm(prgmINWhile Ans=1Asm(prgmINEndWhile Ans=3Asm(prgmINEndAsm(prgmTIMEITDisp AnsDisp "Press 1 to Time Again"Disp "Or press 2 to Return to Menu"Prompt KIf K=1Goto 1Goto 0
PROGRAM:0IN:AsmPrgm:DB00:26006F:EF9247:EF5641:EFBF4A:C9