What's new
What's new

Help with a simple?? MACRO

usernameinvalid

Plastic
Joined
Feb 15, 2021
I'm not that well versed in macros, but by popular demand, I'm finding myself using them more and more lately.

I recently had someone ask me if I could write a macro that would prevent his fanuc 0i-MF controlled router from going to a negative Z value.

How would one accomplish this?
Bonus: Can the post be edited to include this Z-negative check?

Here's my rough idea so far:

-------------------------------------------
O1234

IF [#5003 LE 0] GOTO 100


(program body)


M99
N100 #3000 = 1 (NEGATIVE Z VALUE DETECTED)

-------------------------------------------
**I believe #5003 is the variable for programmed Z, but I will have to double check that**



Is it as simple as that? Criticism welcome!
 
Instead of bothering about whether the tool is at a negative Z, why don't you simply position the tool at the desired Z in the beginning of the program?

Current Z is #5043
 
sinha,

That would be a sensible way to do things, for sure. I think the issue is that he likes to program all his tool lengths off the router table and always use Z positive values. He runs mostly student-generated programs and has had some issues with big negative Z values in the middle of a program before.

I think there may be better ways of preventing this, but I think he wants the piece of mind of a fail-safe, in addition to other measures.

Thanks for the correct variable! I'm having trouble finding a specific manual for that controller(it's controlling a Laguna router).
 
sinha,

That would be a sensible way to do things, for sure. I think the issue is that he likes to program all his tool lengths off the router table and always use Z positive values. He runs mostly student-generated programs and has had some issues with big negative Z values in the middle of a program before.

I think there may be better ways of preventing this, but I think he wants the piece of mind of a fail-safe, in addition to other measures.

Thanks for the correct variable! I'm having trouble finding a specific manual for that controller(it's controlling a Laguna router).

Hello usernameinvalid,
You have the correct System Variable in #5003 for your purpose. I don't think sinha and you are on the same page with regards to what you want to achieve, because #5043 is only relevant after the move, which will be too late if the Z move happened to be a negative value.

The problem with your approach using #5003 (the current programed Z move), is that the following Conditional Statement

IF [#5003 LE 0] GOTO 100

would have to be included after every Z move. The above Conditional Statement would catch the move fairly quickly, but it wouldn't be instantaneous.

Not a method that would be used in mainstream CNC machine programing and operation, but where student generated programs are concerned, a more sure method of preventing a Z minus value being programmed would be to force all Z command values to Absolute with the following:

G00 Z [ABS[_ _]]

Where:
_ _ = Z Coordinate

The following example:

G00 Z [ABS[-20.0]]

Would Rapid to Z20.0

Regards,

Bill
 
Hello usernameinvalid,
You have the correct System Variable in #5003 for your purpose. I don't think sinha and you are on the same page with regards to what you want to achieve, because #5043 is only relevant after the move, which will be too late if the Z move happened to be a negative value.

The problem with your approach using #5003 (the current programed Z move), is that the following Conditional Statement

IF [#5003 LE 0] GOTO 100

would have to be included after every Z move. The above Conditional Statement would catch the move fairly quickly, but it wouldn't be instantaneous.

Not a method that would be used in mainstream CNC machine programing and operation, but where student generated programs are concerned, a more sure method of preventing a Z minus value being programmed would be to force all Z command values to Absolute with the following:

G00 Z [ABS[_ _]]

Where:
_ _ = Z Coordinate

The following example:

G00 Z [ABS[-20.0]]

Would Rapid to Z20.0

Regards,

Bill

Bill,

You are right.
#5043 will have the current position after the end of the block.
However, #5003 also may have a problem. The manual says that it does not include tool compensation value.

One way can be to set a software limit at Z0.
 
Bill,

You are right.
#5043 will have the current position after the end of the block.
However, #5003 also may have a problem. The manual says that it does not include tool compensation value.

One way can be to set a software limit at Z0.

Hello sinha,
It doesn't matter, because it simply registers the value specified in the Z command. For example:

G00 Z10.0
#1 = #5003

In the above example #1 would have the value of 10.0.

In the following example:

G00 Z-10.0
IF [#5003 LT 0] GOTO100
--------
--------
--------
Program Code
--------
--------
--------
N100 #3000 = 1 (NEGATIVE Z VALUE DETECTED)

The conditional statement would test true, but there would be some initial movement, small as it may be, during the execution period of the conditional statement, the branch to the N100 and its execution.

Regards,

Bill
 
Consider soft travel limits

I'm not that well versed in macros, but by popular demand, I'm finding myself using them more and more lately.

I recently had someone ask me if I could write a macro that would prevent his fanuc 0i-MF controlled router from going to a negative Z value.

How would one accomplish this?
Bonus: Can the post be edited to include this Z-negative check?

Here's my rough idea so far:

-------------------------------------------
O1234

IF [#5003 LE 0] GOTO 100


(program body)


M99
N100 #3000 = 1 (NEGATIVE Z VALUE DETECTED)

-------------------------------------------
**I believe #5003 is the variable for programmed Z, but I will have to double check that**



Is it as simple as that? Criticism welcome!


To solve the problem with macro programming G0 and G1 need to be redefined (use two of the 9010 to 9019 programs and match codes with parameters 6050 to 6059). When a G0 is encountered and one of the parameters 6050-6059 is 0 the corresponding 9010-9019 program is run, you need to do the check for range then move with a G0 to intended position. Work offset and tool length offset are not checked and they can cause trouble.


Have a look at parameters 1320-1321 soft travel limits, it may do what you want with less hustle.
 
To solve the problem with macro programming G0 and G1 need to be redefined (use two of the 9010 to 9019 programs and match codes with parameters 6050 to 6059). When a G0 is encountered and one of the parameters 6050-6059 is 0 the corresponding 9010-9019 program is run, you need to do the check for range then move with a G0 to intended position. Work offset and tool length offset are not checked and they can cause trouble.


Have a look at parameters 1320-1321 soft travel limits, it may do what you want with less hustle.

In my opinion also, software limit is the best thing to prevent accidents.
Programming mistakes are always possible, even by a seasoned programmer.
 
Bill,

Because of the comment in the manual about the tool compensation not included in #5003, I am not very sure about it:

G00 Z10.0
#1 = #5003

In the above example #1 would have the value of 10.0.

Can you please experimentally verify this.
 
Bill,

Because of the comment in the manual about the tool compensation not included in #5003, I am not very sure about it:

G00 Z10.0
#1 = #5003

In the above example #1 would have the value of 10.0.

Can you please experimentally verify this.

Hello sinha,
I know this to be the case, as I've used this function many times when all I'm interested in is the Absolute coordinate of an axis at the end of the current move without having to use a Buffer inhibiting command. For example capturing the Z coordinate for use as the Initial Level in a Custom Drilling Cycle.

Regards,

Bill
 
Does your router not have a setting for this on the control? Both of the routers I used to run (from two different manufacturers) had two places to zet Z. One for your program offset, which was the table, and a second maximum Z value to prevent the tools from going too deep.
 
Bill,

Because of the comment in the manual about the tool compensation not included in #5003, I am not very sure about it:

G00 Z10.0
#1 = #5003

In the above example #1 would have the value of 10.0.

Can you please experimentally verify this.

Hello Sinha,
The following pictures show the different result using #5003 ans #5043.

System Variable 5003.JPG
1. Test Program using #5003


Variable 100 for System Variable 5003.JPG
2. Variable #100 with the value of #5003 registered

System Variable 5043.jpg
3. Test Program using #5043

Variable 100 for System Variable 5043.JPG
4. Variable #100 with the value of #5043 registered


Regards,

Bill
 

Attachments

  • System Variable 5003.JPG
    System Variable 5003.JPG
    90 KB · Views: 35
Hello Sinha,
The following pictures show the different result using #5003 ans #5043.

View attachment 314063
1. Test Program using #5003


View attachment 314059
2. Variable #100 with the value of #5003 registered

View attachment 314064
3. Test Program using #5043

View attachment 314061
4. Variable #100 with the value of #5043 registered


Regards,

Bill

Bill,

I wonder what is meant by the tool compensation value being included or not included.
#5043 includes it whereas #5003 does not include it, as per manual.
 
I think the best option in this particular case, would be to change the stroke limit parameter 1321 for the Z axis (along with proofreading programs for negative Z values, and possibly looking for that "minimum Z router setting" as suggested).

Now, I'm just trying to wrap my head around how the soft limit would work with tool height offsets.

Trying to think of the different potential scenarios...

Would this soft limit account for tool height offset? Work offset(G54, G55, etc)? Both?
If the correct tool height offset is referenced and the Z axis is manually jogged, would the tool tip still stop at the soft limit?

If I had access to the fanuc router in question, I would experiment myself and see. But unfortunately, I do not.
 
I'm not that well versed in macros, but by popular demand, I'm finding myself using them more and more lately.

I recently had someone ask me if I could write a macro that would prevent his fanuc 0i-MF controlled router from going to a negative Z value.

How would one accomplish this?
Bonus: Can the post be edited to include this Z-negative check?

Here's my rough idea so far:

-------------------------------------------
O1234

IF [#5003 LE 0] GOTO 100


(program body)


M99
N100 #3000 = 1 (NEGATIVE Z VALUE DETECTED)

-------------------------------------------
**I believe #5003 is the variable for programmed Z, but I will have to double check that**



Is it as simple as that? Criticism welcome!
Hello Sinha please explain #5003 what is purpose of uses
 
It is block end point (Z coordinate).
Can be used to check if the programmed Z is alright. Post#1 has an example.
Better to use a software limit in such cases. That is foolproof.
 
Question Bill and sinha. Are the Z-axis values in different numbers for routers and lathes?

Anyone familiar with Hardinge lathes is familiar with the 9136 and, if around long enough, the 9135 Deep Drill subprograms. You position the drill before calling up the subprogram.

N500M91 (DRILL)
T505S1260M13
X0Z.5
G65P9136K-1.38W.6B.02F.006C.2A.5

One of the first blocks is:

#28=#5002 (STORE Z-POSITION IN #28)

sinha, in your book (page 211) you give this example:

#102 = #5042 (current Z-position stored)

I'm confused since #5002 is the only number I know. Been using the 9136 Deep Drill for about 35 years in controls from the 0T to the 31i. Never had a problem with the Z-axis not rapiding back to the original programmed starting position.

EDIT: I've always assumed #5001 was theX-axis and #5003 was probably the Y-axis.
 
In #5001-#5004,
1 is for 1st axis (always X axis on all machines)
2 is for 2nd axis
3 is for 3rd axis and
4 is for 4th axis
On a 2-axis lathe, 2 is for Z axis
On a Y axis lathe, 3 is for Y axis
I have no experience with a router, but I think, 2 will be for Y axis and 3 for Z axis.

In my example, both #5002 (end point position of the previous block) and #5042 (current position) should work.
The current position #5042 appeared more instructive to me.
 
Last edited:








 
Back
Top