What's new
What's new

Macro Statement On Fanuc Oi-TD Control

Ledyard

Plastic
Joined
Nov 1, 2017
Hi, I have been a long time reader of the forum but this is my first post. I am currently running a Hardinge 2 axis lathe with a Fanuc Series Oi-TD Control. I am trying to set up a bar puller and have the following lines of code run at the end of my program to stop the machine when it reaches the end of the bar (I will eventually move this statement above the puller code to save on the last piece of material):

#102 = 10 (Number of parts desired)
#101 = #101+1 (increment counter)

IF[#101GT#102] THEN M30
M99
%

When the IF statement evaluates as false the program works perfectly and calls the M99 (skipping over the M30) but as soon as the part count is reached and [#101GT#102] evaluates as true, the control throws the following error rather than calling the M30: PS0127 DUPLICATE NC, MACRO STATEMENT

I assume this is a simple syntax error and any advise I could get would be greatly appreciated. I have tried a good number of different syntax variations from different examples I have found and tried replacing the M30 with something such as a tool change (to see if it was the M30 was causing the problem) but the same error is thrown.I do have macros enabled on the control and can watch #101 increment up after each part in the Macro Offsets Page. Currently the program is still functional because the error effectively acts as an M30, stopping the program, but would still like to improve it and lean how to use IF statements properly for other applications I have in the future. Thanks
 
Hi, I have been a long time reader of the forum but this is my first post. I am currently running a Hardinge 2 axis lathe with a Fanuc Series Oi-TD Control. I am trying to set up a bar puller and have the following lines of code run at the end of my program to stop the machine when it reaches the end of the bar (I will eventually move this statement above the puller code to save on the last piece of material):

#102 = 10 (Number of parts desired)
#101 = #101+1 (increment counter)

IF[#101GT#102] THEN M30
M99
%

When the IF statement evaluates as false the program works perfectly and calls the M99 (skipping over the M30) but as soon as the part count is reached and [#101GT#102] evaluates as true, the control throws the following error rather than calling the M30: PS0127 DUPLICATE NC, MACRO STATEMENT

I assume this is a simple syntax error and any advise I could get would be greatly appreciated. I have tried a good number of different syntax variations from different examples I have found and tried replacing the M30 with something such as a tool change (to see if it was the M30 was causing the problem) but the same error is thrown.I do have macros enabled on the control and can watch #101 increment up after each part in the Macro Offsets Page. Currently the program is still functional because the error effectively acts as an M30, stopping the program, but would still like to improve it and lean how to use IF statements properly for other applications I have in the future. Thanks

Hello Ledyard,
An NC statement can't be a component of a Macro Conditional Statement. The following Conditional Statement will give you the result you seek:


IF[#101GT#102]GOTO900
M99
N900
M30
%

Regards,

Bill
 
Thank you for the help! That makes a lot of sense with the error that is called. Ill give it a try and see if it works
 
Just in case somebody does not know ...

An NC statement is a program block involving at least one NC address, such as G,
M, F, S, T, X, Y, and Z, except codes for calling a macro program (such
as G65, G66, etc.) On the other hand, a macro statement simply assigns
a value to a variable (#i = <some value or an arithmetic expression>),
or jumps to a specified block number (GOTO_ and IF_GOTO_), or
uses a conditional statement (IF_THEN_, WHILE_DO_, and END_),
or calls a macro program.
 








 
Back
Top