Time variable within PE6 simulation

tmfkam

Senior Member
Is it possible to more accurately represent the 'Time' variable within a program under simulation in PE6?

I have a couple of statements along the line of:

Code:
DisableTime
Let Time=0
EnableTime
Do
  Toggle LED
  If Switch=1 Then
    GoSub SwitchPressed
  EndIf
  If Time > 120 Then
    GoSub NoSwitchPressed
  EndIf
Loop
Under simulation, after two and a half hours the Time variable had reached 50!

I can accept that it might run slower than on a physical device, but if there is a way of speeding this up I'd like to hear how. I began to wonder if Time was a byte variable as I'd initially tested for Time > 300, thinking that it might never have got to 300 any way. It seems as though that wasn't why things didn't appear to be working.
 

Technical

Technical Support
Staff member
Time is already being simulated correctly in this scenario.

As your program contains no 'pauses', on a real life part there will be hundreds of do-loop iterations before the time variable increments 1 second.
Therefore the same applies in simulation, as the time variable increments in simulation elapsed time, not in 'computer real-time'. Therefore you will need hundreds of the loop to simulate on screen before time variable increments.

To resolve this in simulation either
1) add a pause within the loop to allow 'simulation time' to increment a bit
2) do something like this to speed up the simulation timeout

#ifdef simulating
If Time > 2 then
#else
If Time > 120 then
#endif
 

tmfkam

Senior Member
I see.

Thanks for the clarification. I'll probably go for the IfDef Simulating option.

Code:
DisableTime
Let Time=0
EnableTime
Do
  Toggle LED
  If Switch=1 Then
    GoSub SwitchPressed
  EndIf
#IfNDef Simulating Then
  If Time > 120 Then 'Two minutes
#Else
  If Time > 2 Then 'Time runs slower in the simulator
#EndIf
    GoSub NoSwitchPressed
  EndIf
Loop
 
Top