jotlake Posted November 20, 2015 Share Posted November 20, 2015 Hello, 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, Jan Link to comment Share on other sites More sharing options...
Omron Forums Support Posted November 20, 2015 Share Posted November 20, 2015 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 Y6PLC that identifies which motion program is running in which cs.pmc Link to comment Share on other sites More sharing options...
jotlake Posted November 20, 2015 Author Share Posted November 20, 2015 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 More sharing options...
sanjay kumar katiyar Posted July 19, 2016 Share Posted July 19, 2016 I tried to use a P variable to find out which block is running but it always shows 6 blocks ahead of actual block executing motion. ie P2000=1 x1 y1 P2000=2 x4 z8 P2000=3 x30 y30 Link to comment Share on other sites More sharing options...
Omron Forums Support Posted July 19, 2016 Share Posted July 19, 2016 Try using a synchronous M variable assignment instead, e.g. M2000==1. Link to comment Share on other sites More sharing options...
sanjay kumar katiyar Posted August 3, 2016 Share Posted August 3, 2016 Thanks 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 Clear M4000==2 abs M4000==3 linear M4000==4 x500 z600F50 M4000==5 circle2 M4000==6 x300 z400 r1000 M4000==7 inc M4000==8 linear M4000==9 x300 y600 z300 F100 M4000==10 circle1 M4000==11 x200 y300 r500 M4000==12 Close Link to comment Share on other sites More sharing options...
Omron Forums Support Posted August 3, 2016 Share Posted August 3, 2016 Synchronous M-var assignments only execute at the start of a move or dwell. See the description in the Turbo Software Ref manual under M{data}=={expression} on page 446. Link to comment Share on other sites More sharing options...
Recommended Posts