New - CNC Machine Classifieds

Best CNC Resources:

 »  Home  »  CNC Code  »  CNC M Codes  »  Understanding how M codes work

Understanding how M codes work



The inefficient use of M codes in a program can result in wasted program execution time. It is important that the programmer know just exactly what will happen whenever a miscellaneous function is given.

Confirmation Signals

Once executed, most M codes require that a confirmation signal be received by the control before the program can continue. For example, M03 turns the spindle on in a forward direction. When an M03 is commanded, the control sends an activation signal to the spindle drive motor. However, most controls will then wait for a confirmation that the spindle has reached its programmed speed before allowing the program to continue. When up to speed, the spindle will return the signal, telling the control that it is all right to continue with the program.

In most cases, the confirmation signal is used for safety reasons. In the case of the M03, if the spindle is not up to speed when the control continues with the program, cutting could occur at the wrong spindle speed. For M03, you may not agree that the operator's safety is threatened. However, with other M codes, the confirmation signal is much more important.

Say, for example, your machining center has an indexer that is activated by an M13. When the M13 is given, the control better wait for the index to be completed before allowing the program to continue!

There are two implications of confirmation signals that a CNC programmer must understand. The first has to do with efficiency. When feasible, cycle time can be reduced by including M codes in with motion commands. For example, a machining center program that includes all M03s with motions in X and Y will execute faster than a program which starts the spindle first, then moves in X and Y. In almost all cases, the programmer can reduce cycle time in this manner.

The second programming implication of confirmation signals is a warning. Some machine tool builders do not use them for all M codes. For the M03 example given above, we have seen some machine tool builders who do not force the control to wait until the spindle reaches its programmed speed before allowing motion. This can sometimes be dangerous. (In this case a G04 dwell command may be required to cause the machine to pause long enough for the miscellaneous function to be completed.) A good programmer should know which of each machine's M codes require confirmation signals in order to avoid potentially hazardous situations. M codes to suspect in this regard include those used for indexers, those used to open and close jaws on a turning center, and those used to activate the tailstock on a turning center.

Some machine tool builders allow the programmer to specify (usually with two other M codes) whether the control will wait for the confirmation signal before continuing. Though the initialized state will probably be to wait for the confirmation signal, this gives a great deal of flexibility to the programmer to make the M code behave exactly as desired.

Beginning Or End Of A Motion?

Some M codes will take effect as soon as the command is executed. If M03 is included together with a motion command, for example, most machines will begin to start the spindle as soon as the motion begins. However, other M codes may not begin executing until the end of the motion. For many machines, M05 (for spindle off) is an example of this kind of M code. If M05 is included together with a movement, the spindle will stay running until the completion of the motion command.

Machine tool builders vary dramatically with regard to how they make their M codes behave in this regard. It may take some testing to find out what happens with each M code. As with the confirmation signal, some machine tool builders allow the programmer to specify (usually with two other M codes) whether M codes will take effect at the beginning or end of the command, giving the programmer a great deal of control of how M codes behave.

One more point. We have seen several machine tools that do not behave very well with regard to whether an M code takes effect at the beginning or end of a command. For example, a common machining center M code to orient the spindle is M19. This command can be included with the motion to the tool change position to minimize tool changing time. This way the spindle will orient on the way to the tool change position, saving from 2 to 4 seconds per tool change. This is an example of an M code that should take effect at the beginning of the motion command. However, some machine designs force the control to wait for completion of the motion before the spindle orientation begins. If you have one of these machine tools, you won't be able to take advantage of the time savings feature of M19.

If you come across this kind of problem related to M codes, first check to see if you can change the way M codes behave in this regard (check your M codes list). If you cannot, contact your machine tool builder. It is likely that your machine's programmable controller interface can be changed to allow the M codes in question to be used in your desired manner.


http://findarticles.com/p/articles/

For more information visit CNC M Codes category

Advertisements