The FAQ Mach3 page may also be of some help to understand basic concepts.

 

FAQ Mach4


 


 

How do I set up Mach4 and the SmoothStepper?

Please visit our Mach4 Getting Started Page.

 


 

How do I upload a copy of my Mach4 profile?

Open the profile you wish to send to us in Mach4, then go to Menu -> Help -> Support -> Package Current Profile...

Package Profile

Save your profile with an appropriate name, and remember which folder you saved it in.

Save Profile

In the forum post you are writing, go down to the Attachments section, and click on Add File.  Navigate to the profile you just saved, and select it.  It should then appear to the left of the Add File button.

Add File

After you submit your post, please make sure that your profile is attached in your post.

 

 


Where do I learn more about Mach4 itself?

The best place is on the Mach Support website itself! 

 


Logging in Mach4?

If something weird is happening in Mach4, I will usually ask you for a Log File so I can see exactly what happened in Mach4 and the ESS plugin.  To do this, go to Menu -> Diagnostic -> Logging...

Logging Menu

Then Press the Play button in the Log Window to start recording the messages.

Logging Window

Just before you cause the event to happen or just before you start the run, please press the 'Clear' button to get rid of any extraneous information in the log file.

After the event occurs, pleas press the save button to save the data, and then upload it to us if requested or relevant.   If possible try to make the log as short and concise as possible (I don't need 20 minutes worth of data if you can make it happen in 20 seconds), but also don't delete relevant information either.   What is really helpful is if you can say my problem X happened at this specific time (what ever it happens to be) in the log file.


If you place mc.mcCntlSetLogging(inst,1) in your screen_load_script this will automatically turn the logging on for you.

 


How do the Spindle buttons work in Mach4?

In the wx4 screenset, the lower right corner of the main Mach window looks like this:

Spindle Buttons

When you press the Spindle CW button you see the LED light up, but nothing happens. When you press the Spindle CCW button you see the LED light up, but nothing happens.  It should be working, but why isn't it?  When you press Spindle CW or Spindle CCW you are turning the spindle on, but with the last commanded speed.  Upon startup of Mach4, the last commanded speed is set to a default value of 0 RPM.  Only after you issue a new speed command will the CW or CCW buttons start at that speed. If you go to the MDI tab and type in a command similar to this, you should get Spindle movement:  M3 S1000

(Make sure you press Cycle Start to get the MDI command to execute!)

The buttons on the screen call lua script functions (Menu -> Operator -> Lua Script).

MDI and G-Code use Macros, some of which are standard macros (M3, M4 and M5), and custom macros that you can create and place in your "C:\Mach4Hobby\Profiles\YOUR PROFILE\Macros\" folder.   Here is an example of how to create a macro in Mach3, but it is essentially the same here in Mach4, you just save it to this folder path instead.

 


My Spindle (or something else) should be working, but it isn't!

This might have to do with a missing Macros folder in your "C:\Mach4\Profiles\YOUR PROFILE NAME\" folder.

 

 


Spindle PID

Introduction to the SmoothStepper’s Spindle PID Speed Controller

 

There are two methods for spindle speed control: Open Loop and Closed Loop. 

 Open Loop Control.png

With the Open Loop method Mach controls your spindle by:

  • In relay Mode: The GCode turning the Spindle On or Off (Your Router or VFD may allow you to manually specify a commanded speed).
  • In OB Mode (Step/Dir, CW/CCW or Quadrature modes) the GCode commands to move a certain number of steps every second.
  • In PWM mode your GCode specifies a specific rate (by a duty cycle percentage which is then turned into a specific voltage and amperage via your VFD), and Mach and the ESS assume that the spindle is really moving at that rate.

Open loop mode works well if you have a powerful spindle or the loading on the spindle does not slow it down significantly compared to when it is cutting air.

 Closed Loop Control.png

However, if there are significant changes in spindle loading, that loading may slow down the speed of your spindle significantly; negatively affecting the quality of your cut or breaking tools. The Closed Loop method avoids this by looking at the reported spindle speed and adjusting the current PWM duty cycle value up or down so that the measured spindle speed will match the commanded spindle speed.  With the SmoothStepper the Closed Loop method utilizes a PID controller (only available in PWM mode).

 

A PID based controller is comprised of Proportional Gain (Kp), Integral Gain (Ki) and Derivative Gain (Kd) constants.  These three constants are used to calculate the Error Results ERp, ERi and ERd, and these three error results are summed together and used to adjust the current PWM duty cycle value up or down.

 

The Kp term you specify is the Proportional Gain, which is simply a constant correction term value multiplied by the error amount.  This term may be sufficient by itself in situations where your spindle’s loading does not change significantly with respect to its power.  In this case you could leave the Ki = 0.0 and Kd = 0.0 to disable them.  The Error Result Proportional (ERp) would stay constant if the error amount stayed constant over time.

 

In situations where the loading on your spindle changes significantly and quickly, the remaining Ki and Kd terms can increase your performance significantly.

 

The Ki term you specify is the Integral Gain, which is a correction term that responds to size of the error over time.  The longer the error amount exists the larger the influence the Error Result Integral (ERi) term will have, and it can dominate the Error Result Proportional term quickly (when configured properly).  The Error Result, Integral (ERi) is designed to minimize the error amount as quickly as possible to get you back to zero error (although this can lead to overshooting).

 

The Kd term you specify is the Derivative Gain, which is a correction term that responds to instantaneous rate of change of the error amount.  The faster the error amount changes the larger the influence the Error Result Derivative (ERd) term will have, and it can dominate the Error Result Proportional and Error Result Integral terms very quickly (when set up properly).  The Error Result, Derivative (ERi) neutralizes the other two terms and leaves you at zero error without undershooting or overshooting the set point (when configured properly).

 

You should never use negative values for Kp, Ki or Kd Terms.  The larger a Kp, Ki or Kd Term value is, the larger the effect it will have.

 

Recommended initial values are Kp = 0.25  Ki = 1.0  Kd = 0.3

 

Spindle Speed feedback for the PID is provided by the Spindle Index signal/pin.

 

 PID Tuning

 

 

 

 


Setting Up Step Dir Spindle as an OB axis.

OB means an Out of Band axis.   If you read about the Spindle section on page 24 of 26 (Mach4 CNC Controller Software Installation and Configuration Guide Version 1.0).  Essentially you are using a motor output and disregarding the ‘position’ the motor is at (y = 27.1” or x = 48.567”).  Instead you are just using the motor’s acceleration settings to generate a velocity (step pulses or quadrature signals), and you are feeding that output signal into your VFD or spindle motor driver.

To run your spindle in Step/Dir, CW/CCW, or Quadrature mode, please follow these instructions.

1) In the ESS Configuration 'Spindle' tab: Set your Spindle selection to 'OB' mode.  This is effectively handing control of the spindle over to Mach4.

OB_ESS_Spindle.png
 
 
2) In the ESS Configuration 'Motors' tab: Set Motor 5 (or another Motor) to  Step/Dir, CW/CCW or Quadrature mode as desired.
 
OB_ESS_Motors.png
 
 
3) In the ESS Configuration 'Pins Config' tab:  For the two output pins that will control your spindle (I will use Port 1 Pin 16 and Port 1 Pin 17), give then an Alias similar to this:
  • For Step/Dir Mode - 'M5 Step For Spindle' and 'M5 Step For Spindle'
  • For CW/CCW Mode - 'M5 CW For Spindle' and 'M5 CCW For Spindle'
  • For Quadrature Mode - 'M5 Quad A For Spindle ' and 'M5 Quad B For Spindle'
 
OB_ESS_Pins_Config.png
 
 
4) In the ESS Configuration 'Output Signals' tab: Map the two pins you just assigned to Motor 5's corresponding pins.  (If you used a Motor other than 5 back in step 2, make the same modification here.)   You may also assign the relays for Spindle On, Spindle Fwd and Spindle Rev as desired at this point.
 
OB_ESS_Output_Signals.png

 

5) In the Mach Configuration 'Motors' tab:  Select Motor 5 in the right hand column.  (If you used a Motor other than 5 back in step 2, make the same modification here.) 

If you wish to work in terms of RPM, assign the following:

  • Set the 'Counts' per unit to 1.0  (Changing this field will affect the Velocity and Acceleration fields, so hit Apply, switch to a different motor and then come back to this motor again to continue.)  You want 1.0 since this will multiply the Velocity field.
  • Set the 'Velocity Units/Minute' to your maximum RPM for your spindle  _OR_    60 x the maximum RPM for your spindle
  • Set the 'Acceleration Units/(Sec^2)' to the change in RPM every minute divided by 60.   This will control the acceleration for your spindle.
  • Backlash may be left blank
  • You may set an Enable delay

 

OB_Mach4_Motors.png

 

6) In the Mach Configuration 'Axis Mapping' tab:   In OB1 (6)'s Master Column, choose Motor 5. (If you used a Motor other than 5 back in step 2, make the same modification here.)  You may use a different OB#, but you must then make the same change in the next step.

OB_Mach4_Axis_Mapping.png

 

7) In the Mach Configuration 'Spindle' tab:

In Range 0:

  •  MinRPM, Accel Time and Decel time will be ignored.
  • You need to change the MaxRPM to a non-zero number, since Mach4 will silently dismiss all spindle commands if MaxRPM is 0.  A 1 will suffice, but I would use your Max Spindle Motor RPM for consistency.  Otherwise this field is ignored by Mach when in Step/Dir, CW/CCW, or Quadrature Spindle modes.
  • Feedback Ratio will only be used for the Spindle Feedback (index) signal.

Now set your Max Spindle Motor RPM to your desired RPM.

Now set your Step/Dir Spindle Axis to the value chosen in the previous step.

OB_Mach4_Spindle.png

 

 8) You will now be able to issue MDI or G-Code commands for Spindle movement, like:

  • M3 S1000    --Starts the Spindle CW at 1000 RPM
  • M4 S5000    --Starts the Spindle CCW at 5000 RPM
  • M5              --Stops the Spindle

 

Important Notes:

  • Remember that Mach4 starts up with a default spindle speed of 0.  You will need to issue a S#### command to change the spindle speed from 0 RPM.
  • Remember that in Mach4,  pressing the Enter Key will not start an MDI command.  You will need to click on 'Cycle Start' to start an MDI command.
  • In Mach4, if you press 'Disable' or EStop while the spindle is running, Mach4 will think it is still running when you try to start it again, and ignore your new command!  If you try starting it, and it doesn't start, try switching to the other direction or using M5 to stop the spindle, and then try starting it again.

 

 

 


 

 

Homing Issues

Homing works correctly in Mach4 with the ESS.  However, once in a while a few users have reported that homing stops working for some reason.  Here are the settings to check to get homing to work correctly again:


In the ESS Config:

  • Make sure all axes which can home are enabled and make sure home switch pins config and input signals mappings are enabled and mapped.
  • Set Approach and back off velocities are within reasonable range (i.e. set X(200/20), Y(200/20) and Z(100/10).


In the Mach4 Config:

  • Make sure all axes which are configured are enabled in Axis Mapping. (Those which can home and those which cannot home)
  • In Homing/Soft Limits, set Home order for all configured axes (suggestion for normal gantry machine z(1), x(2), y(3) and if more axes are used have their order greater than 3 so that they home after x,y and z. This makes debugging easier. Have all disabled axes at order zero.
  • Make sure all axes which cannot home have "home in place" checked in the homing tab.

 

To generate an offset from the home switch after homing, you must use a lua script to generate the offset move.

 

 


 

 

Why doesn't Goto Zero work for the Z axis in Mach4?

For safety, the Z axis "Goto Zero" is disabled by default; to modify this, edit this section of the Screen Load Script:

function GoToWorkZero()
    mc.mcCntlMdiExecute(inst, "G00 X0 Y0 A0")--Without Z moves
    --mc.mcCntlMdiExecute(inst, "G00 G53 Z0\nG00 X0 Y0 A0\nG00 Z0")--With Z moves
end

 

 


 

 

Feed Hold and Spindles or Lasers

In the Menu -> Configure ->Mach... -> General tab you have two options for the Feed Hold stopping the spindle and restarting it, which would also apply to the laser.  When using a laser, and you press Feed Hold, you typically would not want the laser to keep lasing. 

Laser and Feed Hold

 

 

 

 


 

 

Mach4 Input Signal Descriptions

This is a list of the Input Signals that Mach4 and the ESS provide for you on the 'Input Signals' tab.  Inputs are signals collected from external devices (or circuits) and read into the ESS/Mach4.  For each Input Signal that you wish to use, you will need to Enable it (Green Check) and then Map a Pin Alias or Port and Pin# to that signal.   A Input Pin may feed multiple Input Signals.

This is covered some in on page 21 of the  Mach4 CNC Controller Software Installation and Configuration Guide Version 1.0

 

  • E-Stop:  This is a courtesy signal from your hardware (Motor Driver or E-Stop Button or other appropriate hardware) that informs the ESS and Mach4 that an Emergency Stop has occurred.  Your E-Stop hardware is responsible for shutting down motors as required for safety.  Never rely on software to stop motors!  Please read our Safety section.
  • Motion Inhibit:  When active, Mach4 will not generate motion.
  • Limit Override: When a limit switch is active, motors are not allowed to move.  When this signal is activated (or a screen set Limit Override button is activated), the motors are allowed to jog in order to move off of the limit switch.
  • Motor 0 ++ :  Positive limit switch for Motor 0 (When active, this will stop all motor movement.)
  • Motor 1 ++ :  Positive limit switch for Motor 1 (When active, this will stop all motor movement.)
  • Motor 2 ++ :  Positive limit switch for Motor 2 (When active, this will stop all motor movement.)
  • Motor 3 ++ :  Positive limit switch for Motor 3(When active, this will stop all motor movement.)
  • Motor 4 ++ :  Positive limit switch for Motor 4 (When active, this will stop all motor movement.)
  • Motor 5 ++ :  Positive limit switch for Motor 5 (When active, this will stop all motor movement.)
  • Motor 0 -- :  Negative limit switch for Motor 0 (When active, this will stop all motor movement.)
  • Motor 1 -- :  Negative limit switch for Motor 1 (When active, this will stop all motor movement.)
  • Motor 2 -- :  Negative limit switch for Motor 2 (When active, this will stop all motor movement.)
  • Motor 3 -- :  Negative limit switch for Motor 3 (When active, this will stop all motor movement.)
  • Motor 4 -- :  Negative limit switch for Motor 4 (When active, this will stop all motor movement.)
  • Motor 5 -- :  Negative limit switch for Motor 5 (When active, this will stop all motor movement.)
  • Motor 0 Home:  Home switch input for Motor 0 (This is used to home your axis, and is sometimes shared with Motor 0 -- .)
  • Motor 1 Home:  Home switch input for Motor 1 (This is used to home your axis, and is sometimes shared with Motor 1 -- .)
  • Motor 2 Home:  Home switch input for Motor 2 (This is used to home your axis, and is sometimes shared with Motor 2 -- .)
  • Motor 3 Home:  Home switch input for Motor 3 (This is used to home your axis, and is sometimes shared with Motor 3 -- .)
  • Motor 4 Home:  Home switch input for Motor 4 (This is used to home your axis, and is sometimes shared with Motor 4 -- .)
  • Motor 5 Home:  Home switch input for Motor 5 (This is used to home your axis, and is sometimes shared with Motor 5 -- .)
  • Motor 0 Index:  If a rotational motor/axis or a servo motor (with index pin), this provides the precise rotational home.
  • Motor 1 Index:  If a rotational motor/axis or a servo motor (with index pin), this provides the precise rotational home.
  • Motor 2 Index:  If a rotational motor/axis or a servo motor (with index pin), this provides the precise rotational home.
  • Motor 3 Index:  If a rotational motor/axis or a servo motor (with index pin), this provides the precise rotational home.
  • Motor 4 Index:  If a rotational motor/axis or a servo motor (with index pin), this provides the precise rotational home.
  • Motor 5 Index:  If a rotational motor/axis or a servo motor (with index pin), this provides the precise rotational home.
  • Index: This will feed in the Spindle's RPM information, since this will (typically) activate once every revolution.  (Some setups may trigger multiple times per revolution for enhanced accuracy.)

 

Servo motors use encoders to know where they are, and they can (but do not need to) feed this information back into the ESS/Mach4.  Encoders may be used with stepper motors, but this is not common.  If the rising edge of the A Phase leads the B Phase, that indicates a step in one direction.  If the rising edge of the B Phase leads the A Phase, that indicates a step in the other direction.   The cumulative change is steps is tracked so that the current position may be known.

  • Encoder 0 Phase A:  This encoder phase input is used with the phase B input to provide position information to the ESS for motor 0.  
  • Encoder 0 Phase B:  This input is used with the phase A input.
  • Encoder 1 Phase A:  This encoder phase input is used with the phase B input to provide position information to the ESS for motor 1.
  • Encoder 1 Phase B:  This input is used with the phase A input.
  • Encoder 2 Phase A:  This encoder phase input is used with the phase B input to provide position information to the ESS for motor 2.
  • Encoder 2 Phase B:  This input is used with the phase A input.
  • Encoder 3 Phase A:  This encoder phase input is used with the phase B input to provide position information to the ESS for motor 3.
  • Encoder 3 Phase B:  This input is used with the phase A input.
  • Encoder 4 Phase A:  This encoder phase input is used with the phase B input to provide position information to the ESS for motor 4.
  • Encoder 4 Phase B:  This input is used with the phase A input.
  • Encoder 5 Phase A:  This encoder phase input is used with the phase B input to provide position information to the ESS for motor 5.
  • Encoder 5 Phase B:  This input is used with the phase A input.
  • Spindle Encoder Phase A: This encoder phase input is used with the phase B input to provide position information to the ESS for the Spindle 
  • Spindle Encoder Phase B:  This input is used with the phase A input.

 

Auxiliary encoders may be used to track devices other than your Spindle and Motors.  Pendants will commonly provide a MPG (Manual Pulse Generator) encoder signal that may be used here.

  • Aux Encoder 0 Phase A:  This encoder phase input is used with the phase B input.
  • Aux Encoder 0 Phase B:  This input is used with the phase A input.
  • Aux Encoder 1 Phase A:  This encoder phase input is used with the phase B input.
  • Aux Encoder 1 Phase B:  This input is used with the phase A input.
  • Aux Encoder 2 Phase A:  This encoder phase input is used with the phase B input.
  • Aux Encoder 2 Phase B:  This input is used with the phase A input.
  • Probe:  Probe (or digitize) input for the G31 or G31.0 command
  • Probe 1:  Probe (or digitize) input for the G31.1 command
  • Probe 2:  Probe (or digitize) input for the G31.2 command
  • Probe 3:  Probe (or digitize) input for the G31.3 command

 

These THC signals are used for Torch Height Control (with the Z Axis) in plasma cutting systems.  The goal of THC is to keep the plasma cutter's tip at the optimal distance from the metal work piece, to ensure the optimal cut quality in the metal.

  • THC On:  This signals indicates that the plasma cutter's torch is active and stable.  This is also referred to as Arc Okay.
  • THC Up:  This signal indicates that the THC unit wants the Z axis to move up.
  • THC Down:  This signal indicates that the THC unit wants the Z axis to move down.
  • Jog X + : This will jog the X axis in the (+) direction.
  • Jog X - :  This will jog the X axis in the (-) direction.
  • Jog Y + : This will jog the Y axis in the (+) direction.
  • Jog Y - :  This will jog the Y axis in the (-) direction.
  • Jog Z + :  This will jog the Z axis in the (+) direction.
  • Jog Z - :  This will jog the Z axis in the (-) direction.
  • Jog A + :  This will jog the A (or U) axis in the (+) direction.
  • Jog A - :  This will jog the A (or U) axis in the (-) direction.
  • Jog B + :  This will jog the B (or V) axis in the (+) direction.
  • Jog B - :  This will jog the B (or V) axis in the (-) direction.
  • Jog C + :  This will jog the C (or W) axis in the (+) direction.
  • Jog C - :  This will jog the C (or W) axis in the (-) direction.
  • Spindle At Speed:  If your VFD provides this signal, it will inform the system that the Spindle is at the commanded speed.
  • Spindle At Zero:  If your VFD provides this signal, it will inform the system that the Spindle is stopped or at 0 RPM.
  • Input #0:  General purpose input that can be mapped to any function
  • Input #1:  General purpose input that can be mapped to any function
  • ...
  • Input #62:  General purpose input that can be mapped to any function
  • Input #63:  General purpose input that can be mapped to any function

 

 


 

 

Mach4 Output Signal Descriptions

This is a list of the Output Signals that Mach4 and the ESS provide for you on the 'Output Signals' tab.  Mach4 and the ESS will generate Output Signals  Inputs are then provided external devices (or circuits) to use. For each Output Signal that you wish to use, you will need to Enable it (Green Check) and then Map a Pin Alias or Port and Pin# to that signal.   A Output Pin may only receive its commands from a single Output Signal.  However, a single Output Signal may feed up to 3 Output Pins.

This is covered some in on pages 22 through 26 of the Mach4 CNC Controller Software Installation and Configuration Guide Version 1.0

 

Each motor may be set to Step/Dir, Quadrature or CW/CCW (Clockwise/Counterclockwise) mode.  These signals go to your Motor Drivers, so they may drive the motors, generating motion.   The Dir indicates the direction the motor is supposed to move, the Step is a single pulse for each step (or micro step) your motor should make.  In CW/CCW mode the CW line would have a pulse for a step in one direction, the CCW line would have a pulse for a step in the other direction.  In Quadrature mode two Phases are generated. If the rising edge of the A Phase leads the B Phase, that indicates a step in one direction.  If the rising edge of the B Phase leads the A Phase, that indicates a step in the other direction.  

  • Motor 0 Step,  Motor 0 CW or Motor 0 Quad A
  • Motor 0 Dir,  Motor 0 CCW or Motor 0 Quad B
  • Motor 1 Step,  Motor 1 CW or Motor 1 Quad A
  • Motor 1 Dir,  Motor 1 CCW or Motor 1 Quad B
  • Motor 2 Step,  Motor 2 CW or Motor 2 Quad A
  • Motor 2 Dir,  Motor 2 CCW or Motor 2 Quad B
  • Motor 3 Step, Motor 3 CW or Motor 3 Quad A
  • Motor 3 Dir,  Motor 3 CCW or Motor 3 Quad B
  • Motor 4 Step,  Motor 4 CW or Motor 4 Quad A
  • Motor 4 Dir,  Motor 4 CCW or Motor 4 Quad B
  • Motor 5 Step,  Motor 5 CW or Motor 5 Quad A
  • Motor 6 Dir,  Motor 5 CCW or Motor 5 Quad B

 

Enable signals will be active when the machine is enabled, and may be used to enable your motor drivers.  However, it may be advisable to have the motor driver enables controlled by a hardware based E-Stop circuit!  These enables signals can be turned on after a delay (Mach4 Config -> Motor Tuning tab). If the axis that uses the motor is not enabled the motor will not get an enable signal.

  • Enable #0:  This is the enable output for Motor 0
  • Enable #1:  This is the enable output for Motor 1
  • Enable #2:  This is the enable output for Motor 2
  • Enable #3:  This is the enable output for Motor 3
  • Enable #4:  This is the enable output for Motor 4
  • Enable #5:  This is the enable output for Motor 5

 

Spindle related outputs.

  • Spindle PWM: This will take the commanded spindle speed in RPM and convert it to an output signal with a duty cycle between 0% and 100%, which your spindle speed control module will convert into an analog voltage (typically 0v to 10 V DC).  This analog voltages is used by your VFD to run your spindle at the commanded RPM. 
  • Spindle Dir:  This output retains the current spindle direction even when the spindle stops.  It only switches state when a direction change is ordered (which prevents spindle direction glitching).
  • Spindle On: This output is active when the spindle is active
  • Spindle Fwd: This output is active when the spindle is running forwards (CW)
  • Spindle Rev: This output is active when the spindle is running in reverse (CCW)

 

  • Is Moving: This output activates when motion is being generated by Mach4 and the ESS.
  • XY Feed Rate PWM: This output provides an output signal (8 bit PWM) for lasers, where the intensity needs to be adjusted to match the X-Y velocity.  The faster the X and/or Y axis velocity is, the higher the laser output needs to be in order to maintain a uniform cut.
  • Charge Pump:  This output provides a 12.5 kHz signal when active, so external hardware knows that Mach4 and the ESS are running.
  • Coolant On:  This output activates for the Coolant.
  • Mist On:  This output activates for the Mist.
  • Current Hi/Low: This output activates to change a drive from low current to high current mode, for upcoming motion.
  • Digitize Trigger:  This output activates when the Probe is active with a G31/G31.x command.
  • Limit Override:   This output activates when the Limit Override is active.
  • Parts Finished: This output activates when the G-Code finishes running, and the parts are finished.
  • G-Code Running:  This output activates when G-Code is running (typically used for an indicator light).
  • Feed Hold:  This output activates when Feed Hold is active.
  • Block Delete:  This output activates when Block Delete is active.
  • Single Block:  This output activates when Single Block is active.
  • Reverse Run: This output activates when Reverse Run is active.  (This runs a G-Code file backwards.)
  • Opt Stop: This output activates when optional stop is active (when a G-Code file calls M01).
  • Machine Enabled: This output activates when the machine is enabled.
  • Tool Change:  This output activates when an automatic tool change is occurring, or while a manual tool change is waiting for a Cycle Start.
  • Dist To Go: This output activates when the DRO (Digital Read Outs) are in Distance to Go mode (which is the distance to go to reach the end point of the current move).
  • Machine Coord: This output activates when the DRO (Digital Read Outs) are in Machine Coordinates mode (distance from the Home Switches) instead of the Work Coordinates mode (relative to a 'Zero' position, which may or may not be your home switches).
  • Soft limits On: This output activates when soft limits are active.
  • Jog Inc: This output activates when jogging is set to incremental jog mode.
  • Jog Cont: This output activates when jogging is set to continuous jog mode.
  • Jog Enabled: This output activates when jog mode is enabled.
  • Jog MPG:  This output activates when jogging is set to Manual Pulse Generator (MPG) jog mode (from a pendant or similar device).

 

  • X Homed:  This output activates once a homing operation completes for this axis.
  • Y Homed:  This output activates once a homing operation completes for this axis.
  • Z Homed:  This output activates once a homing operation completes for this axis.
  • A (or U) Homed:  This output activates once a homing operation completes for this axis.
  • B (or V) Homed:  This output activates once a homing operation completes for this axis.
  • C (or W) Homed:  This output activates once a homing operation completes for this axis.

 

  • Dwell: This output activates while a G4 Dwell command is active.
  • Toolpath Mouse Down: This output toggles when the toolpath is set to report the mouse position and Mach4 Core is set to report clicks. See the Mach4 Lua Script manual to set the core into Toolpath capture mode.

 

  • X ++ :  Activated when one of the motors that makes up the X axis has a positive limit switch pressed.
  • X -- :  Activated when one of the motors that makes up the X axis has a negative limit switch pressed.
  • X Home:  Activated when one of the motors that makes up the X axis has a Home switch pressed.
  • Y ++ :  Activated when one of the motors that makes up the Y axis has a positive limit switch pressed.
  • Y -- :  Activated when one of the motors that makes up the Y axis has a negative limit switch pressed.
  • Y Home:  Activated when one of the motors that makes up the Y axis has a Home switch pressed.
  • Z ++ :  Activated when one of the motors that makes up the Z axis has a positive limit switch pressed.
  • Z -- :  Activated when one of the motors that makes up the Z axis has a negative limit switch pressed.
  • Z Home:  Activated when one of the motors that makes up the Z axis has a Home switch pressed.
  • A (or U) ++ :  Activated when one of the motors that makes up the A axis has a positive limit switch pressed.
  • A (or U) -- :  Activated when one of the motors that makes up the A axis has a negative limit switch pressed.
  • A (or U) Home:  Activated when one of the motors that makes up the A axis has a Home switch pressed.
  • B (or V) ++ :  Activated when one of the motors that makes up the B axis has a positive limit switch pressed.
  • B (or V) -- :  Activated when one of the motors that makes up the B axis has a negative limit switch pressed.
  • B (or V) Home:  Activated when one of the motors that makes up the B axis has a Home switch pressed.
  • C (or W) ++ :  Activated when one of the motors that makes up the C axis has a positive limit switch pressed.
  • C (or W) -- :  Activated when one of the motors that makes up the C axis has a negative limit switch pressed.
  • C (or W) Home:   Activated when one of the motors that makes up C the axis has a Home switch pressed.

 

  • Output #0:  General purpose output.
  • Output #1:  General purpose output.
  • ...
  • Output #62:  General purpose output.
  • Output #63:  General purpose output.


 

 

 

 

 


Laser Setup

Lasers can be very dangerous, especially to your eyesight.  The appropriate Laser goggles are a MUST!  Please refer to your Laser's manual, manufacture, or vendor to determine the appropriate Laser eye protection and other safety requirements.

Please make sure that you read and understand our Safety page too!

Starting with ESS Mach4 plugin build 221, we now have a dedicated Laser PWM signal, support for a Laser Gate signal and software specifically for Laser Vector and Laser Raster modes.

Laser Vector mode, relies on using GCode to control the motion of the laser head (or the laser emission point on your Z axis).  You will activate the Laser output before starting a cut, and then deactivate the Laser output when fishing a cut, all in GCode.

Laser Raster mode uses a little bit of GCode to position the starting point of the raster, but after that, it consumes the data from a bitmap image, and burns the image pixel by pixel based off of the 8 bit color data in the image.

The traditional method of using the Spindle PWM output for a laser is no longer necessary nor the best choice, a Spindle and Laser may now be used in the same GCode program since they are separate devices.

 

Setting Up The Configuration:

1. To set up a Laser, go to Mach4 Menu -> Configure -> Plugins... -> ESS ### -> Pins Config Tab:

  • Determine which output pin will be your Laser PWM output pin (I picked 2-16).  
  • Determine which output pin will be your Laser Gate output pin(I picked 2-17).  If your Laser does not use a Gate signal, YOU WILL STILL NEED TO ASSIGN ONE, but you may pick any unused output on the ESS, since you will not need to wire it.

Pins Config

2. In the Mach4 Menu -> Configure -> Plugins... -> ESS ### -> Output Signals Tab:

  • Set the "Laser PWM" signal to the Laser PWM output pin selected in the last step. 
  • Scroll down to the Output Numbers area, and select an unused one.  I picked Output #20, and assigned it to the Laser Gate output pin selected in the last step.

Laser PWM

Laser Gate

3. In the Mach4 Menu -> Configure -> Plugins... -> ESS ### -> Laser Tab - Laser Settings:

  • Set the Laser Gate Output # to the Output signal selected in the last step.  This step is required for the ESS's FPGA to generate a PWM output signal.
  • Set the Raster PWM frequency and Vector PWM Frequency that you want the ESS to send to your laser in each of those those modes.
  • Synrad Lasers may be damaged if the PWM frequency is above 20 kHz, other Lasers may be as well.  To set the PWM frequency above 20 kHz, you must check the box for "Allow PWM frequencies over 20 kHz".  If you do this, YOU MAY DAMAGE YOUR LASER, which will be entirely your fault and your responsibility!
  • If you are not connecting the Laser Gate pin to your laser, you may leave all the Gate Delay and Gate Duration settings alone.  If you are using the Laser Gate, consult with your Laser's manual for the best settings. 
  • The Gate Delay Percentage represents the OFF time of the Gate signal
  • The Gate Duration Percentage represents the ON time of the Gate Signal.
  • These signals are synchronized with the pixel's PWM value that is currently being burned.  The purpose of the Gate signal is to force your Laser to emit/discharge at the appropriate time to burn the correct pixel. 
  • Gate Delay and Duration values will affect the intensity and/or color of the burned area.
  • Delay allows time for the new PWM value to be read by the Laser, and will cause the next Duration Discharge to be at the correct intensity. 
  • Duration is the amount of time that the Laser is emitting.  If you double the duration value, you will likely double the emitted power (not counting for non-linearity or maxing it out).
  • The total Gate Delay + Gate Duration percentages must sum up to 100% or less.   If the total is larger than 100% , the delay value will be automatically reduced to reach 100%.
  • If the total Gate Delay + Gate Duration value is less than 100%, more off time will be added after the Duration percentage has completed, to reach 100%.
  • The Synrad 5 kHz mode will "tickle" the Gate signal, when the PWM value is below a specific threshold (nearly off or off). This tickling will keep the Laser ready to emit when the next PWM value requiring an emission is received.

LaAser Tab

4. In the Mach4 Menu -> Configure -> Plugins... -> ESS ### -> Laser Tab - Default Image Settings in RASTER mode.  These fields are populated into Mach4 registers at startup, and not modified by the config settings until the next startup. You may override these settings by calling Macros from your GCode or in Mach4:

  • Depending on the starting corner of your image, you may need to check "Flip Image Horizontally" to get the orientation and lettering to appear correct.  This will flip or mirror your image left to right.
  • Depending on the starting corner of your image, you may need to check "Flip Image Vertically"to get the orientation and lettering to appear correct.  This will flip or mirror your image top to bottom.
  • In an image, pure white (or the pixel value of 255) will burn with full intensity, and pure black (or the pixel value of 0) will not burn at all.  To switch this, check "Invert Image Intensities".
  • "Compensate for X Acceleration Distance" means that the plugin will calculate the distance it takes to get up to the commanded velocity, which is where the pixels will be burned.  The plugin will automatically move in the opposite direction before it starts to burn the first line of the image, so that the first image pixel will occur at the starting point of the Laser Raster.  If you are using the "_Laser_Raster_Velocities.txt" file to manually adjust the Pre-Comp offset, that will be in addition to this automatically calculated value.
  • If "Skip the Laser Raster Start Window" is unchecked, you will be prompted with a confirmation window before the Laser Raster Starts.  Check this, if you do not want to see the confirmation window.
  • "Laser Raster Even Rows Only" may be checked, and then only the Even Numbered rows (all in the same direction) will be burned.  This is useful if you wish to check the overlap distance of your laser beam, or if you are having alignment issues with your Odd Numbered rows (i.e. a single vertical line is being rastered as two vertical lines - in this case, you would need to adjust your Motor Delay Distance).

 5. Download these lua macros, unzip them, and place them in your "C:\Mach4Hobb\Profiles\YOUR_PROFILE_NAME\Macros\" folder.  These macros will be discussed in the next section.

 

 Laser Vector Operations:

With the Spindle you would use a command similar to M3 S1000 to turn the spindle on and then set the speed to 1000 RPM, M5 would be used to turn it off again.  Since these commands are used by the Spindle, we won't reuse them for the Laser.  Instead, the following lua scripts will be used to control the Laser's PWM and gate signals (using Mach4's ESS Registers):

1. m2003 uses the comments area immediately after on a single line of GCode to configure Laser's PWM parameters:

  • m2003 (LASER_VECTOR_PWM_PERCENTAGE=33.33) <- This will set the PWM Duty Cycle from 0% to 100%
  • m2003 (LASER_VECTOR_FREQUENCY=20000) <- This will set the PWM frequency to 20 kHz
  • m2003 (LASER_VECTOR_GATE_DELAY=0.5) <- This will set the Gate Delay to 0.5 ms
  • m2003 (LASER_VECTOR_GATE_DURATION=0.5) <- This will set the Gate Duration to 0.5 ms

2. m2004 will be used to Enable the Laser for Vector Mode (but not activate it).  This macro also processes any recent changes made by m2003 commands, and is required to make changes to the parameters.

3. m62p#  will activate the laser.  Replace the # with your Gate Output Signal number, which would be 20 from the settings above:  m62p20  This command when followed by a GCode motion command (G0, G1, G2 or G3) will activate the laser (assuming it was enabled), and have the activation synchronized with the start of the motion command.

4. m63p#  will deactivate the laser.  Replace the # with your Gate Output Signal number, which would be 20 from the settings above:  m63p20  This command when followed by a GCode motion command (G0, G1, G2 or G3) will deactivate the laser (assuming it was enabled), and have the laser shutoff synchronized with the start of the new motion command.

5. m2005 will be used to Disable the Laser for Vector Mode.  It will shut off the Laser PWM signal and the Laser Gate Signal.

A simple square can be lased with this code:

 

(Start of GCode)
G01 X0 Y0 Z1 F50

m2003 (LASER_VECTOR_PWM_PERCENTAGE=33.3)
m2003 (LASER_VECTOR_FREQUENCY=20000)
m2003 (LASER_VECTOR_GATE_DELAY=0.5)
m2003 (LASER_VECTOR_GATE_DURATION=0.5)

m2004 (This will Enable the Vector Laser)

G01 X1 Y1 Z1

M62 P20   (This will turn ON the Laser Gate and PWM with the next motion command)

G01 X2 Y1
G01 X2 Y2
G01 X1 Y2
G01 X1 Y1

M63 P20   (This will turn OFF the Laser Gate and PWM with the next motion command)

(Move to the next position, and then start a new laser cut if desired...)





(When done and ready to quit)

M2005 (This will Disable the Vector Laser)
G01 X0 Y0 Z1

(End of GCode)

 

 

 

 Laser Raster Operations:

The intent is to give the user a significant level of flexibility with regards to controlling the laser raster settings, which means that there are many macro commands available for the user.   If you don't want to utilize all of them, you can just copy and paste the code provided below, and after some initial tweaking, just reuse the same GCode every time for every image.  All you need to do is change the image you are pointing to.

An important point to note  is that the feedrate is currently locked at 1024 pixel per second with build 221, but will be able to increase greatly with the next major update.  As a result your feedrate will depend upon your image's DPI.  Your speed in inches/min is 60 * 1024 / DPI.  Your speed in mm/min is 60 * 1024 / pixels per mm. The software will ignore your commanded feedrate (while in build 221) and calculate the appropriate feedrate.  The lower the DPI the faster the X axis velocity while burning a line of the image.  The Y axis will merely step up a row, and it will typically not reach its max velocity before the move is over.

Here are the lua script commands used to set up the Laser Raster:

1. m2000 (C:\image.bmp)    This command will look for the image.bmp picture in your C drive.   You can point to any folder location you wish, and use any image name that you wish.  The requirement is that the image be a 256 color (8 bit) gray scale bitmap or a 24 bit RGB bitmap without an alpha channel.  I have used the GIMP Photo Editing software to create and modify my test images, but most other image editors will work as well. 

2. m2001 (Comment)

  • m2001 (UNITS=IN) This will tell the software that all your commanded values will be in Inches.  This must be the same as the default units for your profile in Mach4's  General Tab for Machine Setup Units.  If your default units are metric, you must call m2001 (UNITS=MM) for the software to run.
  • m2001 (FEEDRATE=900.9) you may specify your desired feedrate.  However for Build 221, it will be ignored and the appropriate, calculated, feedrate will be used.
  • m2001 (IMAGE_STARTING_CORNER=#) The Laser Raster will start from the commanded corner and work to the opposite corner.  Replace the # with 1, 2, 3 or 4.  1 means start from the Lower Left corner of the image.   2 means start from the Lower Right corner of the image.  3 means start from the Upper Right corner of the image.   4 means start from the Upper Left corner of the image.
  • m2001 (IMAGE_COLOR_CHANNEL= #) If you are using a 256 color gray scale image, this command is not important.  If you are using an 24 bit RGB image, this command allows you to select which color channel the image data will be taken from.  1 means the Red color channel.2 means the Green color channel.   3 means the Blue color channel.  4 means the average of all three color channels.
  • m2001 (IMAGE_INVERT_INTENSITIES=0) 0 Means that pure white (or the pixel value of 255) will burn with full intensity, and pure black (or the pixel value of 0) will not burn at all.  1 means that pure black (or the pixel value of 0) will burn with full intensity, and pure white (or the pixel value of 255) will not burn at all. This will override the default setting in the Laser tab for  "Invert Image Intensities".
  • m2001 (IMAGE_FLIP_X=0) Depending on the starting corner of your image, you may need to set this to 1 to get the orientation and lettering to appear correct, by flipping or mirroring your image left to right.  This will override the default setting in the Laser tab for "Flip Image Horizontally".
  • m2001 (IMAGE_FLIP_Y=0) Depending on the starting corner of your image, you may need to set this to 1 to get the orientation and lettering to appear correct, by flipping or mirroring your image top to bottom.  This will override the default setting in the Laser tab for "Flip Image Vertically".
  • m2001 (PWM_MAX=100) This will set the Maximum PWM Duty Cycle corresponding to a pixel intensity value of 255 (full burn value). Depending on the speed of the raster, a 100% value may be too high.
  • m2001 (PWM_MIN=15) This will set the Minimum PWM Duty Cycle corresponding to a pixel intensity value of 0 (no burn value). Depending on the speed of the raster, a 0% value may be too low.  This is ideally set just low enough that it does not burn the surface of the material, but a pixel value of 1 will.
  • m2001 (SHOW_WINDOW_TO_START=1) When set to 1, you will be prompted with a confirmation window before the Laser Raster Starts.  Set this to 0 if you do not want to see the confirmation window. This will override the default setting in the Laser tab for "Skip the Laser Raster Start Window".


3. m2002 (This starts the Laser Raster) This will tell the software to start the laser raster process. 

 

When the laser raster process starts, a log file is created and updated at "C:\Mach4Hobby\Plugins\_PROCESSING LASER COMMANDS LOG.txt".  This file will explain what is happening and what, if anything, went wrong.

If you are using servo motors, they will likely have following error.  This is compensated for in the "C:\Mach4Hobby\Plugins\_Laser_Raster_Velocities.txt" file.  The file is created after your first Laser Rastering attempt, and is internally documented.

 

Here is an example GCode file to raster an image:

 

(Start of GCode)

G0 X2 Y2 (Starting corner for the image)

M2000 (C:\GCode\Test.bmp)

M2001(UNITS = IN)
M2001(FEEDRATE = 600.000000)
M2001(IMAGE_STARTING_CORNER = 3)
M2001(IMAGE_COLOR_CHANNEL = 1)
M2001(IMAGE_INVERT_INTENSITIES = 1)
M2001(IMAGE_FLIP_X = 0)
M2001(IMAGE_FLIP_Y = 0)
M2001(PWM_MAX = 90)
M2001(PWM_Min = 5)
M2001(SHOW_WINDOW_TO_START = 1)

M2002(This starts the Laser Raster)

G0 X0 Y0

(End of GCode)

 

 

 

 

 

 

Go to top