cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

FIL macro for calculation of cycle time

KenFarley
21-Topaz I

FIL macro for calculation of cycle time

Hello,

I've found it's very helpful to include a time estimate for my NC programs, which I put in a comment block at the beginning of the file. Historically, I've manually added this, but there is a way to do it with the filter (FIL) file and a macro. I looked at the PTC macros and found some code that was supposed to do this, but it does not work. Basically, the algorithm being implemented does the following:

(1) Store the current line number from the input CL file.

(2) Switch the postprocessor into "simulation mode", which does not output any actual processed code.

(3) Process the input CL file, one statement at a time, until the end of the file is encountered.

(4) Get the cycle time from the appropriate "POSTF" function call.

(5) Rewind the input CL file to the line immediately after the starting line you saved in (1).

(6) Turn off the "simulation mode".

(7) Process the remainder of the input CL file normally.

This is accomplished via the following FIL file code:

$$---- [ FIL commands begin ] ---------

CIMPOS = POSTF ( 7, 1 ) + 1 $$ Set the return CL position

JUNK = POSTF ( 2, 1, 1867, 1 ) $$ Turn on simulation mode

DO / ENDDO, INDEX = 0, 10

JUNK = POSTF ( 14 ) $$ Get next CL file record

CMDTYP = POSTF ( 7, 2 ) $$ Obtain the CLASS from record

IF ( CMDTYP.EQ.14000 ) THEN

TOTTIM = POSTF ( 1, 3, 495 ) $$ Get the cycle time

INSERT/ '( Est Time : ', TOTTIM, ')$'

INDEX = 11 $$ Force loop exit

ELSE

RESULT = POSTF ( 13 ) $$ Process the current CL line

INDEX = 2

ENDIF

ENDDO) CONTIN

JUNK = POSTF ( 15, CIMPOS ) $$ Reset CL to return position

JUNK = POSTF ( 2, 1, 1867, 0 ) $$ Turn off simulation mode

$$---- [ FIL commands end ] ----------

The result I get is always zero, when I use the above code. If I do the "POSTF ( 1, 3, 495 )" stuff at the end of normal file processing, I get a meaningful time, but don't really want to put that at the end of my NC code file. Any ideas as to why the "simulation mode" doesn't seem to correctly calculate cycle time? Is there a way for me to process the contents of the CL file, then prepend the time estimate on the output file?

Anyone have any pointers on getting this to work?


This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
1 ACCEPTED SOLUTION

Accepted Solutions

So, it's been a while, and I haven't really seen any response. I've tried a number of iterations at methods to calculate program run time, but it seems that the only one that works for me is to do so at the very end of processing the CL file. So, here's my macro for doing this:

$$

$$ --[ Macro : WRTTIM ]-------------------------------------------------

$$

$$ Obtains and outputs the total runtime at the present time, as a prop-

$$ erly formatted comment. Utilizes the always-obscure and cryptic POSTF

$$ function to read the correct common variable.

$$

WRTTIM = MACRO/

MNTIME = POSTF ( 1, 3, 0495 ) + 1.0 $$ Get the total runtime

HRTIME = INTF ( MNTIME / 60 )

CALL/ IN2TXT, INTVAL = HRTIME, NUMDIG = 2

HRTEXT = TEXT/ TXTVAL

MNTIME = INTF ( MNTIME ) - ( HRTIME * 60 )

CALL/ IN2TXT, INTVAL = MNTIME, NUMDIG = 2

MNTEXT = TEXT/ TXTVAL

TXTPRE = TEXT/ '( E', (TEXT/LOW,(TEXT/'st ')), 'T'

TXTPRE = TEXT/ TXTPRE, (TEXT/LOW,(TEXT/'ime : '))

TXTHRS = TEXT/ ' H', (TEXT/LOW,(TEXT/'ours '))

TXTMNS = TEXT/ ' M', (TEXT/LOW,(TEXT/'inutes'))

INSERT/ TXTPRE, HRTEXT, TXTHRS, MNTEXT, TXTMNS

INSERT/ ' )$'

TERMAC

My current "solution" is to just write this at the end of my processed file, then hand edit (unfortunately) and move it to the beginning of the file. The reason for moving it is that many of the programs I'm generating are really long, and the drip feeding program we use only shows a small portion of the file in its preview. This way the person running the program can get an idea of the amount of time the program will take and plan accordingly.

View solution in original post

2 REPLIES 2

So, it's been a while, and I haven't really seen any response. I've tried a number of iterations at methods to calculate program run time, but it seems that the only one that works for me is to do so at the very end of processing the CL file. So, here's my macro for doing this:

$$

$$ --[ Macro : WRTTIM ]-------------------------------------------------

$$

$$ Obtains and outputs the total runtime at the present time, as a prop-

$$ erly formatted comment. Utilizes the always-obscure and cryptic POSTF

$$ function to read the correct common variable.

$$

WRTTIM = MACRO/

MNTIME = POSTF ( 1, 3, 0495 ) + 1.0 $$ Get the total runtime

HRTIME = INTF ( MNTIME / 60 )

CALL/ IN2TXT, INTVAL = HRTIME, NUMDIG = 2

HRTEXT = TEXT/ TXTVAL

MNTIME = INTF ( MNTIME ) - ( HRTIME * 60 )

CALL/ IN2TXT, INTVAL = MNTIME, NUMDIG = 2

MNTEXT = TEXT/ TXTVAL

TXTPRE = TEXT/ '( E', (TEXT/LOW,(TEXT/'st ')), 'T'

TXTPRE = TEXT/ TXTPRE, (TEXT/LOW,(TEXT/'ime : '))

TXTHRS = TEXT/ ' H', (TEXT/LOW,(TEXT/'ours '))

TXTMNS = TEXT/ ' M', (TEXT/LOW,(TEXT/'inutes'))

INSERT/ TXTPRE, HRTEXT, TXTHRS, MNTEXT, TXTMNS

INSERT/ ' )$'

TERMAC

My current "solution" is to just write this at the end of my processed file, then hand edit (unfortunately) and move it to the beginning of the file. The reason for moving it is that many of the programs I'm generating are really long, and the drip feeding program we use only shows a small portion of the file in its preview. This way the person running the program can get an idea of the amount of time the program will take and plan accordingly.

Just noticed I have a call to "IN2TXT", another macro, in that posted code. That particular routine converts a supplied number to a specific number of digits, storing it in "TXTVAL". If you are interested, here it is:

$$

$$ --[ Macro : IN2TXT ]-------------------------------------------------

$$

$$ Converts an integer value to a text string, with the desired

$$ number of characters. If necessary, the number is padded with

$$ leading zeroes to achieve the desired width.

$$

$$ Parameters

$$ INTVAL : the value that is to be processed

$$ NUMDIG : the number of characters the number is to fill

$$

$$ In order to properly use this macro, a "global" variable called TXTVAL

$$ must have been declared in the program. This is due to the fact that

$$ macros allow for input of parameters, but not output.

$$

IN2TXT = MACRO/ INTVAL, NUMDIG

WRKVAL = INTF ( INTVAL )

DIGSOK = 1 + INTF ( LOGF ( WRKVAL ) / LOGF ( 10.0 ) )

NUMZED = NUMDIG - DIGSOK

IF ( NUMZED.GT.0 ) THEN

TXTVAL = TEXT/ REPEAT, NUMZED, '0', CONVI, WRKVAL, DIGSOK

ELSE

TXTVAL = TEXT/ CONVI, WRKVAL, NUMDIG

ENDIF

TERMAC

Top Tags