What's new
What's new

Macro Programming Fundamentals

The main thing that I was referring to was the dismantling a number 1 at a time from left or right. I was thinking decreasing by 1 each iteration instead of a factor of 10. I'm thinking I just misunderstood Bill's intent.
For an engraving Macro for numbers, each digit of a number greater than 9, or less than -9, needs to be dismantled in sequence from Left or Right to gain each single number to be engraved. The number of digits needs to be known to do this and can be either by hard coding the number of digits in a fixed length number, or, when the length is going to vary, there needs to be some method of obtaining the number of digits in the whole number. Using Sinha's method or as I've shown are two ways of achieving this.

Regards,

Bill
 
For an engraving Macro for numbers, each digit of a number greater than 9, or less than -9, needs to be dismantled in sequence from Left or Right to gain each single number to be engraved. The number of digits needs to be known to do this and can be either by hard coding the number of digits in a fixed length number, or, when the length is going to vary, there needs to be some method of obtaining the number of digits in the whole number. Using Sinha's method or as I've shown are two ways of achieving this.

Regards,

Bill
Thank you both.
 
What's a good way to go about making a custom macro for profiling "straight" fillets with an endmill, taking into account the radius of the corners of the inserts to make an accurate radius? Say you'd want to mill R20 with a 8mm endmill with corner R0.5mm for example.

I thought about defining the R to make with the radius, starting points, and also the starting angle and total angle of the radius. Then defining the depth of cut with angle step for the next cut.

Then for the radius compensation I suppose you'd take the current angle of the radius you are making, and then calculate the point of tangency for that angle on the inserts radius, and then offsetting the endmill by that amount.

Is there a better way or does my idea seem good enough?
 
What's a good way to go about making a custom macro for profiling "straight" fillets with an endmill, taking into account the radius of the corners of the inserts to make an accurate radius? Say you'd want to mill R20 with a 8mm endmill with corner R0.5mm for example.

I thought about defining the R to make with the radius, starting points, and also the starting angle and total angle of the radius. Then defining the depth of cut with angle step for the next cut.

Then for the radius compensation I suppose you'd take the current angle of the radius you are making, and then calculate the point of tangency for that angle on the inserts radius, and then offsetting the endmill by that amount.

Is there a better way or does my idea seem good enough?
Are you taling about on a mill or lathe? At you mentioned endmill but also insert radius. Just trying to make sure I get what you are thinking.
 
Are you taling about on a mill or lathe? At you mentioned endmill but also insert radius. Just trying to make sure I get what you are thinking.
Mill.
I meant in the case of an indexable milling tool, indexable end mill. Or corner radius of a carbide end mill..

If you use button inserts for example the error would be quite large if you don't compensate for the radius.
 
Mill.
I meant in the case of an indexable milling tool, indexable end mill. Or corner radius of a carbide end mill..

If you use button inserts for example the error would be quite large if you don't compensate for the radius.
Yes. If I understand you correctly that should work. Give it a shot and if you don't get he desired results drop back in and let us know what it is doing or not doing.
 
Yes. If I understand you correctly that should work. Give it a shot and if you don't get he desired results drop back in and let us know what it is doing or not doing.
Sure, thanks. I'll try it out and post it here and see what you guys think. If I can do it, but I think so.
 
How difficult would it be to make a macro for milling a hemisphere with an archimedian spiral so to speak? I think that would be called a Seiffert's spiral. So a helical interpolation operation with varying radius, that also follows the curvature of a sphere?
 
How difficult would it be to make a macro for milling a hemisphere with an archimedian spiral so to speak? I think that would be called a Seiffert's spiral. So a helical interpolation operation with varying radius, that also follows the curvature of a sphere?
It can be a good project, but may not be worth the time, in view of availability of CAM softwares. Of course, a CAM software might be using only circular moves at different Z's, not the way you describe.

Any curve, that can be mathematically defined, can be generated by macro programming. I have given an example of helical interpolation with varying radius in my Macro B book. However, that is like conical interpolation. If you modify the formulae used, it will do what you want.
 
It can be a good project, but may not be worth the time, in view of availability of CAM softwares. Of course, a CAM software might be using only circular moves at different Z's, not the way you describe.

Any curve, that can be mathematically defined, can be generated by macro programming. I have given an example of helical interpolation with varying radius in my Macro B book. However, that is like conical interpolation. If you modify the formulae used, it will do what you want.
Of course! I view it more as an exercise in math and programming rather than something economical. It still has that effect though as you become more competent overall, I think. And yes, I thought your example there would be a good starting point.
Well, when time allows...
 
A canned cycle could have been provided for such requirements.
Actually, Fanuc leaves a lot of scope for CAM softwares. They have not provided canned cycles even for a simple but common application of circular/rectangular pockets, which is pretty simple. In fact, I have seen in-built G-codes for pocketing, in an emulated Fanuc control on a Denford machine.
 
I was writing a macro for my Fanuc 10M machine to use a haimer. I wanted to get the haimer length from #11099 (tool length offset 99) but it says "PS114 VARIABLE NO. OUT OF RANGE". Do I have to fiddle something with the parameters again or is it a feature? I almost bricked my machine already by tweaking around the option parameters so I would prefer not to do it too much.
 
I was writing a macro for my Fanuc 10M machine to use a haimer. I wanted to get the haimer length from #11099 (tool length offset 99) but it says "PS114 VARIABLE NO. OUT OF RANGE". Do I have to fiddle something with the parameters again or is it a feature? I almost bricked my machine already by tweaking around the option parameters so I would prefer not to do it too much.
IIRC, on that control you read #2099 or #2299 to get the value of tool offset 99 depending on how your offset table is spec'd
 
It worked. Here's what I did, a XY center and optional Z work offset setting macro with the features I thought to be useful for my use. The messages pretty much will tell what is about to happen next and there's a second take for Y if not using block delete. That's for round features where the first one is eyeballed to center so it could potentially be off. If accidentally pressing the start button twice in the same position, it will start over. There are some automatic moves (that the message box will also tell before executing) so need to be careful.
It is not entirely foolproof, for example if moving the wrong axis during centering but I thought it's foolproof enough for me...
Code:
%
O9040
N1
#3006=1 (HAIMER CENTERING  BY J. KAJULA)
G53 M5 G94
IF [#19EQ#0 ]THEN#19=1
IF [#19GT6 ]THEN#3000=1 (OUT OF RANGE)
IF [#19LT1 ]THEN#3000=1 (OUT OF RANGE)
#3006=1 (JOG TO 1ST POS IN Y-AXIS)
#1=#5022
#3006=1 (Y POS 1 STORED. JOG TO Y POS 2)
#2=#5022
IF [#2EQ#1 ]GOTO99
#3= [#1+#2]/2
#3006=1 (WARNING. MOVES 30MM UP AND CENT. Y)
G1 F5000 G91 Z30.0
G1 G90 G53 Y#3
#3006=1 (JOG TO X POS 1)
#4=#5021
#3006=1 (JOG TO X POS 2)
#5=#5021
IF [#4EQ#5 ]GOTO99
#6= [#4+#5]/2
#3006=1 (WARNING. MOVES 30MM UP AND CENT. X)
G1 G91 Z30.0
G1 G90 G53 X#6
/#3006=1(JOG IN Y POS 1 FOR REMEAS. Y)
/#1=#5022
/#3006=1(Y POS 1 STORED. JOG TO Y POS 2)
/#2=#5022
IF [#2EQ#1 ]GOTO99
/#3=[#1+#2]/2

(STORING THE POS IN G54-G59 OFFSETS AS SELECTED BY ARGUMENT S1-6, DEFAULT G54)
# [5201+20*#19]=#6 (STORE X)
# [5202+20*#19]=#3 (STORE Y)
IF [#26NE#0 ]GOTO100
GOTO101

N100

#3006=1 (JOG INTO Z0 POS)
# [5203+20*#19]=#5023-#2099 (TAKES HAIMER LENGTH FROM TOOL OFFSET 99!!!!)
N101
#3006=1 (READY)
M99
N99#3006=1 (FAIL. START OVER)
GOTO1
%
 








 
Back
Top