Macro Programming Fundamentals - Page 37

1. Stainless
Join Date
Sep 2010
Location
india
Posts
1,260
Post Thanks / Like
Likes (Given)
73
229
Originally Posted by MazatrolMatrix
It's ASIN I'm talking about. I ran into a situation where I wanted to find an unknown angle and would have liked to use ASIN to do so.
I do not know about your control, but on Fanuc, it is better to use ATAN for finding angles.
ASIN does not give answer in second or third quadrant, and ACOS not in third or fourth quadrant, irrespective of parameter setting.
Of course, if the expected answer is in the first quadrant only, anything can be used.

2. IF [#1EQ#2] #3=#10

ALARM 854: ILLEGAL MACRO PROGRAMMING

IF[#1 < #3] #5=#10

ALARM 859: ODD NUMBER OF PARANTHESES/BRACKETS

so then I tried

IF[[#1 < #3] #5=#10]

Still got alarm 859.

3. Stainless
Join Date
Sep 2010
Location
india
Posts
1,260
Post Thanks / Like
Likes (Given)
73
229
I just glanced through the Mazatrol manual.
Though I may have missed something, it seems that only GOTO is available with IF.
And ASIN is not available.
LT must be used in place of <

4. Titanium
Join Date
Sep 2010
Location
Victoria Australia
Posts
3,723
Post Thanks / Like
Likes (Given)
0
1468
If ASIN really has to be used, the Mazatrol Matrix User Macro has the ATAN math operator. Accordingly, the following should work as an Inverse SIN Function:

#i=ATAN[Number / SQRT[-Number * Number + 1]]

Where:
#1 = the ASIN result
Number = the SIN value

If you want to create an Inverse COS Function, the following should also work.

#1 = ATAN[-Number / SQRT[-Number * Number + 1]] + #2 / 2

#1 = the ACOS result
#2 = Pi
Number = the COS value

Regards,

Bill
Last edited by angelw; 10-02-2019 at 10:19 AM.

5. That's what I was looking for, thank you very much.

6. Titanium
Join Date
Sep 2010
Location
Victoria Australia
Posts
3,723
Post Thanks / Like
Likes (Given)
0
1468
Originally Posted by MazatrolMatrix
That's what I was looking for, thank you very much.
Hello MazatrolMatrix,
To be entirely correct, 1 and -1 being passed as an argument have to be dealt with as shown in the Code Examples below.

Rather than having to trot this code out every time you needed it and include it in your program, I would create a Function by registering the code under a unique program number for Inverse SIN and COS as follows. When you have to use either of these functions in your program, simply execute the Macro Call Block for the appropriate function. In each of the following Inverse SIN and COS Function, Common Variable #100 is used to return the result to your program.

Both are Bare Bones examples with no Error Trapping.

Regards,

Bill

Inverse SIN Function Example
G65 P8000 A0.5 (CALL BLOCK PASSING THE SIN OF 30DEG IN THIS EXAMPLE)

O8000
(ASIN FUNCTION)
(THE SIN OF THE ANGLE IS PASSED AS ARGUMENT A)
#2 = 3.1415926535897932 (Pi)

IF [#1 NE 1] GOTO10
#100 = #2 / 2 (Pi/2)
GOTO30

N10 IF[#1 NE -1] GOTO20
#100 = -#2 / 2 (-Pi/2)
GOTO30

N20 #100 = ATAN[#1 / SQRT[-#1 * #1 + 1]]

N30 M99
%

Inverse COS Function Example
G65 P8001 A0.86603 (CALL BLOCK PASSING THE COS OF 30DEG IN THIS EXAMPLE)

O8001
(ACOS FUNCTION)
(THE COS OF THE ANGLE IS PASSED AS ARGUMENT A)

#2 = 3.1415926535897932 (Pi)

IF [#1 NE 1] GOTO10
#100 = 0
GOTO30

N10 IF[#1 NE -1] GOTO20
#100 = #2
GOTO30

N20 #100 = ATAN[-#1 / SQRT[-#1 * #1 + 1]] + #2 / 2

N30 M99
%

7. I'm not sure if this is a Haas issue specifically, or a macro issue...

Is it possible to use a variable's value for the text to be engraved while using Haas's G47 macro function**?

In other words, when using the P0 (value), or even the P1 (value), can one reference a variable?
In essence - P0(#505)

All manner of mayhem broke loose when I tried so I'm sure that I'm doing something wrong, but want to make sure that it is even possible.

Thank you.

** - G47 Text Engraving (Group 00)

* E - Plunge feed rate (units/min)
F - Engraving feedrate (units/min)
* I - Angle of rotation (-360. to +360.); default is 0
* J - Height of text in in/mm (minimum = 0.001 inch);
default is 1.0 inch
P - 0 for literal text engraving
- 1 for sequential serial number engraving
- 32-126 for ASCII characters
* R - Return plane
* X - X start of engraving
* Y - Y start of engraving
* Z - Depth of cut

*indicates optional

8. Aluminum
Join Date
Sep 2012
Location
New Zealand
Posts
60
Post Thanks / Like
Likes (Given)
1
12
I'm not sure if this is a Haas issue specifically, or a macro issue...

Is it possible to use a variable's value for the text to be engraved while using Haas's G47 macro function**?

In other words, when using the P0 (value), or even the P1 (value), can one reference a variable?
In essence - P0(#505)

All manner of mayhem broke loose when I tried so I'm sure that I'm doing something wrong, but want to make sure that it is even possible.

Thank you.

** - G47 Text Engraving (Group 00)

* E - Plunge feed rate (units/min)
F - Engraving feedrate (units/min)
* I - Angle of rotation (-360. to +360.); default is 0
* J - Height of text in in/mm (minimum = 0.001 inch);
default is 1.0 inch
P - 0 for literal text engraving
- 1 for sequential serial number engraving
- 32-126 for ASCII characters
* R - Return plane
* X - X start of engraving
* Y - Y start of engraving
* Z - Depth of cut

*indicates optional
Would the format not be P#505 with no (comment)?

Seems like you would only be able to do a single character per cycle.

DP

9. Plastic
Join Date
Oct 2019
Country
TURKEY
Posts
1
Post Thanks / Like
Likes (Given)
0
0

10. Titanium
Join Date
Oct 2007
Country
SPAIN
Posts
3,544
Post Thanks / Like
Likes (Given)
1986
1290
Originally Posted by hamitunlu
Hey - nice bit of spam Monkey Boy!
Or are you the one walking tall?

11. Plastic
Join Date
Oct 2019
Country
UNITED ARAB EMIRATES
Posts
1
Post Thanks / Like
Likes (Given)
0
0
Our working comprehensive goal is to provide benefits to our client’s business through developing. And growing the standard of their loyalty. Thus, to achieve a high level of loyalty, we do study work along with research on user personas that can reduce the risks of connection with a misunderstanding of their needs.Digitalopment

12. Titanium
Join Date
Sep 2010
Location
Victoria Australia
Posts
3,723
Post Thanks / Like
Likes (Given)
0
1468
Originally Posted by syedhuzaifa
Our working comprehensive goal is to provide benefits to our client’s business through developing. And growing the standard of their loyalty. Thus, to achieve a high level of loyalty, we do study work along with research on user personas that can reduce the risks of connection with a misunderstanding of their needs.Digitalopment
I have a fascination in how the rearrangement of letters in a word, or phrase results in a word of different tense, or meaning. For example Eat and Ate, Eat being the present simple and Ate the past simple.

With regards to the paragraph in the previous Post, by rearranging and deleting some letters, the resulting word is Spam. Amazing don't you think?

13. Aluminum
Join Date
Jan 2019
Country
SWEDEN
Posts
190
Post Thanks / Like
Likes (Given)
56
22
Originally Posted by angelw
I have a fascination in how the rearrangement of letters in a word, or phrase results in a word of different tense, or meaning. For example Eat and Ate, Eat being the present simple and Ate the past simple.

With regards to the paragraph in the previous Post, by rearranging and deleting some letters, the resulting word is Spam. Amazing don't you think?
I have to admit I can see absolutely no point to this spam message?

14. Aluminum
Join Date
Jan 2019
Country
SWEDEN
Posts
190
Post Thanks / Like
Likes (Given)
56
22
I'm gifting this to the community. Maybe you can improve on it and we can get a discussion going. It's not original or very complex but it's good and working. Error handling isn't really tested. I made this today as a rewrite of an existing working one. Taking it into production tomorrow.

This macro spirals a mill to widen a pre-drilled hole. It also compensates feed by radius. (Feed given is interpreted as peripheral feed.) Plus I added an option for high feed mills (easy one.)

It's a fun one but maybe you'll ruin your machine with it who knows.

C: Predrilled hole diameter
D: Cutter diameter
E: Target diameter
Q: Ae or Ap
V: Variant (0: Ae 1:Ap)

Code:
```:5000
(TEMPO 1 MATERIAL 2172 250X125X25)
(ISCAR GROUP P1 KENNAMETAL GROUP P3)
(ORIGO UPPER CENTER)
( T13=KENNAMETAL B051A13500CPG 13.5MM )
( T12=ISCAR EC-E5L 12-30C12CF83 12MM  )

(KENNAMETAL 13.5MM VC80 F.3)
G90G0G54G43X-105.Y-30.Z50.M7S1886H13T12
G4X10
M3
G81G99R3.Z-30.F565
X-42.5Y-20.
Y-105.
X42.
Y-20.
G98X105.Y-30.
G55
G99X-105.Y-30.
X-42.5Y-20.
Y-105.
X42.
Y-20.
G98X105.Y-30.
G0M9
G91G28Z0M6
M1

(ISCAR EC-E5L 12MM)
(RECOMMENDED VC360 F.096)
(MACHINE LIMIT VC188.4)
G90G0G54G43X-105.Y-30.Z50.S5000H12M3T9
Z5.M14F2000
G66P12C13.5D12.E27.5Q1.R0.Z-30.V1.F2000.
X-105.Y-30.
X105.Y-30.
G67
G66P12C13.5D12.E40.Q1.Z-13.R0.V0.F2000.
X-42.5Y-20.
Y-105.
X42.
Y-20.
G67
M15
G91G28Z0M6
M30

:0012(FIL=P-SPIRALOUT)
(FUNCTION 0 SPIRALS FROM R=(C-D/2) TO R=(E-D/2) Q MM PER ROTATION)
(FUNCTION 1 SPIRALS FROM Z=R TO Z=Z Q MM PER ROTATION)
(ARGUMENTS:)
(C: PREDRILLED HOLE DIAMETER)
(D: TOOL DIAMETER)
(E: TARGET DIAMETER)
(Q: WIDTH OR DEPTH OF CUT)
(V: VARIANT. 0 IS SLICING AND 1 IS HIGH FEED LOW AP.)
(SAVE CURRENT XYZ)
G9
#111=#5001
#112=#5002
#113=#5003
(SAVE MODAL INFO)
#119=#4109
(ERROR HANDLING)
IF[#07EQ#0]THEN#3000=1(MISSING [D] DIAMETER)
IF[#08EQ#0]THEN#3000=2(MISSING [E] DIAMETER)
IF[[#17EQ#0]AND[#22NE1]]THEN#3000=3(MISSING [Q] AE)
IF[[#17EQ#0]AND[#22EQ1]]THEN#3000=4(MISSING [Q] AP)
IF[[#26EQ#0]AND[#22EQ1]]THEN#3000=5(MISSING [Z])
(DEFAULTS)
IF[#09EQ#0]THEN#09=#4109(USE SYSTEM FEED IF NO FEED VARIABLE)
IF[#03EQ#0]THEN#03=#07(MACRO DEFAULTS TO PREDRILLED HOLE OF CUTTER DIAMETER)
IF[#26EQ#0]THEN#26=#113(IF NO TARGET DEPTH IS GIVEN MACRO DEFAULTS TO CURRENT Z TARGET)
()
#103=10 (MACRO RESOLUTION)
IF[#22EQ1]GOTO1
(MODE 0: AREA SLICING. Q IS AE.)
#105=0 (ANGLE COUNTER)
F#09(FEED COUNTER)
G90G0Z#18
G90G1Z#26(ENTER CUT)
G3X[#111+#101]Z#26R[#101/2]
WHILE[#106LT#102]DO1
#105=0(ANGLE COUNTER)
WHILE[#105LT360]DO2
#106=#106+#104
IF[#106GT#102]THEN#106=#102
#109=#09*[#106/[#106+[#07/2]]]
G3X[#111+[COS[#105]*#106]]Y[#112+[SIN[#105]*#106]]R#106F#109
#105=#105+#103
END2
END1
(FINISHING CUT)
G3X[#111+#102]Y#112R#102
G3I-#102
G3X#111Y#112R[#102/2]F#09
G0Z#113
F#119
M99
N1 (MODE 1: DEPTH SLICING. Q IS AP.)
#106=#18 (Z COUNTER)
G90G0Z#18
G3X[#111+#102]Y#112R[#102/2] (ENTER CUT)
WHILE[#106GT#26]DO1
#106=#106-#17
IF[#106LT#26]THEN#106=#26
G3I-#102Z#106
END1
(FINISHING CUT)
G3I-#102Z#26
G3X#111Y#112R[#102/2]
G0Z#113
M99```

15. Titanium
Join Date
Jul 2013
Location
Indiana
Posts
3,233
Post Thanks / Like
Likes (Given)
4726
1630
I've been drilling with this little drill program for a pretty long time and unless I'm starting to wig out I don't remember ever running into this till now. So the 27/64 drill did as expected, it kept counting till it reached the Z depth of 1.6 then came out of the hole went home then completely skipped the next drill, read the M30 and set there done.

The fix was to in the 11/32 drill change to GOTO300 & N300 then it run as it was supposed to. I don't understand why this happened though. Isn't the control as its counting reading up looking for N200? I don't know how it got lost when it should be reading backwards at the GOTO looking for N's.

It kinda reminds me of issues I've had with duplicate Q and P numbers in the same program when using canned cycles. Sometimes the control would get lost and be somewhere it's not supposed to be when searching for Q and P numbers if there were duplicates. In my mind if this problem was going to occur it seems it'd be on the second drill instead of first one? I know I've stacked these cycles on top of one another before and I don't ever remember running into this problem. Am I wigging out?

Below is copy and paste of the entire program as it was originally.

Brent

%
O5216(20-401 5215 2ND OP)
(20-401 5215 REV 3 5/25/2018)
(CORE PIN)
(VISCOUNT V-44)
(PART IN .920 DIA COLLET)
(COLLET IS MARKED .8895)

(G54 SET Z 5.015)

N10(MSG, 27/64" .4219 DRILL)
(COLBALT DRILL 89-403-A430)
(DRILL TURNED DOWN TO .375)
G0G99G40G54X14.Z10.T0
T0404

#1=.025(FEED SHORT OF)
#2=.070(PECK EVERY)
#3=.0(START DRILLING)
#4=1.6(STOP DRILLING)
#5=.2(RAPID BACK SHORT OF)
#6=.005(FEED RATE)

M41
G97S175M3
G0Z.3
G0X0M8
G0Z-[#3]
#3=[#3+#2]
N200
G1Z-[#3]F[#6]
G0Z.5
G0Z-[#3-#5]
G1Z-[#3-#1]F.2
#3=[#3+#2]
IF[#3LT#4]GOTO200
G1Z-[#4]F[#6]
G0Z.3
M9
G0X4.
G0G99G40G54X14.Z10.T0
M0

N20(MSG, 11/32" .3438 DRILL)
G0G99G40G54X14.Z10.T0
T0606

#1=.025(FEED SHORT OF)
#2=.070(PECK EVERY)
#3=1.3(START DRILLING)
#4=4.64(STOP DRILLING)
#5=.2(RAPID BACK SHORT OF)
#6=.0040(FEED RATE)

M41
G97S195M3
G0Z.3
G0X0M8
G0Z-[#3]
#3=[#3+#2]
N200
G1Z-[#3]F[#6]
G0Z.5
G0Z-[#3-#5]
G1Z-[#3-#1]F.2
#3=[#3+#2]
IF[#3LT#4]GOTO200
G1Z-[#4]F[#6]
G0Z.3
M9
G0X4.
G0G99G40G54X14.Z10.T0
M30
%

16. Aluminum
Join Date
Jan 2019
Country
SWEDEN
Posts
190
Post Thanks / Like
Likes (Given)
56
22
Just at a glance you have two N200? Go-to searches forward. On my phone.

17. Titanium
Join Date
Sep 2010
Location
Victoria Australia
Posts
3,723
Post Thanks / Like
Likes (Given)
0
1468
Originally Posted by yardbird
The fix was to in the 11/32 drill change to GOTO300 & N300 then it run as it was supposed to. I don't understand why this happened though. Isn't the control as its counting reading up looking for N200? I don't know how it got lost when it should be reading backwards at the GOTO looking for N's.
Hello Brent,
The control doesn't search backwards, only forwards. If the sequence number being searched for isn't encountered before the end of the program, the search will start again at the head of the program. Accordingly, if the sequence number is unique in the program and appear before the GOTO command, it seems as though the program has searched backwards, but it has not. In your example program, where there are two N200 sequence numbers, the search initiated by GOTO200 will find the N200 Block that is downstream of the GOTO200 Block first.

Regards,

Bill

18. Titanium
Join Date
Jul 2013
Location
Indiana
Posts
3,233
Post Thanks / Like
Likes (Given)
4726
1630
Originally Posted by angelw
Hello Brent,
The control doesn't search backwards, only forwards. If the sequence number being searched for isn't encountered before the end of the program, the search will start again at the head of the program. Accordingly, if the sequence number is unique in the program and appear before the GOTO command, it seems as though the program has searched backwards, but it has not. In your example program, where there are two N200 sequence numbers, the search initiated by GOTO200 will find the N200 Block that is downstream of the GOTO200 Block first.

Regards,

Bill
Hello Bill,

Well there you go. Maybe I knew this at one time, seems odd to be looking forward when the information such as the P and Q is backwards as is the case with G70 finishing G71 G72 G73 canned cycles. Apparently I'm wigging out. Thank you

Brent
Last edited by yardbird; 11-12-2019 at 12:37 AM. Reason: Changed stuff

19. Plastic
Join Date
Nov 2019
Country
TURKEY
Posts
5
Post Thanks / Like
Likes (Given)
0
0
cnc nasıl programdır ;

20. Titanium
Join Date
Sep 2010
Location
Victoria Australia
Posts
3,723
Post Thanks / Like
Likes (Given)
0
1468
Originally Posted by expectium
cnc nasıl programdır ;

Herhangi bir dilde ve diğer tüm gönderilerinizde spam, hala spam - f off

(Spam in any language and in all your other Posts, is still spam - f off)