M64 CNC Code: Beginner’s Guide to Activating Digital Outputs

Welcome to our simple guide on the M64 CNC code. Whether you are new to CNC programming or an experienced machinist, understanding the M64 code is essential.

This guide will explain everything you need to know about this unit mode command—what it is, when to use it, and why it matters.

(Step-by-step.)

Key Takeaways

  • M64 is a CNC code that sets the output state, turning on auxiliary outputs immediately with the syntax M64 P[value].
  • The P value ranges from 0 to the maximum number of digital-out pins, configurable with the num_dio parameter.
  • M64 is often used with M63 and M65 commands to control digital outputs, and is part of the Group 4: Digital and Analog Output Control category.
  • Auxiliary outputs 1-6 can be configured with toggle inputs or Gcode, while outputs 7-16 can only be controlled through Gcode.
  • M64 is used to activate a specified auxiliary output immediately, and is crucial for precise control over digital outputs in CNC machining.

M64 Command Syntax

When specifying the M64 command, you’ll need to follow a specific syntax.

The syntax is M64 P[value], where the P value specifies the auxiliary output number to be turned on immediately. This command is used to switch ON auxiliary outputs, and it’s often used with M63 and M65 commands to control the state of digital outputs.

The P value ranges from 0 to the maximum number of digital-out pins, which can be increased with a command-line parameter (num_dio) to motion (loadrt motmod). With this command, you can control external devices connected to the digital output pins.

Auxiliary Outputs Configuration

You’ll need to configure your auxiliary outputs properly to guarantee seamless control over your digital outputs. This involves assigning the correct P value to each output, which corresponds to the Auxiliary output number. For instance, M64 P1 switches on Auxiliary output 1.

Auxiliary OutputP ValueControl Method
1-6P1-P6Auxiliary toggle inputs or Gcode
7-16P7-P16Gcode only
1 (example)P1M64 P1 (ON), M63 P1 (OFF)
4 (example)P4M64 P4 (ON), M65 P4 (OFF)

Digital Output Control Overview

In the domain of CNC machining, precise control over digital outputs is crucial.

You need to guarantee that your digital outputs are accurately controlled to achieve the desired results. This is where the M64 CNC code comes in.

The M64 code allows you to control digital outputs immediately, with the syntax being M64 P[value], where the P value specifies the auxiliary output number. You can use this code in conjunction with M63 and M65 codes to regulate the state of digital outputs.

The control mode determines how the digital output is turned on or off. For instance, you can toggle outputs 1-6 using assigned toggle inputs, while outputs 7-16 can only be changed through G-code.

M64 and M65 Code Usage

By specifying the correct output number, you can achieve precise control over your digital outputs using M64 and M65 codes.

To turn on a digital output, use the M64 code with the syntax M64 PNN, where PNN is the auxiliary output number. Conversely, to turn off a digital output, use the M65 code with the same syntax.

For example, M64 P1 turns on auxiliary output 1, while M65 P1 turns it off. You can use these codes to synchronize digital outputs in a specific mode.

For instance, you can use M64 to switch on an output in a particular mode and then use M65 to turn it off when the mode changes. By combining M64 and M65 codes, you can achieve precise digital output control in your CNC machine.

LinuxCNC Documentation Reference

You’ll find detailed information on the M64 command, which sets the output state, in the LinuxCNC documentation.

This documentation explains the syntax and usage of M64, including how it controls HAL pins motion.digital-out-NN.

You can reference the documentation to learn more about using M64 to set the output state in your CNC code.

M64 Command

Take control of your digital outputs with the M64 command, which instantly activates a specified auxiliary output. This command is part of the Group 4: Digital and Analog Output Control category of G-code commands in LinuxCNC. The syntax is M64 P[value], where the P value specifies the auxiliary output number. You can use M64 to activate output relays, with each relay command on an individual line.

CommandFunctionOutput Control
M64Activate digital outputImmediate activation
M63Deactivate digital outputSynchronized with motion
M65Deactivate digital outputImmediate deactivation
M64 P[value]Activate auxiliary outputSpecified by P value

Set Output State

When configuring your CNC machine, setting the output state is crucial for controlling digital outputs.

You’ll use the M64 command to switch on auxiliary outputs. The P value specifies the output number to be turned on. For example, M64 P3 turns on auxiliary output 3.

You can configure auxiliary outputs 1-6 with toggle inputs, while outputs 7-16 can only be controlled through Gcode. M64 turns on digital output immediately, unlike M63 which turns it off synchronized with motion, and M65 which turns it off immediately.

Understanding M64 Parameters

Configuring the M64 command requires a clear understanding of its parameters, which play a crucial role in controlling external devices.

You’ll need to know how to use the P-word, which specifies the auxiliary output number in the M64 syntax: M64 P[value].

Three key points to keep in mind when working with M64 parameters:

  1. The P-word ranges from 0 to a default value of 3, but you can increase the number of digital-out pins with a command-line parameter to motion.
  2. Auxiliary outputs 1-6 can have Auxiliary toggle inputs assigned to toggle them on and off, while auxiliary outputs 7-16 can only be changed through Gcode.
  3. The M64 code is used to turn on an output pin, and its syntax varies based on function, with parameters differing for each syntax, playing a pivotal role in successful configuration.

CNC Codes Similar to M64

CodeMode
M62Turn On binary output pin
M63Turn Off binary output pin
M65Turn Off binary output pin
M66Wait on Input
M67High Pressure Coolant On
M68High Pressure Coolant Off
M70Cycle bar feeder call 1
M71Cycle bar feeder call 2
M72Inside chuck clamp
M73Outside chuck clamp
M74Steady rest – milling head connection mode release
M75Steady rest – milling head connection mode start
M76Steady rest 1 unclamp
M77Steady rest 1 clamp
M78Steady rest 2 unclamp
M79Steady rest 2 clamp
M80Workpiece measurement start
M81Workpiece measurement end
M82Tool measurement start
M83Tool measurement end

Leave a Comment