![]() |
Forum Index : Microcontroller and PC projects : Time$ - what the Hell....
Author | Message | ||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9610 |
I don't follow this at all..... ![]() My code is: This DOES NOT work. The clock never moves past 00:00:00, despite the 'Wait for tank' message flashing away there happily. The background RTC - having been reset in the line before the DO/LOOP, should now count up - it does not. If I run this test code right at the top of the program: Time$="00:00:00" DO Text MM.HRES/2,165,TIME$,CM,2,1,RGB(BROWN) Text mm.hres/2,MM.VRES-25,"WAIT FOR TANK...",CM,2,1,RGB(White) Pause 500 Text mm.hres/2,MM.VRES-25," ",CM,2,1,RGB(BLACK) Pause 500 Loop It works exactly as expected, and the timer counts up on the LCD. But the code above - which is essentially the same - does not. If I CTRL-C break the program when it WON'T count, then quickly ask for a '? TIME$', it is only counting from the point I CTRL-C stopped the program, so it is like resetting the time$ inside a loop(but only once) is not taking effect.... Can anyone help with this, as I don't understand what I am doing wrong. ![]() Smoke makes things work. When the smoke gets out, it stops! |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
try a PRINT Time$ and also try T$ = Time$ Text mm.hres/2,165,T$,CM,2,1,RGB(BROWN) VK7JH MMedit |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9610 |
PRINT Time$ added to DO/LOOP - never makes it past 00:00:01 CTRL-C break, then ? Time$ - 00:00:06, so the RTC is ticking again, but only AFTER you CTRL-C break the running code - inside a loop which, does not clear the RTC, so it SHOULD be ticking.... I will now try the T$ idea. EDIT: Results from adding a 'PRINT Time$' to the loop: ![]() Results of saving Time$ to T$ first is EXACTLY the same - the RTC never moves. The extra code I added was: T$=Time$ which is now the first line in the DO/LOOP with the blinking tank message: ![]() EDIT: Run the code for 7 seconds, RTC never moves past 1s. CTRL-C break, wait a little, ask for the time$: ![]() This is really odd..... ![]() Smoke makes things work. When the smoke gets out, it stops! |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
I agree that there seems to be a problem. I would use a settick to do the timing. That alone might solve the problem Rather than using the clock, I prefer my own counter. It is counting at double speed here but with the two pauses as in your code, it should be close. I would still use settick. Jim VK7JH MMedit |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9610 |
I....am....a....phucking.....idiot. ![]() I added a PRINT "DEBUG" right after LOOP UNTIL PIN(BLU)=0 OR BUTTON line. This resulted in the above readout. If everything was working correctly, I should NOT get the debug messages, but I was. This revealed all. PIN(BLU) is the top-level tank sensor. It HAS to be out of water(and therefore zero), but I have a hardware short on that one for now to simulate a full tank. Naturally, you can't have the lower sensor out of water at the same time as the upper one IN water, so what was happening, was that the OR operator on the LOOP UNTIL PIN(BLU) OR BUTTON line, was seeing that the top-level sensor was now under water, so it was then looping, and it comes around the same loop again, and falls over itself. As soon as I removed the hardware short on the BLU input, the problem went away, and the timer now works. Sheesh..... My brain sometimes..... ![]() Smoke makes things work. When the smoke gets out, it stops! |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |