Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : MM TIME$ PLEASE? Where X<>1 !!!
Author | Message | ||||
Nixie Regular Member Joined: 19/02/2013 Location: AustraliaPosts: 66 |
Instead of X equalling 1, it doesn't ! If I adjust the PAUSE to 1000, yes it all behaves itself. But I can't afford to do that because I want to use it without using PAUSE in a program where I want to measue times of less than one second. I know I could cheat by using what X turns out to be, but I'm hoping for a more elegant solution? Any assistance greatly appreciated. Using an original BW MM with ver 4.3 firmware/ mmbasic. THE PROGRAM: 100 CLS: M=0 120 S=VAL(MID$((TIME$),7,2)) 'S= the number of seconds from the internal clock 130 IF S=59 THEN M=M+1 'Increment the counter M every 60 seconds 140 PAUSE 200 'Without PAUSE X=310 on the first pass! 150 PRINT M,S 160 IF M=3 THEN END 170 GOTO 120 ONSCREEN RESULTS: 0 58 0 58 1 59 2 59 3 59 4 59 5 59 5 0 5 0 5 0 5 0 5 1 5 1 Etc.. Many thanks, Nic "Biggles Smiled Grimly" |
||||
Nixie Regular Member Joined: 19/02/2013 Location: AustraliaPosts: 66 |
Oh dear, I did mean M NOT X. So sorry, my attention to detail slipped. Thanks, N |
||||
MM_Wombat Senior Member Joined: 12/12/2011 Location: AustraliaPosts: 139 |
try, 100 CLS : M=0 : flag=0 . 130 if s=59 AND flag=0 then m=m+1 : flag = 1 140 if s=0 then flag=0 ' reset flag for next occurrence of 59 . . . . . obviously this will fill the screen with lots of values. change 150 to 150 print @(0,30) m,s;" " which will keep the output on one line Regards dennis Keep plugging away, it is fun learning But can be expensive (if you keep blowing things up). Maximite, ColourMaximite, MM+ |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6099 |
Nic, Try this version: CLS: M=0
_Lbl120: S=VAL(MID$((TIME$),7,2)) 'S= the number of seconds from the internal clock IF S=0 THEN ' use zero rather than 59 to increment the minutes if first=0 then ' only inc on the first time through with zero first =1 ' set the flag to stop further incs M=M+1 'Increment the counter M every 60 seconds endif else first=0 ' we have passed the zero so we can reset the flag endif PAUSE 200 'Without PAUSE X=310 on the first pass! PRINT M,S IF M=3 THEN END GOTO _Lbl120 And then study the SETTICK way of doing things. You can use SETTICK to run a short routine every second (or whatever period) and do the counting then return to the main program. That way we are not sitting helpless in a pause. Jim Beaten by slow typing again! VK7JH MMedit MMBasic Help |
||||
MM_Wombat Senior Member Joined: 12/12/2011 Location: AustraliaPosts: 139 |
Great minds think alike TassyJim. I didn't think of the settick function, if that makes you feel any better. 1 finger typer myself... Regards Dennis Keep plugging away, it is fun learning But can be expensive (if you keep blowing things up). Maximite, ColourMaximite, MM+ |
||||
Nixie Regular Member Joined: 19/02/2013 Location: AustraliaPosts: 66 |
Ah ha! I am enlightened! Jim, Dennis, thank you, thank you! This is just so great to get assistance! ..and yes, not only have you answered a couple of puzzles, you expand my knowledge too! Best regards, Nic. |
||||
Print this page |