Shop OBEX P1 Docs P2 Docs Learn Events
Cog Counter Freezing — Parallax Forums

Cog Counter Freezing

oliver_man_77oliver_man_77 Posts: 7
edited 2008-10-21 18:26 in Propeller 1
I am working on a project where I need to monitor encoder position in reference to a product detection eye "Sync". Based on the encoder position I need to sequence some outputs. The following code is sequencing outputs as desired only it runs for 16 minutes the stahls. I need this to run 24/7.· The program is only in the begining stages of a very complex proscess. Once this code is running 100% it will be layered much more but so far this is my problem. So any ideas why it stops running?

CON
  _clkmode  = xtal1 + pll16x                            
  _xinfreq  = 5_000_000                                 'Set clock to 80 MHz
  High = 1
  Low  = 0
  Out = %1
  Sync = 18                                             'Set pin # for Product Detect
  encoder = 16                                          'Set pin # for Encoder Input
  white = 21                                            'Set pin # for White Start
  cyan = 22                                             'Set pin # for Cyan Start
  magenta = 23                                          'Set pin # for Magenta Start
  yellow = 24                                           'Set pin # for Yellow Start
  black = 25                                            'Set pin # for Black Start
'
VAR
  long  posn
'
PUB Start_cycle
'
  Start_White
  dira[noparse][[/noparse]yellow] := 0                                     'Clear Yellow Start signal
  Start_Cyan
  dira[noparse][[/noparse]black] := 0                                      'Clear Black Start signal
  Start_Magenta
  dira[noparse][[/noparse]white] := 0                                      'Clear White Start signal
  Start_Yellow
  dira[noparse][[/noparse]cyan] := 0                                       'Clear Cyan Start signal
  Start_Black
  dira[noparse][[/noparse]magenta] := 0                                    'Clear Magenta Start signal
return Start_cycle    
'
Pri Start_White
'Configure counter module
  ctra[noparse][[/noparse]30..23] := %01010111                             'Set ctra module to POSEDGE detector
  ctra[noparse][[/noparse]8..0] := encoder                                 'APIN to encoder
  frqa := 1
  phsa := -2000                                         'Encoder counts to delay White signal
  repeat while phsa [noparse][[/noparse]31]
dira[noparse][[/noparse]white]~~                                           'Set White Start signal
'
Pri Start_Cyan
'Configure counter module
  ctra[noparse][[/noparse]30..23] := %01010111                             'Set ctra module to POSEDGE detector
  ctra[noparse][[/noparse]8..0] := encoder                                 'APIN to encoder
  frqa := 1
  phsa := -2000                                         'Encoder counts to delay Cyan signal
  repeat while phsa [noparse][[/noparse]31]                                                                     
dira[noparse][[/noparse]cyan]~~                                            'Set Cyan Start signal              
'
Pri Start_Magenta
'Configure counter module
  ctra[noparse][[/noparse]30..23] := %01010111                             'Set ctra module to POSEDGE detector
  ctra[noparse][[/noparse]8..0] := encoder                                 'APIN to encoder
  frqa := 1
  phsa := -2000                                         'Encoder counts to delay Magenta signal
  repeat while phsa [noparse][[/noparse]31]                                                                     
dira[noparse][[/noparse]magenta]~~                                         'Set Magenta Start signal              
'
Pri Start_Yellow
'Configure counter module
  ctra[noparse][[/noparse]30..23] := %01010111                             'Set ctra module to POSEDGE detector
  ctra[noparse][[/noparse]8..0] := encoder                                 'APIN to encoder
  frqa := 1
  phsa := -2000                                         'Encoder counts to delay Yellow signal
  repeat while phsa [noparse][[/noparse]31]                                                                     
dira[noparse][[/noparse]yellow]~~                                          'Set Yellow Start signal              
'
Pri Start_Black
'Configure counter module
  ctra[noparse][[/noparse]30..23] := %01010111                             'Set ctra module to POSEDGE detector
  ctra[noparse][[/noparse]8..0] := encoder                                 'APIN to encoder
  frqa := 1
  phsa := -2000                                         'Encoder counts to delay Black signal
  repeat while phsa [noparse][[/noparse]31]                                                                      
dira[noparse][[/noparse]black]~~                                           'Set Black Start signal              
'  

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-10-20 21:06
    You're probably getting a stack overrun, since Start_Cycle is being called recursively (i.e. in its own return statement). Putting it in a repeat loop instead should solve the problem.

    -Phil

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Still some PropSTICK Kit bare PCBs left!
  • oliver_man_77oliver_man_77 Posts: 7
    edited 2008-10-21 18:26
    Thanks Phil, that took care of my problem so far. On to the next phase
Sign In or Register to comment.