Mach 3 Programming Tutorial
I have the 4th axis wired I just need to do the stepper drive settings and the Mach3 settings.For the stepper drive I can set the micro steps to:The stepper motor is a 1.8 so 200 steps per rev.The rotary table is 4 deg per turn so 90:1Armed with that info what should the drive be set to and what would be the 'Steps per' in the motor tuning of the A axis? If I chose say 1000 on the stepper would the setting be (1000.200).90 = 180,000,000?????
Or am I totaly off?Once that is set then there is, Velocity?, Acceleration?, G's? And Dir Pulse?Are there any other setting in Mach3 I need to configure? The rotary axis is set to degrees and a 90 to 1 gear ratio will make a very accurate setup.The 4th axis in Mach3 should be setup as the A axis and make it rotary.The diameter compensation does not work on all Mach3 versions. I recommend version 66 as being the least likely to cause problems.On the config tool path section there are several items that need to be checked.Rotational radius is set for each job on the settings tab to set the speed of the work.There may be some others but I can't think of them right now.Ray. The rotary axis is set to degrees and a 90 to 1 gear ratio will make a very accurate setup.The 4th axis in Mach3 should be setup as the A axis and make it rotary.The diameter compensation does not work on all Mach3 versions. I recommend version 66 as being the least likely to cause problems.On the config tool path section there are several items that need to be checked.Rotational radius is set for each job on the settings tab to set the speed of the work.There may be some others but I can't think of them right now.Ray.
Well I am a little more awake this morning so for the version number I like 062 the best but 066 does work.On the Settings tab 'Rotational Radius' compensates the speed of the 4th axis for the size or diameter of the part when substituting A for X or Y in the cam program. Tool path page orientates the part with which axis the rotary aligns with. It is used for the tool path display.
All 4 axis are still active and if you have a cam program that can write true 4 axis programs all are working.' Axis Calibration' will get you close to correct steps just enter 360 and check if the rotary made one full rotation and adjust from there.Step and direction should be setup as your other axis are if you are using the same or similar controller but you may have to make adjustments for the direction of rotation.It has been several years since I setup my 4th axis and I need to check the machine for more accurate information.Ray.
It depends what diameter part you will be turning as the forces exerted at 1' are many times less that those at 6' of diameter. What material you are cutting also comes into play and the holding ability of the motor when the part is not turning but other cuts are in progress is very important. Most steppers use a reduced voltage when standing still to reduce the heat generated internally so the holding power goes down also.Don't forget the backlash issue as the diameter increases the amount of movement increases exponentially with the diameter. A 1' diameter part that has 1 degree backlash can move about 0.009 but that same backlash at 6' in diameter is 0.052. Not acceptable.It all depends on what you are doing and how accurately you want it to be.Ray.
Macro programming is a useful tool for most any CNC machine shop, whether a one man garage or an international conglomerate. Macro programming provides a means of shortening code and doing repetitive tasks easily and quickly. All of your canned cycles in a control are nothing but a macro.
Macro is also extremely useful for families of parts.All computer programming is on a fundamental level, very similar. The syntax of the commands, and purpose of the programming may change, but the fundamentals of how to approach it, how logic works, and program flow are pretty much the same.The first step to any programming is to define the functionality required of the program.
Functionality is defined as the end result(s) and abilities expected of the computer code. In other words, what is it supposed to do.When we write a macro, we have a desired result in mind.
Write down the broad-based result you are looking for from the program. A broad-based result would be something like: Bolt circle drilling, rectangular pocketing, block facing, slotting, etc.For an example, lets use bolt circle drilling.After we have defined the broad-based functionality, we need to narrow down the specifics of what we desire from the program.
We must set limits to the functionality we want to achieve. If no limits are set, then the program becomes too large, cumbersome and time consuming.In our example, one of the main limits we need to set is the maximum number of holes we will be allowed to drill in the macro. For the sake of brevity, lets limit ourselves to 10 holes (We have another question coming up that, in reality, allows unlimited holes using only 10 as a maximum here)So: Max Holes in pattern 10.Next up on the functionality list regarding hole drilling: Do we have a drilling cycle in the machine control or not?
Most of the time, this is going to be a yes, so we will go with that.So: Have drilling cycle in control YesNext up on the functionality list: Do we want the ability to start the hole pattern at some angle other than directly along one of the major machine axis (X,Y,Z), this is seen often in parts, so yes, we want this functionality.So: Ability to start holes at operator input angle YesNext: Do we want the macro to call the tool, or will you already have the tool in the spindle when you call the macro? Lets do macro does not call tool. This is really a programmers preference as to which way to go, but since the possibility exists that we could do multiple bolt patterns with the same tool, we wouldn't want to go to tool change position each time between patterns.So: Macro calls tool NoNext: Do we want to induce multiples of our max holes? This would allow you to drill more than our stated maximum number of holes.
I think we can implement this in a short manner, so we will do this.So: Macro allows multiples YesWhat other functionality should we define?.hrm.for now I can't think of anything, so onward we go with the functionality described above. Ok,Now that we have defined functionality, we need to set some standards with regards to the macro programming. The first thing to consider is the variable table. You have four (4) types of variables:Local Variables: These variables are local to the program. Normally used to transfer values to a cycle call, or as intermediate mathematical value holders. I hate using local variables because of one major issue with them.
They are reset to null (not 0) when the control is reset or the program ends. While perfectly fine for use in transferring variables to canned cycles, etc. They can get you in trouble if you use them for other things.
I, just by policy, never use them for anything. In Fanucese, these are typically #100-#499 (if you have that many available). Local variables are only available to the program in which they are used.Global Variables: These variables, once set, remain set unless you change or reset them via macro or the control keyboard. Unlike local variables, global variables are available to any program in the control. I use gobal variables because they are retained, can be used in any program, and you can track what's going on if you have an issue. In Fanucese, these are typically #500-#999System Variables: These variables are available to use in macro programming and allow you to write and retrieve information from the control itself, such as tool in the spindle, tool offset active, write and read offsets, check active codes, etc.
Very handy indeed, BUT, these are NOT standardized to a great extent. You will have to consult the macro programming portion of your control manuals to determine what these are.String Variables: String variables are a group of characters interpreted as a single value. Typically defined with a $ symbol. String variables allow you to manipulate text and phrases etc.
Not all controls support string functions.I typically define my variable fields along the following lines:#500-599: Input variables to the macro#600-799: Mathmatical functions of the macro#800-899: Variables needed with regard to tooling, offsets and system variables.#900-999: Logic keep bits, counters, etc. After we have defined our functionality and standardized our variable table usage, we now need to define the inputs to our program that are needed to generate the functionality results we desire. My method is to put the inputs in a separate subprogram from the actual working program. This helps to prevent editing errors from curiosity and just oops in the main macro.The inputs we need to do our drilling are the following:#500 = Number of holes to be drilled#501 = Bolt circle diameter#502 = Angle of first hole along the X axis at machine coordinate 0° angle. Typically this is the X+ direction.#503 = X axis absolute position for bolt circle center#504 = Y axis absolute position for bolt circle center#505 = Hole Depth#507 = Pecking Depth#507 = R plane clearance#508 = Feedrate for drilling#509 = Clearance height (above part Z0) for rapid movements between holes#510 = Spindle speed for drilling#511 = W function of the G82 drill cycle#512 = E function of the G82 drill cycle#513 = V function of the G82 drill cycle#514 = L function of the G82 drill cycleThat's all I can think of right now that we would need to achieve our stated functionality. If anyone sees something missing, let me know, as I'm writing this and thinking it through as I go. Btw, I'm writing this based on the Brother B00 implementation of fanucese.
Php Programming Tutorial
More to come later. Nice Job Tony!Couple o' things.I worked with a machine tool builder once, that had a bolt circle drilling canned cycle. Either a degree spacing, or a # of holes equally spaced could be programmed. Also, there was a 'word' somewhere to skip one or more of specific holes in the array.I like to use pass-through variables. The ones between 1 and 26, inclusive. #500+ can be set from within a program if you don't want to have them be as volatile as you have described.Yes, I've worked with a few controls that had a bolt circle cycle.
Handy they are. I'm just using this as an example of how to lay out a program, and some of the basic functionality available with macro programming.
Good call 3t3d it is floating point math. I spent about 4 days pounding my head against the wall. Trying to figure out why when I had IF#23GE#17 GOTO1 and I would look at the variables and the were both be.400 but would not jump to 1. I had to end up using the rounding function to fix it. IFROUND#23.0GEROUND#17.0GOTO1Tonytn36 Nice work.I just wanted to throw my 2 cents in. I know that it is the programmer’s decision if the tool call is in the macro. I use this in the macro to keep less data out of the main program with the macro call.
I don’t believe that you should limit yourself to 10 holes for the fact that what happens when you have to do 11 holes? Now the macro has to be changed. I like to look at it as the fact the only thing that can cause the macro to not machine what you want is the few variables that you set in the macro call. There should also be specified a bolt circle diameter. I also like to use the Local variable assignments #1-#33 because if a macro call is written and a variable is forgotten then the old variable from the previous program. I know code can be written to check this but that gets into longer macros and more calculations. My macro calls cosist of 6-8 variables on average.Stevo.
Nice catch on the EQ 3t3d. I should mention that most controllers with macro ability also support RND, FIX and INT functions.On the hole limit of 10.
I chose 10 because from the values 0 - 10, you can achieve all other values needed for number of holes and it can limit the number of calculations you need to do in the macro, by adding just a few.As mentioned, and of note many things when macro programming are 'programmer preference', including whether to use local variables or not. I just prefer to not use them and that decision is based on the fact that one man was killed because of ill-advised local variable use (3t3d and SwissPro should remember this incident from a.m.c).
The biggest key is to be consistent with how you program.You should always have variable range checks in your macro. This is akin to shutting the door on the mill before you plow into a piece of aluminum at 10K and 200 IPM. It's a safety issue, both for the machine and the operator.
Yup, it takes a few minutes to write, and eats up a little memory, but if it saves your machine just once.it's paid for all of that time and effort. Tony I agree with you 100%. Most of my programs that actually run and loop the part are 10 lines of code but I have 30 lines of calculations that check and alarm in case someone fat fingered a number ect.
I was more referring to it is hard to catch a clearance plane for example as you were describing for #509. If you use for example #1 for your clearance at the beginning of the macro you can have IF#1EQ#0GOTO1000(alarm). Which means if you forgot to set #1 all together it will be equal to null and the calculation will catch that it was never set.
However if you run 1 macro setting #509=3 then run another macro when you need a clearance of #509=5 and you forget to include #509 in your program all together it is going to use 3. It’s just a bit harder to catch that in a calculation without making the macro part specific.As you said it is programmer preference. However I do like to have my clearance planes in the #500 that way there is always something for clearance as long as you’re using #500 in all of your macros.The way I like to put in safe calculations is take each variable that is being set and 1 at a time run it through every scenario that an operator can change it to and what the outcome would be. Then combine 1 and 2 for outcomes ect.There is no limit to macros except imagination. Great work on breaking down the systematic process for developing a macro. I look forward to seeing your code.
Just when you think you know all the tricks someone shows you something you didn’t think was possible.Stevo. There are quite a few mathematical functions available to us for macro programming. Some controls offer more extensive operation sets, but I'll stick with the Fanucese standard set for now.NOTE 1:All Fanucese and fanucese compatible variables begin with a pound ( #) sign ( #500). Siemens variables are preceded by an R ( R500). We have four distinct possibilities that could occur with our bolt circle example.#1. There is an even number of holes, one of which starts on a Major axis.#2.
There is an odd number of holes, one of which starts on a Major axis#3. There is an even number of holes that do not start on a Major axis.#4. There is an odd number of holes that do not start on a Major axis.Now, we could write one macro that would ignore the differences of the four possibilities listed above and programmers preference abodes here. QUOTE: 'Bluechip, are you saying that the converter changes the Fanuc macro into a common variable program for the Okuma? CNC XChange will auto-convert all areas of the Fanuc Macro B language including Common Variables, System Variables, Arithematic Operations, Control Commands ( While / Do loops, If, etc., Conditional Expressions ( EQ, LT, etc. Into the compatible Okuma User Task commands / variables.
And REVERSE.CNC XChange also has an unlimited user defined area where users can set-up their own 'what-to-convert-into-what' in case their control does some specific functions not covered in the hard-coding.Of course. Our standard version of CNC XChange will also convert standard Fanuc G code to Okuma OSP code. And REVERSE.Again.
Info and video presentations at.