Jump to content
OMRON Forums

Programmatically detect which and where a CS program is running


Recommended Posts



For our framework and advanced debugging, we would like to programmatically monitor which actual CS program is running and in which line, like the PC/PE commands can report.

If a PLC or PLCC program can detect this, preferably including the call stack like PC/PE commands, we can include this in a gathering setup for tracing which and where a CS program is running.


In CS1 status range X:$2000 to X:$20FF, I can see some activity around X:$20E4 that seems to be related to the the active running program, but I can't find any information that describes how to interprete these (internal) CS status registers.


- Is there a way to programmatically detect the actual "Program Counter" or "Program Execution Pointer" of a running CS program?


Thanks and regards,



Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

Years ago I wrote a PLC that determines which motion programs are running in which coordinate systems. It's big and ugly, but it works (attached).


As for the execution line number, I do not remember exactly how the execution address relates to the line number. There is probably a better way to do that, but I do not remember at the moment.


If I cannot figure it out, you could always try putting a synchronous M-Variable in the program with the line number on it and poll the variable when you want to know what line number the program is executing.


For example:

M400 == 1

X1 Y2

M400 == 2

X5 Y6

PLC that identifies which motion program is running in which cs.pmc

Link to comment
Share on other sites

Thanks for the example, it looks well documented so it will probably be a good start to add detection for the line number and maybe some optimization for a single CS.


A standalone way to determine the program and line number has a preference above adding line debug variables into the code, since that makes it more difficult to analyze and debug existing and running applications without modifying the (production released) source code.


Some time ago I wrote a Notepad++ plugin that visually tracks the current program and line number, using the 'PC' command that highlights the current line. This looks pretty cool, but is off course not really realtime (but still 10 to 20 times per second) and difficult to analyze offline.

Therefore I prefer to find a 'semi realtime' way using a PLC/PLCC combined with the normal data gathering, to match the line numbers to the axis positions.


I will let you know when I have figured that out, but I don't know when I will find the time to do that (since it does not have a high priority).

Link to comment
Share on other sites

  • 7 months later...
  • 2 weeks later...


it works well, but i have one problem that M var takes last value as 11 and never 12 in the program given below.


open prog 5







x500 z600F50




x300 z400 r1000






x300 y600 z300 F100




x200 y300 r500



Link to comment
Share on other sites

This topic is now closed to further replies.

  • Create New...