CNC M-codes

T

Thread Starter

T. Hahn

Gentlemen,

I have been assigned the wonderful task of interfacing a CNC unit and Haas indexer to a PLC controlled process. While I have managed to grasp the G-code programming, I guess I'm just missing something in the input/output M-code defintion in the CNC program. The information I have been furnished with defines all the special M-code functions, but what I don't get is if I want the CNC to "wait" until say input 1 is on, how the heck do I define that particular input in the CNC program? Likewise, I have to trigger outputs at areas in the CNC.

I didn't receive any input from the process control portion of the site, so I thought I would try languages. PLEASE HELP!!
 
W

William Sturm

Have you tried contacting Haas? It should be a simple question for them. There are many CNC systems out there and they do vary somewhat, especially in the M codes.

Bill
 
CNC code dosent allow you to play with the hardware level devices. Its a higher level language that the PLC interprets for further processing. This is done to prevent operators from misusing the machines or their constituent input / ouput ports.

To do that you have to go and work at the PLC level using ladder logic or a similar programming format.

Nauzad
 
This is a list of all M codes for the HAAS control and what they do.

M Code Introduction
M-Codes are non axes-moving commands for the machine. The format for an
M code is the letter “M” followed by two numbers, for example M03.
Only one M code may be programmed per line of code. All M codes take effect
at the end of the block.
M Code List
M00 Stop Program M49 Set Status of Pallet
M01 Optional Program Stop M50 Execute Pallet Change
M02 Program End M51-M58 Set Optional User M Codes
M03 / M04 / M05 Spindle Commands M59 Set Output Relay
M06 Tool Change M61-M68 Clear Optional User M Codes
M07 Shower Coolant M69 Clear Output Relay
M08 Coolant On / M09 Coolant Off M75 Set G35 or G136 Reference Point
M10 Engage 4th Axis Brake M76 Control Display Inactive
M11 Release 4th Axis Brake M77 Control Display Active
M12 Engage 5th Axis Brake M78 Alarm if Skip Signal Found
M13 Release 5th Axis Brake M79 Alarm if Skip Signal Not Found
M16 Tool Change M80 Auto Door Open
M17 Unclamp APC Pallet and Open APC Door M81 Auto Door Close
M18 Clamp Pallet and Close Door M82 Tool Unclamp
M19 Orient Spindle M83 Auto Air Gun On
M21-M28 Optional User M Function with M-Fin M84 Auto Air Gun Off
M30 Program End and Reset M86 Tool Clamp
M31 Chip Conveyor Forward M88 Through-Spindle Coolant On
M33 Chip Conveyor Stop M89 Through-Spindle Coolant Off
M34 Coolant Increment M95 Sleep Mode
M35 Coolant Decrement M96 Jump If No Input
M36 Pallet Part Ready M97 Local Sub-Program Call
M39 Rotate Tool Turret M98 Sub-Program Call
M41 Low Gear Override M99 Sub-Program Return or Loop
M42 High Gear Override M104 Extend Probe Arm
M46 Jump if Pallet Loaded M105 Retract Probe Arm
M48 Check Validity of Current Program M109 Interactive User Input
M00 Stop Program
The M00 code is used to stop a program. It stops the axes, spindle, turns off
the coolant (including Through Spindle Coolant). The next block (block after
the M00) will be highlighted when viewed in the program editor. Pressing Cycle
Start will continue program operation from the highlighted block.
M01 Optional Program Stop
M01 works the same as M00, except the Optional Stop feature must be on.
M02 Program End
The M02 code is used to end a program. Note that the most common way of
ending a program is with an M30.
242
Original Instructions
96-8000 Rev AP
December 2012
M03 / M04 / M05 Spindle Commands
M03 turns spindle on in the forward direction
M04 turns spindle on in the reverse direction
M05 Stops the spindle
Spindle speed is controlled with an S address code, for example, S5000 will
command a spindle speed of 5000RPM.
NOTE: It is not recommended to run an M04 command with Through-
Spindle Coolant (TSC).
M06 Tool Change
The M06 code is used to change tools, for example M06 T12. This will put tool
12 into the spindle. If the spindle is running, the spindle and coolant (including
TSC) will be stopped by the M06 command.
M07 Shower Coolant
This M code activates the optional shower coolant pump. The pump is turned
off by M09, which also turns off standard coolant. The optional shower coolant
is automatically turned off before a tool change or a pallet change, and it
will automatically restart after a tool change if it was ON prior to a tool change
sequence.
M08 Coolant On / M09 Coolant Off
The M08 code will turn on the optional coolant supply and an M09 code will
turn it off. Also see M34/M35 for optional P-Cool and M88/89 for optional
Through-the-spindle coolant.
NOTE: Coolant status is checked only at the start of a program, so a low
coolant condition will not stop a running program.
M10 Engage 4th Axis Brake/ M11 Release 4th Axis Brake
These codes will apply and release the brake to the optional 4th axis. The
brake is normally engaged, so the M10 command is only required when an
M11 has been used to release the brake.
M12 Engage 5th Axis Brake / M13 Release 5th Axis Brake
These codes will apply and release the brake to the optional 5th axis. The
brake is normally engaged, so the M12 command is only required when an
M13 has been used to release the brake.
M16 Tool Change
This M code behaves the same as M06. However M06 is the preferred method
for commanding tool changes.
243
G & M Codes
Settings
Original Instructions
96-8000 Rev AP
December 2012
M17 Unclamp APC Pallet and Open APC Door/ M18 Clamp Pallet and
Close Door
This M-code is used on vertical machining centers with pallet changers. It is
used as a maintenance/test function only. Pallet changes should be commanded
with an M50 command only.
M19 Orient Spindle (P and R values are an optional feature)
M19 adjusts the spindle to a fixed position. The spindle will only orient to the
zero position without the optional M19 orient spindle feature.
The orient spindle function allows P and R address codes. For example,
M19 P270 will orient the spindle to 270 degrees. The R-value allows the
programmer to specify up to two decimal places; for example, M19 R123.45.
M21-M28 Optional User M Function with M-Fin
The M codes M21 through M28 are optional for user-defined relays. Each M
code activates one of the optional relays. The Reset button will stop any operation
that is waiting for a relay-activated accessory to finish. Also see M51-58
and M61-68.
Some or all of the M21-25 (M21-M22 on Toolroom, Office and Mini mills) on the
I/O PCB may be used for factory-installed options. Inspect the relays for existing
wires to determine which have been used. Contact your dealer for more
details.
Only one relay is activated at a time. A typical operation is to command a rotary
product. The sequence is: Run the machining portion of a CNC part program.
Stop CNC motion and command rotary motion through the relay. Wait for a finish
 
Top