PE6.0.7.4 Un-resposive during simulation

tmfkam

Senior Member
During a simulation with a 'tight' loop PE6 becomes un-responsive, with no way of canceling the simulation meaning that I have to use Task Manager to shut down PE6 (and lose any changes made but not yet saved).

I normally have the simulation speed set to 30 as this gives the fastest display but once simulation is started if there are no pauses within the program this can't be altered either.

Code:
[color=Green]'14M2 Dual 4017 Driver

'V1  30th October.
'V1b 20th November
'V1c 20th November, improved detection. Detection output placed in loop
'so as to better indicate operation with minimal delay
'V1d 20th November, took out delays.
'V1e Removed sub-routines in main loop to speed up program
'operation.[/color]

[color=Navy]#No_Data
#Picaxe [/color][color=Black]14M2[/color]
[color=Navy]#Define [/color][color=Black]Simulate[/color]
[color=Navy]#Define [/color][color=Black]Microseconds[/color]
[color=Navy]#Define [/color][color=Black]InvertOutput[/color]
[color=Blue]Symbol SigH [/color][color=DarkCyan]=[/color][color=Blue]b.1        [/color][color=Green]'High signal[/color]
[color=Blue]Symbol SigL [/color][color=DarkCyan]=[/color][color=Blue]b.2        [/color][color=Green]'Low Signal

'These are inverted by a BC547 buffer so the logic
'for SigH needs to go Low, and for SigL needs to go High
'To do this, InvertOutput MUST be defined

                        'Ena   Pin 13 of the 4017 must be held low[/color]
[color=Blue]symbol Clk  [/color][color=DarkCyan]=[/color][color=Blue]b.5        [/color][color=Green]'Clock Pin 14 of the 4017 [/color]
[color=Blue]symbol Rset [/color][color=DarkCyan]=[/color][color=Blue]b.4        [/color][color=Green]'Reset Pin 15 of the 4017[/color]

[color=Blue]Symbol [/color][color=Purple]Det1 [/color][color=DarkCyan]=[/color][color=Purple]Pinc.1     [/color][color=Green]'Detect bank 1[/color]
[color=Blue]Symbol [/color][color=Purple]Det2 [/color][color=DarkCyan]=[/color][color=Purple]Pinc.2     [/color][color=Green]'Detect bank 2
'Other detect lines could be connected to Pinc.3, Pinc.4 or Pinc.0
'This would give the maximum detect sensors as:
      '9  Pinc.1 only
      '18 1 & 2
      '27 1, 2 & 3
      '36 1, 2, 3, & 4
      '45 0, 1, 2, 3, 4[/color]

[color=Blue]Symbol Scan [/color][color=DarkCyan]=[/color][color=Navy]9          [/color][color=Green]'Groups of 9 LEDs or sensors connected to 4017[/color]

[color=Blue]Symbol [/color][color=Purple]Current[/color][color=DarkCyan]=[/color][color=Purple]b0       [/color][color=Green]'Current Position[/color]
[color=Blue]Symbol [/color][color=Purple]OutputTime[/color][color=DarkCyan]=[/color][color=Purple]w1    [/color][color=Green]'Count of output loop[/color]

[color=Navy]#Ifdef [/color][color=Black]Microseconds [/color][color=Blue]Then
      Symbol Time_Length [/color][color=DarkCyan]= [/color][color=Navy]500
      [/color][color=Blue]SetFreq M32[/color]
[color=Navy]#Else
      [/color][color=Blue]Symbol Time_Length [/color][color=DarkCyan]= [/color][color=Navy]50
#EndIf[/color]

[color=Blue]Let [/color][color=Purple]Current[/color][color=DarkCyan]=[/color][color=Navy]0[/color]
[color=Blue]High Rset
Low Clk[/color]

[color=Navy]#IfDef [/color][color=Black]InvertOutput [/color][color=Blue]Then
      High  SigH        [/color][color=Green]'Set High Out High (Inverted)
      [/color][color=Blue]Low SigL          [/color][color=Green]'Set Low Out Low   (Inverted)[/color]
[color=Navy]#Else
      [/color][color=Blue]Low  SigH         [/color][color=Green]'Set High Out Low
      [/color][color=Blue]High SigL         [/color][color=Green]'Set Low Out High [/color]
[color=Navy]#EndIf[/color]

[color=Black]Start:
      [/color][color=Blue]Do
            For [/color][color=Purple]Current[/color][color=DarkCyan]=[/color][color=Navy]1 [/color][color=Blue]to Scan
                  High Clk          [/color][color=Green]'Clock the 4017
                  [/color][color=Blue]Low Clk           [/color][color=Green]'Finish the clock pulse
                  [/color][color=Navy]#IfDef [/color][color=Black]Simulate [/color][color=Blue]Then
                        Pause [/color][color=Navy]1000
                  #EndIf
                  [/color][color=Blue]If [/color][color=Purple]Det1[/color][color=DarkCyan]=[/color][color=Navy]0 [/color][color=Blue]Then
                        Let [/color][color=Purple]OutputTime[/color][color=DarkCyan]=[/color][color=Blue]Time_Length
                        [/color][color=Green]'Set Detect Signal
                        [/color][color=Navy]#IfDef [/color][color=Black]InvertOutput [/color][color=Blue]Then
                        [/color][color=Green]'Invert Output logic
                              [/color][color=Blue]Low SigH
                              High  SigL
                        [/color][color=Navy]#Else
                        [/color][color=Green]'Output logic normal
                              [/color][color=Blue]High SigH
                              Low  SigL
                        [/color][color=Navy]#EndIf
                  [/color][color=Blue]EndIf
                  If [/color][color=Purple]Det2[/color][color=DarkCyan]=[/color][color=Navy]0 [/color][color=Blue]Then
                        Let [/color][color=Purple]OutputTime[/color][color=DarkCyan]=[/color][color=Blue]Time_Length
                        [/color][color=Green]'Set Detect Signal
                        [/color][color=Navy]#IfDef [/color][color=Black]InvertOutput [/color][color=Blue]Then
                        [/color][color=Green]'Invert Output logic
                              [/color][color=Blue]Low SigH
                              High  SigL
                        [/color][color=Navy]#Else
                        [/color][color=Green]'Output logic normal
                              [/color][color=Blue]High SigH
                              Low  SigL
                        [/color][color=Navy]#EndIf
                  [/color][color=Blue]EndIf
                  If [/color][color=Purple]OutputTime [/color][color=DarkCyan]> [/color][color=Navy]0 [/color][color=Blue]Then
                        Dec [/color][color=Purple]OutputTime
                  [/color][color=Blue]EndIf
                  If [/color][color=Purple]OutputTime[/color][color=DarkCyan]=[/color][color=Navy]1 [/color][color=Blue]Then
                        [/color][color=Green]'Clear Detect signal
                        [/color][color=Navy]#IfDef [/color][color=Black]InvertOutput [/color][color=Blue]Then
                        [/color][color=Green]'Invert Output logic
                              [/color][color=Blue]High  SigH
                              Low SigL
                        [/color][color=Navy]#Else
                        [/color][color=Green]'Output logic normal
                              [/color][color=Blue]Low  SigH
                              High SigL
                        [/color][color=Navy]#EndIf
                  [/color][color=Blue]EndIf
            Next [/color][color=Purple]Current

            [/color][color=Blue]High Rset   [/color][color=Green]'Reset the 4017
            [/color][color=Blue]Low Rset    [/color][color=Green]'Remove the reset 
      [/color][color=Blue]Loop[/color]
If the above program is run with 'Define Simulation' declared, everything works as expected. If 'Define Simulation' is commented out, PE6 becomes totally un-responsive. Of course, it could just be my old Windows XP machine but I thought I'd mention it...
 

hippy

Technical Support
Staff member
We will have to investigate further. On my XP machine which isn't particularly fast it seems to run okay, output B.5 keeps pulsing high, pause and stop simulation buttons and clicks on the simulation panel chip pins to toggle inputs respond as expected.
 

Technical

Technical Support
Staff member
We can't duplicate this, with or without the line commented. Does it happen if you increase the time delay?
 

tmfkam

Senior Member
Hmm... Must be my old machine then...

I tried this with PE6.0.7.3 and again with 6.0.7.4 with the same results.

I changed the Pause statement within my "IfDef Simulate Then" to PauseUs 1 and it too allowed everything to work as normal, with that removed it crashes every time.

Thanks for looking, I'll assume it is my machine.
 

Technical

Technical Support
Staff member
It looks like your machine just cannot 'keep up' with that simulation speed in the tight loop.

Slow the simulation down, e.g. 50 rather than 30, or a quick workaround would be yo use the predefined 'simulating' directive as

#ifdef simulating
pause 1
#endif

this would add the pause into your simulation but not into a downloaded program.
 

Buzby

Senior Member
We've been round this loop before, and I don't think it's fair to blame the OP's 'antique' machine.

When PE6 first came out I had problems exactly as described above. That was on a 1.8Ghz XP Pro 2Gb laptop.
I still have exactly the same problems, with a few new twists, on a 3.2Ghz Win 7 Ultimate 4Gb desktop.

I can find no minimum spec published for a machine that can run PE6 at high simulation speeds.

When the wish list for PE6 was being compiled a feature I was looking forward to was directives like #GUI_OFF and #GUI_ON, which could be used to switch off the screen updates when running sections of code you didn't need to laboriously follow step-by-step.

PE6 seems to built from 'modules' that 'talk' to each other, but sometimes the 'listeners' can't keep up.

This is a video of running the OP's code last night :
 

tmfkam

Senior Member
That is certainly the problem I see. The code highlighting runs through the code but nothing else in PE 'works' at all and the interface (toolbars and the like) are not fully drawn or refreshed either.
 

tmfkam

Senior Member
It looks like your machine just cannot 'keep up' with that simulation speed in the tight loop.

Slow the simulation down, e.g. 50 rather than 30, or a quick workaround would be yo use the predefined 'simulating' directive as

#ifdef simulating
pause 1
#endif

this would add the pause into your simulation but not into a downloaded program.
"Simulating" is just what I was looking for.
Thanks for that. It will be an enormous help.

Unfortunately, once the simulation has started, the simulation speed control becomes unresponsive and it can't be altered.
Until the simulation is started, the speed control can't be seen.

I could put in the 'Simulating' pause, adjust the speed and then take the pause out again now I know what to do.

But I think I'll stick with:

#ifdef simulating
pause 1
#endif

I should point out that I've not had this problem with other programs, perhaps they've had enough slower commands in them to give enough time for PE to breathe?

The program listing I posted had no problems until I moved most of the code out of separate sub-routines and into the main loop as I tried to speed it up as much as possible. I'd been reading how long each call to the sub-routine and it's subsequent return took and thought that although the code was tidier with sub-routines, I needed the speed of execution much more, so re-wrote the sub-routines as in-line.

Personally, it is the wonderful simulator provided for the PicAxe processors that stops me from seriously considering moving to the raw PIC devices. If I only need to include a few lines of '#ifdef simulating' I'll be happy to do so.
 

Technical

Technical Support
Staff member
Unfortunately, once the simulation has started, the simulation speed control becomes unresponsive and it can't be altered.
Until the simulation is started, the speed control can't be seen.
Right click on the Simulation Start button instead of left click. This starts in stepping mode (break on first line) and you can adjust the speed before hitting play again.
 

tmfkam

Senior Member
Right click on the Simulation Start button instead of left click. This starts in stepping mode (break on first line) and you can adjust the speed before hitting play again.
Wonderful. Easy when you know how...

As I can now incorporate the 'Simulating' option in any tight loops, hopefully I won't see this problem again. Until I forget of course!
 
Top