Hi,
Hi Alan,
1. I uploaded your program to the 08M2 but it only ran for 4 hours, any ideas.
2. Wondering why no one is using the 'time' option, I thought that was the big advantage of the M2 chip over the older one.
3. Also when I try the simulation program it gets stuck on the time line. How do you make it skip over that.
Cheers Dan
Sorry, this reply must be rather after
your bedtime.
1. I don't know. Is that the original or "speeded up" version (with modified constants) and in the simulator (PE5 or PE6) or on a "real" chip? But it probably doesn't matter too much now as it seems there are better ways to code your requirement.
2. The real advantage of the
time variable is that the PICaxe can do
lots of other stuff and just check occasionally to see how time is progressing. Thus it's ideal for programmers like me who want the PICaxe to "do lots of stuff". However, you've found one of its snags; it may not simulate in a "user-friendly" manner:
The problem is that the simulator must run a hundred or even a thousand times slower than "real time". That's partly because the simulator is a complex program, but also because most programs will run much faster than the programmer can follow. Even the "slow" PICaxe can execute 1,000 - 10,000 lines of program each second.
3. The simulator doesn't "know" what what the program is doing (nor who wrote it), so it assumes that there might be many hundreds of instructions to be executed each second (i.e. between the one second "ticks" for the
time variable) so it only increments the time variable very slowly. However, it should
eventually increment
time from 0 to 1, etc..
One way to skip the time delay is to define a constant such as
#define SIMULATING (I believe PE6 may do this automatically) and then write the appropriate section of code such as :
Code:
#define SIMULATING ; Delete or comment-out for real PICaxe hardware
do
#ifNdef SIMULATING ; The next lines will be included only if the program is NOT simulating
do
loop until time > 59 ; Wait for a minute
#endif
sertxd ("*") ; Mark that "one minute" has passed
loop
But for your application the PAUSE or WAIT commands are probably a much better choice. In this case the simulator "knows" that nothing else is happening so it can shorten the execution time to a "user-friendly" value, perhaps the same as the "real" tme.
WAIT 60 is the simplest instruction to introduce a one minute delay, but personally I would recommend
PAUSE 60000. WAIT is a "pseudo" command which basically multiplies the numerical value by 1000 (i.e. converts ms to seconds) and executes a PAUSE. That's fine for 60 seconds, but 65535 is the largest value that a PICaxe can handle so
WAIT 120 will NOT work correctly. That is explained in the command reference, but if one of us regular programmers is "inspecting" somebody else's program code, then
WAIT 120 doesn't "shout as being wrong" in the same way that
PAUSE 120000 does.
Cheers, Alan.