What's new
What's new

Help with macros

MaticB

Plastic
Joined
Jul 3, 2022
Hello,

I was hoping if anyone could help me write a few macros for a dual spindle lathe with a robot to feed the machine.
I'd like to stop the machine every xx pieces to check the inserts but i am not sure how to write the counter macro.

For example:

#131=10
IF[#130EQ#131]GOTO 10
N10 #3000=1(Check Inserts)

Any help appricated!
Thanks!
 

angelw

Diamond
Joined
Sep 10, 2010
Location
Victoria Australia
Hello,

I was hoping if anyone could help me write a few macros for a dual spindle lathe with a robot to feed the machine.
I'd like to stop the machine every xx pieces to check the inserts but i am not sure how to write the counter macro.

For example:

#131=10
IF[#130EQ#131]GOTO 10
N10 #3000=1(Check Inserts)

Any help appricated!
Thanks!
There are dedicated System Variables for the Number of Parts Machined (number completed) and Number of Required Parts (target number); #3901 and #3902 respectively. These variables can be set within your program, or via the Setting Page of the control.

At the beginning of your program, you would set the Number of Parts Required and perhaps initialize the Parts Completed, then at the appropriate point in your program, have the following code:
#3901 = #3901 + 1 (or M Code that Increments System Variable #3901)
IF[#3901 EQ #3902] GOTO 10
N10 #3000=1(Check Inserts)

There should be an "M" code, the specification of which will be set in parameters to increment System Variable #3901. Determine what this is and you will be able to delete the #3901 = #3901 + 1 and simply replace it with the "M" Code that increments System Variable #3901.

Regards,

Bill
 

MaticB

Plastic
Joined
Jul 3, 2022
Thanks for the fast reply Bill!

But with this approach you would need to go to into parameters and set the counter to zero then back into memory and nc start? Surely there is a way to alarm out, rezero the counter automatically check tooling and go?

Thanks.
 

angelw

Diamond
Joined
Sep 10, 2010
Location
Victoria Australia
Thanks for the fast reply Bill!

But with this approach you would need to go to into parameters and set the counter to zero then back into memory and nc start? Surely there is a way to alarm out, rezero the counter automatically check tooling and go?

Thanks.
Which part of the following extract from my previous Post don't you get?

These variables can be set within your program, or via the Setting Page of the control.

At the beginning of your program, you would set the Number of Parts Required and perhaps initialize the Parts Completed,
 

MaticB

Plastic
Joined
Jul 3, 2022
Right! Sorry i kinda focused on the settings page only. Silly me.

Gonna try it out this week.

Thanks!
 

angelw

Diamond
Joined
Sep 10, 2010
Location
Victoria Australia
Right! Sorry i kinda focused on the settings page only. Silly me.

Gonna try it out this week.

Thanks!
The Setting Page is a convenient page to make some setting without having to enable the PWE. The advantage of using the dedicated Parts Required and Parts Completed System Variables, is that both variables are retained when power to the control is turned off and therefore, the count of the Parts Made that relate to the check on the condition of the cutting tool is not lost and an "M" should normally be provided, or can be created, to index the Parts Completed System Variable #3901.

These System Variables are the same used by the Parts Counter Function if the control is equipped with it.

Regards,

Bill
 
Last edited:

MaticB

Plastic
Joined
Jul 3, 2022
The Setting Page is a convenient page to make some setting without having to enable the PWE. The advantage of using the dedicated Parts Required and Parts Completed System Variables, is that both variables are retained when power to the control is turned off and therefore, the count of the Parts Made that relate to the check on the condition of the cutting tool is not lost and an "M" should normally be provided, or can be created, to index the Parts Completed System Variable #3901.

These System Variables are the same used by the Parts Counter Function if the control is equipped with it.

Regards,

Bill
Many thanks Bill, i really appriciate it!

Looking to buy Peter Smid Macro Programming,any good?
 

wmpy

Hot Rolled
Joined
Dec 16, 2011
Many thanks Bill, i really appriciate it!

Looking to buy Peter Smid Macro Programming,any good?
Smid's book is good. It doesn't cover the newer controls, but the principles are the same, and most of the variables referenced in the book are still used in those newer controls.
 

mcw89

Plastic
Joined
Sep 10, 2021
Hello,

I was hoping if anyone could help me write a few macros for a dual spindle lathe with a robot to feed the machine.
I'd like to stop the machine every xx pieces to check the inserts but i am not sure how to write the counter macro.

For example:

#131=10
IF[#130EQ#131]GOTO 10
N10 #3000=1(Check Inserts)

Any help appricated!
Thanks!


#802=5 (INSERT CHECK INTERVALL)
#801=#801+1
IF[#802LE0]GOTO99
IF[#801LT#802]GOTO99
M01 (INSERT CHECK)
#801=0
N99 M99
(YOUR PROGAMM)
 

MaticB

Plastic
Joined
Jul 3, 2022
Thanks for the replies!

got it working today, albeit a little different.
O3901(PART COUNTER MACRO)
;
#3902=10(NUMBER OF PARTS);
#3901=#3901+1(INCREMENTAL COUNTER);
IF[#3901LT#3902] GOTO10;
;
N5 #3901=0;
#3000=1(CHECK INSERTS);
;
N10;
;
G4 X2(DWELL TIME);
;
M99:
EQ didn't work for the for some reason it just went straight to #3000 alarm, LT works fine though

Thanks!
 

angelw

Diamond
Joined
Sep 10, 2010
Location
Victoria Australia
Thanks for the replies!

got it working today, albeit a little different.
O3901(PART COUNTER MACRO)
;
#3902=10(NUMBER OF PARTS);
#3901=#3901+1(INCREMENTAL COUNTER);
IF[#3901LT#3902] GOTO10;
;
N5 #3901=0;
#3000=1(CHECK INSERTS);
;
N10;
;
G4 X2(DWELL TIME);
;
M99:
EQ didn't work for the for some reason it just went straight to #3000 alarm, LT works fine though

Thanks!
In the context of the arrangement of your code above, of course EQ wouldn't work. To make the branch, the Condition Statement would have to test True. When using "EQ" in the Condition Statement, it will only test true when the the two variables being compared are the same. When they are not equal, no branch to N10 will occur and the program will simply progress to N5 and then the #3000.

In my example in an earlier Post if #3901 equaled #3902, the program would branch to the Block containing #3000. What I should have shown for more clarity is the fact that the rest of you program resided between the Conditional Statement and the result of the Conditional Statement testing True as follows:

IF[#3901 EQ #3902] GOTO 10
------------
------------
Other code of your program goes here
------------
------------
M99
N10 #3000=1(Check Inserts)

Regards,

Bill
 
Last edited:

MaticB

Plastic
Joined
Jul 3, 2022
In the context of the arrangement of your code above, of course EQ wouldn't work. To make the branch, the Condition Statement would have to test True. When using "EQ" in the Condition Statement, it will only test true when the the two variables being compared are the same. When they are not equal, no branch to N10 will occur and the program will simply progress to N5 and then the #3000.

In my example in an earlier Post if #3901 equaled #3902, the program would branch to the Block containing #3000. What I should have shown for more clarity is the fact that the rest of you program resided between the Conditional Statement and the result of the Conditional Statement testing True as follows:

IF[#3901 EQ #3902] GOTO 10
------------
------------
Other code of your program goes here
------------
------------
M99
N10 #3000=1(Check Inserts)

Regards,

Bill
I understood it as when #3901(adding+1 everytime it passes the macro) reaches 10(equal as #3902) it goes to N10 .

Sorry, i am very new to Fanuc and macros.

Thanks
 

angelw

Diamond
Joined
Sep 10, 2010
Location
Victoria Australia
I understood it as when #3901(adding+1 everytime it passes the macro) reaches 10(equal as #3902) it goes to N10 .

Sorry, i am very new to Fanuc and macros.

Thanks
In your example following, the Conditional Statement IF[#3901LT#3902] GOTO10, will test True only when the number of parts completed is less than the Target Number. In his case, the program will branch past the #3000 Block. Only when
IF[#3901LT#3902] GOTO10 doesn't test True does it not branch pass the #3000 Block.

#3902=10(NUMBER OF PARTS);
#3901=#3901+1(INCREMENTAL COUNTER);
IF[#3901LT#3902] GOTO10;
;
N5 #3901=0;
#3000=1(CHECK INSERTS);
;
N10;
;
G4 X2(DWELL TIME);
;
M99:

In my example following, only when IF[#3901 EQ #3902] GOTO 10 tests True, will it branch to the N10 Block. The #3901 Variable is indexed by
either:
1. Setting in parameter so that M99 signals the index
2. Setting in parameter a Custom "M" Code to signal the index, M111 for example.
or
3. Explicitly indexing #3901 with #3901 = #3901 +1

IF[#3901 EQ #3902] GOTO 10
------------
------------
Other code of your program goes here
------------
------------
M99 (or M111 or #3901 = #3901 +1)

N10 #3901 = 0
#3000=1(Check Inserts)

Regards,

Bill
 
Last edited:








 
Top