Making M codes compatible with custom macro
Categories: CNC M CodesMany CNC users have two or more highly similar CNC machines made by different machine tool builders. Depending on work load, most need to run the same jobs on any one of the similar machines at any given time. Say, for example, you have two 20-horsepower, eight-inch chuck, turning centers. One is made by brand X and the other by brand Y. As each job comes up you would probably like to run it on whichever turning center frees up first.
One problem this kind of CNC user constantly faces is incompatibility with regard to programs. Even if the two (or more) similar machines have identical controls, there will probably still be some incompatibility regarding M codes. If both of the turning centers have two spindle ranges, one may use M23 for low range and M25 for high range. The other may use M41 and M42. To overcome these M code incompatibility problems, either the CNC user must maintain two (or more) complete sets of CNC programs (which can be cumbersome), or the operator of each machine will be constantly editing programs written for the other machine (which is tedious, error prone, and time consuming).
Turning center spindle ranges are but one example of when similar CNC machines built by different machine tool builders are not compatible with regard to M codes. While some M codes are somewhat standardized (M00, M01, M03, M04, M05, and so on), almost any M code the machine tool builder must name for their own miscellaneous functions introduces a potential incompatibility problem (tailstock, chuck jaws open/close, automatic toolchanger functions, pallet changer, and so on).
If your machines have custom macro B, you have the ability to change the function of your M codes (up to ten on current model controls) in such a way that the machines become compatible. In essence, you can set up the control so that when it reads one M code, it executes another. While this technique can be applied to any M code incompatibility, let’s stress its use for the turning center spindle range M codes.
The first step is to pick the M codes you want to use. In the spindle range example, maybe more of your machines use M41 and M42, so you wish to change the machines that currently use M23 and M25. Or maybe the machines that use M41 and M42 do not have custom macro B, meaning the only machines you can change are those that use M23 and M25 (though custom macro B can be added to many controls at any time).
For those machines you wish to change (we’ll say those using M23 and M25), look in the custom macro section of your programming manual. In the section related to creating your own M codes, you will find parameters that must be changed (two in our case). These parameters control what happens when a specified M code is executed. When set properly, whenever the specified M code is read, the control will automatically jump to a custom macro. In the custom macro, we will include the M code that performs the actual spindle range change. This is a bit confusing, so here is a full example.
One popular control uses parameter numbers 7071 through 7079 to control which M codes call custom macros. For this control, parameter number 7071 is related to program number 09001 and parameter number 7072 is related to program number 09002. On the machines that currently use M23 and M25, we will set parameter number 7071 to a value of 41 and 7072 to a value of 42. From this point on, whenever this control reads an M41, it will execute program number 09001. Whenever it reads an M42, it will execute program number 09002.
The last step is to enter the correct programs into the control. Most controls even allow your M code related custom macros to be protected so that they cannot be changed or deleted (another parameter is related to this function). Here are the two simple programs.
09001 (Program number) M23 (Execute low range command) M99 (End of custom macro) 09002 (Program number) M25 (Execute high range command) M99 (End of custom macro)
When these programs are in the control’s memory, and when the parameters are properly set (remember, they will probably be different parameter numbers for your particular control), whenever the control reads an M41, it will jump to program number 09001. In this program, the M23 will make the range change. From this point on, programs that have M41 and M42 will execute without modification in machines originally set up to accept M23 and M25.
You say your turning center has only one spindle range?
There may be times when you find the need to delete M codes in order to get programs to run. In the previous example, maybe one of the similar turning centers has only one spindle range. Yet whenever an M41 or an M42 is read, the control of this machine will stop executing due to an unrecognizable Mcode. For this type of machine, you can use similar techniques to make the control ignore the unused M codes. The parameters will be set the same as shown earlier. Only the custom macros will change.
09001 (Program number) M99 (End of program) 09002 (Program number) M99 (End of program)
Notice these are nothing more than empty programs. When the control reads an M41, it will jump to 09001, which immediately sends execution back to the previous program. Though nothing actually happens within the programs, the control will no longer get stuck on the unrecognizable M codes.
http://findarticles.com/p/articles/mi_m3101/is_n4_v68/ai_17570283/pg_1