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! 

 

 

 

 


What is the limitation in Demo Mode?

For 5 to 10 minutes (random) after startup of Mach4, you can run GCode while in demo mode. You need to license Mach4 to remove this limitation. Everything should work correctly during that 5 to 10 minute window, and then things will just stop working.

 


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, please press the "Save" button to save the data to a file, and then upload it to us if requested or relevant. 

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.

As of Mach4 build 5028+, the Mach4 signals tabs will allow you to enable or disable logging of signal change states on a per signal basis.   If you are asking for help with a log file, make sure all of the signals are being logged so we can see them changing in the log file (unless they are spamming the log file and totally irrelevant).

As of Mach4 build 5028+, the Mach4 signals tabs will allow you to enable or disable logging of signal change states on a per signal basis.   If you are asking for help with a log file, make sure all of the signals are being logged so we can see them changing in the log file (unless they are spamming the log file and totally irrelevant).

As of Mach4 build 5028+, you can go into the log settings and filter out different message types. If you are asking for us to look at the log file, make sure that the Plugin box is checked,

Logging Options

 

 


Communications Timeout

"A communications timeout occurred with the ESS board.No data packets were received from the ESS for 3 seconds.

This is likely caused by the ESS losing power, or losing Ethernet communications between Mach4 and the ESS.

If asking for support, please record what the two Green and Red status LEDs are doing on the ESS before and after pressing OK below.

An ESS power cycle and Mach4 restart may be needed. Press 'Yes' to close, 'No' to suppress this message."

 

If the LEDs are all off, the ESS has no power.

If the top Green LED is blinking twice per second, power was lost and came back.

If you press yes, and then Mach4 and the ESS keep running, then your PC went out to lunch and stopped servicing Mach4 and the ESS. In this case, do the following:

1) Run The SCU and its Windows Performance Tuning, since that will help to optimize your PC, so it can run well.  If has been a while, you may need to run it again since a windows update may have modified some things.  Now for the rest of the possibilities in no particular order...

2) Make sure your GCode is running from your PC's hard drive. Never run GCode from a network drive or a USB stick, at some point, there will be a pause while trying to access the data and the ESS will run out of data!

3) Don't have USB Memory sticks or USB Hard drives attached to your computer.  Windows will stop servicing Mach to periodically detach and then reattach these USB file systems.

4) Don't switch screens or applications while running GCode

5) Don't refresh your tool path while running GCode

6) Make sure your PC is disconnected from the internet. Random downloads or updates from the internet will cause your computer to stop servicing Mach.

7) Close all other software when running Mach4 (so they won't consume RAM or CPU time)

8) A common problem is a PC with a mechanical hard drive, and the fix for this is to use a SSD instead.  Your PC will start up much faster, load Mach much faster, and more importantly load data and not stall out while running GCode because your mechanical hard drive had to spin up or search for data.

9) We have seen corrupted Ethernet adapter drivers cause this issue several times now.  Open your Windows Control Panel then go into Device Manager.  Once inside expand the Networking section and locate the Ethernet Adapter that you are using to connect to your ESS. Right Click on it and select Uninstall.  Once that is done, go to Menu -> Action -> Scan for Hardware Changes, and your PC will find the Ethernet Adapter again.  Finally Run the SCU and configure the network adapter again, and it should address the connectivity and transmission issues.

EthernetDriverNetworkConnections.png

EthernetDriverNetworkConnections.png

EthernetDriverUnistall.png

EthernetDriverNetworkConnections.png

 

 

 

 

Here are some other recommended hardware steps you should take:

1) Check your Ethernet cable to make sure it is securely connected at both ends.  Try replacing the Ethernet cable with a new one, since we have seen "Ran out of Data" messages caused by bad Ethernet cables.

2) Make sure your PC is not set to speed stepping in BIOS or other similar setting that throttles back the CPU speed. 

3) Make sure that your PC is not overheating.  Try checking the CPU temperature with a monitoring program, and see if it is running too hot, which make make it reduce its CPU speed to keep it from damaging itself.  If you are running the PC in hot weather (without air conditioning) this can exasperate this problem.  Having a fan blow on your PC may be able to cool it enough to keep running without these problems.

4) Try air cutting your GCode file with your VFD/spindle shut off, and also your vacuum system shut off.  If you can run your GCode without this error message and these devices are off, then it is likely that electronic noise or ground loops from these devices may be causing the problem.

5) PC RAM.  If you don't have enough RAM, your PC is forced to swap data between the RAM and the hard drive using page files, which can cause significant delays, especially when using mechanical hard drives.  These delays can easily cause 'Ran out of Data' messages.  Recommended amounts of RAM for different versions of Windows are as follows  (32 bit Windows will limit you to 4GB of RAM, 64 bit Windows will allow more than 4 GB of RAM):

  • Windows 7: Minimum 4GB (you will need to make sure all other programs are closed); preferred 8 GB.
  • Windows 8: Minimum 4GB (you will need to make sure all other programs are closed); preferred 8 GB.
  • Windows 10 and 11: Minimum 4GB (you will need to make sure all other programs are closed and you will need to disable Cortana); preferred 8 GB or 16 GB.

 


G4 Dwell or Delay

Mach4 has two ways of interpreting the G04 Dwell or Delay command, with or without a decimal point.

If you include the decimal point, it interprets it in seconds:  G4 P3.0  is 3 seconds  G4 P3000.0 is 3,000 seconds.

If you omit the decimal point, it interprets it in ms :  G4 P3  is 0.003 seconds  G4 P3000 is 3 seconds.

I always use seconds on my code...

Also your smallest delay may only be 1.1 ms or 0.0011 seconds (or Mach4 will ignore it).

 

 

 


Jogging in Mach4

There are three main ways to jog an axis in Mach4:

There are two modes to jog with: Velocity mode or Incremental mode.

In Velocity mode, the machine moves at a commanded speed (a percentage of the max axis velocity) until you let go of the button (this is the normal mode for the screen set jogging). This will have acceleration and deceleration included with the motion, which means if you have a low acceleration rate it will take a while to decelerate too! This is the easiest way to move larger distances at higher speeds.

In Incremental mode, the machine will move one increment for every click of the encoder (you can assign any value you want for each increment). A typical MPG has 100 clicks per rev. If your current increment is 1 mm and you spin the MPG one rev the machine will move 100 mm. If you spin the MPG faster than the jog rate for that axis, it will accumulate all of the excess commanded movement and continue moving after you stop cranking on the MPG. If you spin the MPG fast it can keep going for quite a while to reach the commanded destination which could crash your axis (which is why you should use soft limits in order to prevent instances like this). The machine is just doing what you commanded it to do, it is just that you selected too big of an increment and cranked too far too fast. Incremental mode is the best way to move to a precise position. Mach4 always interprets a MPG input with incremental mode jogging. 

In Incremental mode, you may also see that if you set the step size to be 0.1 mm or some other small amount, it will appear jerky when slowly stepping. There are two reasons for this:

1. Plugin Cycle frequency: The ESS reports status information (including encoder counts) back to the plugin every 25 ms if you have the plugin frequency set to the default of 40 Hz.  If you increase it to 100 Hz, it becomes 10 ms.  We have some customers push it to 200 Hz, but not all PCs are happy with that speed.  80 Hz or 100 Hz are good choices if your PC is decent.

2. Velocity FIFO buffer depth (the bigger issue).  The default buffer depth is 0.18 seconds for the velocity FIFO buffer. That means apart from the plugin service periods, you also have 0.18 s of delay time before the motion commands are processed through the ESS's FIFO buffer and consumed.  We set it that big, so lower end PCs don't have FIFO buffer ran dry issues...  With a good PC, you MIGHT be able to run at 0.02 seconds for the buffer depth with a 100 Hz or 200 Hz plugin frequency.  There would be MUCH less lag and feel much more real time when doing your precision incremental jogs and the jerkiness will be gone.   To be clear I am not saying you should make it that small, and you would want to do a bunch of air cutting first to make sure you don't run out of data. 0.08 seconds would give you a much faster response time and also be much less likely to run empty.

Use Velocity mode to move close to where you want to be and then switch to incremental mode to get exactly where you want to be.

 

OB or OOB, are Out of Band axes, which means they run independently; their motion is not coordinated with the X, Y, Z, A, B, C, U, V or W axes.  OB axes in Mach4 can ONLY be controlled by jogging. 

Normally a spindle is ran at a set velocity, either by the ESS or Mach4, and it may be considered essentially an OB axis even if it is in PWM mode. However, the spindle may be assigned to an OB axis using motor 5 in Step Dir mode, in which case it could be jogged, or it could also be swapped in as a C axis and then its motion could be coordinated... the spindle doesn't always fit nicely into one category or the other.




Keyboard Jogging in Mach4

Mach3 has keyboard jogging enabled by default.  Mach4 requires you to assign the keys yourself.

 

1. Open the Mach4 Configuration:  Menu -> Configure -> Control...

TMC

 

2. In the Plugins tab , you will need at least these plugins enabled:

  • Core
  • LUA
  • Regfile
  • ESS
  • Keyboard Inputs.  <---You will need this if you are going to use keyboard keys.

If you don't have all these plugins enabled, the hardware will not work right.  You may use additional plugins as needed.

If you enable any plugins, you will need to restart Mach4 for those plugins to function properly.

Plugins

 

3. Open the Keyboard plugin: Menu -> Configure -> Plugins... -> Keyboard Inputs

 

 TMC

 

 

 4.  Keyboard Config Window.


A) Add inputs, "X+","X-","Y+","Y-","Z+","Z-" and others as appropriate for your needs, name them as you wish.

B) Press the area under "Key" to select the keyboard keys you wish to use.

C) Under function select the action you wish to have happen with that key press.

D) After pressing OK, RESTART MACH4If you don't restart, the keyboard keys will not work.

 Keys

 

5. In Window's task bar notification area (lower right, and it may be consolidated in the the ^ group), is a little black keyboard icon.  This is Mach's keyboard status indicator. If the red circle is on, your keyboard will not jog Mach or control the keyboard plugin.  If the red circle is not present, your assigned keys on the keyboard will be captured by Mach and processed by Mach.

 


 

What should the ESS's LEDs be doing during startup?

Near the middle of the ESS board is a red LED that should not be lit (silkscreen labeled "INIT").  When you first power the board, the red LED should blink for a short period ( about 1/4 of a second) and then go off.  Once you run Mach3, a green LED in the vicinity of the red INIT LED should light up.

 

ESS LEDs

 

Red LEDs

The Upper Left Red LED is not used, it will never be on, unless the microprocessor can't write to flash (a critical hardware failure that we have only seen once).

The Lower Left Red LED indicates the ESS device’s EStop input signal (controlled by your EStop Button):

  • If the Lower Left Red LED is on, the EStop is active inside the ESS, and the ESS will not generate any motion.   The EStop state inside the ESS can be caused by: Mach3/4 being in the disabled state (instead of enabled); Your EStop switch activated, forcing the EStop state; Your BOB is sending an EStop signal; a limit switch activated and forced an EStop condition.
  • When the Lower Left Red LED is OFF, you can generate signals with the ESS.

 

Green LEDs

The Upper Right LED indicates the ESS Mode.

The Lower Right Green LED indicates communications with the PC. 

  • Upper Green LED ON for 2 QUICK SHORT blinks; the Lower Green LED is OFF.  The ESS may be pinged in this mode.  This is the Normal Wait mode for the ESS when it first powers up, and it is waiting for a connection with Mach3 or Mach4. 
  • Upper Green LED ON SOLID.  The ESS may be pinged in this mode.  This is the Normal Run mode for the ESS, which means that it is (or was) connected to Mach3 or Mach4.  The Lower Green LED will do a very short and quick flash every time there is a data transmission with Mach.  You will typically see 10 or more blinks every second from the Lower Green LED when it is communicating properly with Mach.  When the ESS is in this mode, it cannot accept a new connection from Mach.   If Mach is closed and the ESS is still in this mode, you will need to power cycle the ESS before it can accept a new connection from Mach.
  • Upper Green LED ON for about 1 second then off for about 1 second; the Lower Green LED is OFF.  The ESS cannot be pinged in this mode. This means that the ESS is in BootP Configuration mode, which is only for use with the Configurator.  This mode can only happen when the small plastic jumper shorting out both of the BootP pins (JP1).  To exit this mode, remove the small plastic jumper from the BootP pins (JP1) and power cycle the ESS.  If you are receiving BootP packets when the config jumper is removed, it is very possible that the ESS lost its config, and running the Configurator will replace the config and allow normal operations again.

  • Upper Green LED ON for 1 LONG blink and 2 SHORT blinks; the Lower Green LED is OFF.  The ESS cannot be pinged in this mode.  This means that the ESS lost its IP address configuration in its flash memory.  The only way to fix this is to run the Configurator and give it an IP address again.  After running the Configurator, you will need to power cycle the ESS, and it should go into normal Wait mode (as long as there is not a jumper on JP1).

 

The Ethernet Jack has two LEDs on it. The upper left one is yellow. This is an important status LED. It represents the status of the Link Layer. If a link has not been established, the yellow LED will not be on. The link layer is a low-level Ethernet layer that needs to be present between your ESS and your PC in order for the higher-level communications to run.


The upper right LED on the Ethernet Jack is a green LED.  This green LED will flash whenever data is transmitted or received through the Ethernet Jack. 

  • When in normal operating mode (BOOTP jumper removed) connected to Mach it will blink multiple times per second, or appear to be on almost solid. 
  • When in config mode (BOOTP jumper shorting out both pins) the ESS transmits a request for an IP address about once per second.

 

The Red Led next to the FPGA (Init) should have one quick blink right after power is applied on a functional ESS.  The LED should then turn off for the rest of run time.  If the the Red Init LED is on solid, that means that the FPGA cannot clear its memory, or that there is a voltage problem on the 1.2V or 3.3V internal power rails.

 

 


TMC3in1 Handle Failure Messages in the log file

If you do not have a TMC3in1, but your log file is getting spammed with "TMC3in1 Register Update HANDLE FAILURE..." messages, that is because the TMC3in1 plugin is enabled in your profile, but the TMC3in1 plugins are not present.

 Either:

1) Add the TMC3in1 plugins to your "C:\Mach4Hobby\Plugins" folder, open Mach4 menu -> Configure -> Control... -> Plugins,  and disable the TMC3in1 plugin there, or

2) Open your "C:\Mach4Hobby\Profiles\YOUR PROFILE NAME\Machine.ini" file, and search for "TMC3in1=1".  Change it to "TMC3in1=0".  (Same effect as #1 without installing the plugins.)

You will not get spammed by these messages anymore. 

As of ESS build 258, the aforementioned messages will not spam your profile's log window.

 

 


ESS Diagnostics Window

The ESS Diagnostics window may be found at: "Mach4 Menu -> Diagnostic -> ESS v...".  This window may be useful during the initial setup of your machine, but I almost never go into it except during some rare troubleshooting.

The ESS Diagnostics window has an Inputs tab. This shows you the current state of all the ESS inputs as it sees them (after adjusting for Active Hi/Low).

meh meh


Some boxes may be checked, some boxes may not be checked, it depends on how your BOB is designed (pull ups and pull downs on each input), and more importantly if you have something wired to an input and what it is doing.  If the box is checked, that means the input is active.  If it is not checked, the input is not active.

If you check  or uncheck a box, nothing else will happen (same in the Outputs tab), this only tells you what the current state is.  The boxes are updated whenever the ESS sees the pin actually change state from Active to Inactive or vice versa.

 

There is an Encoders tab that displays all of the current encoder values and probe registers:

 meh

 

There is a tab that displays some spindle information:

 meh

 

There are two tabs that display FPGA signals and FPGA status information:

 meh meh

 

There is a tab that displays some ESS details:

 meh

 

 There is a final tab that shows Expansion Port information.

 

 meh

 

 


How do the stop, EStop and limit switches work with the SmoothStepper?

When an EStop event occurs, it forces a stop to occur in the ESS's FPGA, and the motors will stop and the outputs will go into the state you specified on their ESS Pin Settings.  The ESS will inform the ESS plugin, which will tell Mach4.  In addition, Mach4 will disable.

You can press the Stop button in Mach4, which will have essentially the same effects as an EStop.  The difference is that the stop event is being generated by Mach4 instead of the EStop input signal  on the SmoothStepper activating because of an external stop button or the output of a BOB.

When a limit Switch event occurs, it forces a stop to occur in the ESS's FPGA, and the motors will stop and the outputs will go into the state you specified on their ESS Pin Settings.  The ESS will inform the ESS plugin, which will tell Mach4.

 


How does the Charge Pump work?

Back when parallel ports were included with every PC, the PC would/could send out junk data on the parallel port's signal lines when the PC was booting up. (However, the PC would not be able to accidentally create a 12.5 kHz output which is used as the charge pump signal).  Once Mach took over the parallel port, it would output a charge pump signal to indicate that it was in control of the parallel port and that the hardware (motor driver) should respond to the incoming signals.  Without, the charge pump signal, the motor drivers would ignore any and all incoming signals (i.e. Step and Direction signals).

With the SmoothStepper, we will not output any signals without being commanded to do so.  Because of this, we don't need to worry about sending spurious signals during boot up, meaning we don't need to generate a charge pump signal.  We do provide a charge pump output for motor drivers that require a charge pump input.  However, if your motor driver allows you to disable the charge pump input, it should be fine to disable the charge pump input when you are controlling you motor driver with a SmoothStepper - please make sure your local laws and regulations allow this first though.

The SmoothStepper's General Config, you can decide if the charge pump will only be generated while Mach4 is Enabled, or if the charge pump will be generated the whole time that the SmoothStepper is configured (that is to say the SmoothStepper is communicating with Mach4, but the SmoothStepper configuration is not being updated).

 

 


Probing in Mach4

Please click here to see all the details regarding probing in Mach4.

 


NAN for Motor DRO?

If you see NAN in your motor's DRO, the issue is mot likely a "NAN" for one of the values in the Motor tuning.  Open the Mach4 motor tuning and make sure everything is correct.

 

 


G61 Exact Stop Mode and G64 Cutting (Constant Velocity or CV) Modes

Please click here to learn more about G61 Exact Stop Mode and G64 Cutting (Constant Velocity or CV) Modes.

 

 


How do I swap axes in Mach4?

You don't swap an axis in Mach4 (like you used to do in Mach3), you swap the motor using:

mcAxisMapMotor(...) OR

mcAxisUnmapMotor(...)

Be aware that swapping the motors may (will) lead to position jumps, loss, etc... Rarely can this be done on the fly.  The motor needs to be still and then the Spindle needs to be off (M5).

You will also want to remove the step/dir spindle flag with the OOB axis that is running the Step/Dir spindle with:

MACHAPI int MACH_APIENTRY mcAxisSetSpindle(MINSTANCE minst, int axisID, BOOL spindle);

 

This is a Mach4 feature that I am only listing here so you can search for it on the Mach forums.  The ESS will do what Mach4 tells it to do with this functionality, but I won't directly support end users getting this working on their installs. It is doable, but it is something to ask for help elsewhere to implement.

 


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.

Please see the Macros section here before making your own macro scripts.

 Mach4 MDI window

 

 

Also make sure that you have both Max RPM values set in the Mach4 Config window, spindle tab.

Mach4 Spindle Control

 

Logging Window


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.  If there is not a "Macros" folder in there, make one, and then Mach4 will be happy.

 


Selecting a Spindle RPM Source (Index or Encoder)

Here is the Spindle Configuration step in the Getting Started Guide.

You have to choices for your RPM selection source:

1) Spindle Index - This will give you a single pulse per revolution of your spindle shaft.  On a mill or router setup, this will usually be sufficient since you are running at hundreds or thousands of RPMs, and you are not relying on a precise RPM readings.  The exception to this would be if you were doing slow speed tapping.

2) Spindle Encoder A - this will allow you to read multiple pulses per revolution, with the pulses updating the RPM.  This is very useful for low RPM lathe threading, especially with heavier cuts.  The additional pulses per rev will tell the SmoothStepper what the instantaneous RPM is, and it will adjust the Z and X axis motion to compensate and deliver a quality threading pass.

  • You only need to hook up Spindle Encoder A for the RPM measurements to be made.  However, without the Spindle Encoder B channel hooked up, the encoder will just dither back and forth between values.  With the Spindle Encoder A and B channels hooked up, the encoder value will count up or down (depending on the rotational direction).
  • You would hook your encoder's A channel up to the Spindle Encoder A input; set the Pulses Per Rev to the number of encoder pulses per Rev (you may need to divide by 2 or 4).  If your Encoder has more than 1,000 or 10,000 pulses per prev, you should consider adding a RPM prescalar, so that the RPM updates are not too frequent.  If the pulses are too frequent, you may lose RPM resolution and/or stability.  Here is how you determine the best appropriate encoder prescalar.
  • If you are using your encoder to measure the spindle speed, and the encoder looks like it is counting up or down nice and smooth, but the calculated RPMs are jumping all over the place, the likely issue is electrical noise. The quadrature encoder with its A and B channels will be able to ignore the noise and count up or down correctly, although you may see it bounce repeatedly between (e.g.) 262 and 263 before it starts bouncing between 263 and 264.  However, the ESS is only looking at the A channel for it's RPM calculations, and every noise bounce on that signal input will count as an encoder pulse and cause a new RPM calculation with a period that was too short. In this situation, some noise filtering of 5 us, 10 us or 20 us will likely fix the issue so you can see stable RPM measurement - but you should still try and fix the root cause of the noise issue, not just ignore it in software.

Here is our recommendation on how to reduce VFD/spindle noise.

 

 


Spindle RPM Reporting and Averaging

All Mach4 does is display the RPM value reported by the ESS.

The ESS's FPGA collects the period values between pulses on the spindle index signal and sends the latest period measurement back every (1/plugin frequency) Hz. The ESS plugin will then average together 1 seconds worth of period measurements converted into RPM (if you have it set to the default 1 second of averaging in the ESS Config -> Spindle tab). If you want to see how bouncy the raw RPM value is, set the averaging time to (1/ ESS plugin frequency) we will just pass through the raw FPGA period measurements (converted into RPM), and it will get updated to the screenset DRO as the data comes in.  If the un-averaged values are bouncing around 26,000 RPM in a 25,900 RPM to 26,100 RPM range, that would be good clean signal. With 1 second averaging, a signal like this would be really nice and smooth in the DRO.

However, this is very much a Garbage in Garbage out operation.

For example, if the spindle is running at 26k RPM, and you see values of 55,000 112,000 26,000 180,000 70,000 RPM; (stuff that is total junk and way higher than what you want to see), in this case there is noise coupling into the spindle index signal and it is randomly causing the period to be much shorter than it should be, resulting in erroneously high and random RPM values. This would mean fix the wiring (preferred) or add in a smidge of noise filtering on the index pin signal (a good test but not the preferred solution).

Alternatively, the values could be 5,000 12,000 6,000 18,000 7,000 RPM, stuff that is total junk and way slower than what you expect to see. This means that the signals are coming in faster than the (low pass filter) electronics on the BOB will allow to pass through, or the index sensor isn't working properly. (Or it could be that the signal voltage or current is not sufficient to trigger transition on the BOB's input pins.) In either case, a bunch of index pulses are not reaching the ESS's FPGA so they can be measured

Throwing a scope on the index sensor output (at the BOB input pin) should tell you a lot about the signal and its quality.

 

 

 


Spindle PID

 

m2010 can be used to enable and disable PID form your GCode:
m2010(USE_SPINDLE_PID=1) This will allow you to turn spindle PID ON from your GCode.
m2010(USE_SPINDLE_PID=0)This will allow you to turn spindle PID OFF from your GCode.

 

Introduction to the SmoothStepper’s Spindle PID Speed Controller

Please read this page for more details regarding PID setup.

Here is the Spindle Configuration step in the Getting Started Guide.

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 = 0.0  Kd = 0.0 

For some lathes, Kp winds up at 10.0 to achieve a fairly tight window  (+/-3%) during a threading pass.   At this point you can then start to add in some Ki or Kd terms (starting at something like 0.3 for each) and slowly increasing them while doing air cuts or test cuts until you reach the performance required for your machine.  Each machine is unique and is dependent upon your hardware, materials and feeds.

 

Spindle Speed feedback for the PID is provided by the Spindle Index signal/pin or the Encoder A channel pin.

 

 PID Tuning

 

The rule of thumb with PID tuning is to have a high proportional (Kp) gain, only as much integral (Ki) gain as is necessary to secure 'zero following error' and just enough differential (Kd) gain to secure stability.

To achieve a tighter PID loop, you should go to the ESS Config -> General tab, and increase your Plugin Frequency to 60 Hz, 80 Hz or 100 Hz instead of the default 40 Hz.  If you go too high with the plugin frequency and your PC can't keep up, then you should back off a little bit. There is little benefit to exceeding 100 Hz.

 


Setting Up Step Dir Spindle as an OB axis.

While you can use an OB Step/Dir axis  to control your Spindle, I strongly recommend that you use a SS Motor setup for your spindle instead. Why?  There have been issues where a Step/Dir OB servo motor will clunk in OB Mode, which it will not do in SS Mode.

 

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 you should 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.

 

 

 


 

 

Additional OB Axes

Out of band axes are for controlling things like chip conveyors, stock feeders, carousel motors, etc...  They are not coordinated motion axes but instead are totally independent of other axes.  OOB axes use the scripting jog methods for motion and they can be homed.  So one can use incremental or absolute jogging for precise positioning.  Or velocity based jogs as a percentage of max velocity or feed per minute.  No G code will ever move one of these axes in coordination with any other axis.  Meaning that no axis letter can be assigned to them.

Contrary to the feature matrix on the website, the Hobby version has all 6 OOB axes available.  It was Mach4 Lite that was limited to only one OOB axis.  Obviously, one would need a motion controller that could control at least 12 motors to take advantage of every coordinated and OOB axis.

 

 


 

 

MODBUS Spindle Control

If you want to avoid 0V to 10V analog spindle speed control, you may use a USB to MODBUS or Ethernet to MODBUS converter (I would STRONGLY recommend the Ethernet versions since they keep your PC electrically isolated from your VFD and Spindle, since VFDs can create TONS of electrical noise).  In this case you would use the Mach4 MODBUS plugin, which is a separate plugin that is 100% outside of the ESS. 

In the ESS config on the spindle tab, set the ESS Spindle to be relay or none, and ignore the ESS from that point forward.

When you command spindle changes (S###, M3/M4/M5), the ESS will ignore those commands (the ESS might issue some log messages that we saw a change from Mach4 but the ESS will not change anything. The MODBUS plugin will see those same changes and then act on them, assuming you have it set up correctly.

In the MODBUS plugin for the spindle, you will need to set it up according to something like this guide by Billl Caldwell for MODBUS in Mach4.

Huanyang HY inverters do not have a standard MODBUS protocol. There are a few people whom have taken the time to work out the differences between what Huanyang have done and the MODBUS standard and have made a corrective plugin, but it is available for
Mach3 only (as far as I know).

The Huanyang GT series of inverters do comply to standard MODBUS protocols, so one of those is an option for standard MODBUS.

The CNC Zone Forums have a LOT of information regarding Spindles, VFDs and controlling them via MODBUS or analog.

 


 

 

Should I set my FRO above 100%?

No, never set your feed rate override (FRO) above 100%.  When you do this, Mach4 will attempt to use your existing GCode Feed Rate value and go faster than that. The problem is that your smaller moves will require a faster acceleration rate, and can exceed your acceleration rate in your motor tuning.   This may result in jerky movement or stalled motors (I have seen it plenty of times to know that it happens). 

If you want to move faster, it is best to regenerate your GCode with the higher Feed speed commanded or edit your GCode for the higher speed.  

You can always reduce your FRO value so that your machine will run slower. 

 


 

 

My motor squeals and does not move

When I hear a stepper motor squealing and not moving, I instantly think that the motor is being over commanded. This is typically seen on the Z axis not moving upwards, but it can happen to the X and Y axes especially when they are loaded down.

It can be either your acceleration rate and/or your max velocity that is causing the problem.  

Assuming that you were doing a normal G0 or G1 move.  Go into the Mach4 config, and then Motor tuning and go to motor 2 (if that is your Z motor) and try reducing your acceleration by 25% and the same for your max velocity.  Once you can get an axis working reliably working reliably, then you can increase the acceleration or the velocity until you start getting stalls.   I recommend you have your acceleration about 10% lower than where you start getting stalls.   Typically you will not notice a loss in acceleration as much as you would notice a loss in max speed.  If you do heavy cuts, acceleration will cause problems sooner than your max velocity.

If this was when you were doing a ref all home, then your Z axis (assuming it is your Z axis) approach velocity may be too high.  In that case reduce the homing approach velocity until the stalls go away.

As things get warmer, metal can expand and start binding up a little easier. If the acceleration rate is too high (or the max velocity) an axis can bind and stall.  This can happen on hot days or after you have been running a long time, if you have the acceleration or max velocity tuned too aggressively.

If you are using servo motors, it is also critical that you tune the servo motors if you have not, or they can stall.

Never use a feed rate over 100% in Mach, because that will mess up the acceleration parameters and that can cause stalls or jerking as well.

 


 

 

How do I tune my motors?

Go to Mach4's Menu -> Configure -> Control... Motors.

"Counts per unit" is the number of motor steps per Inch or steps per mm for the selected motor.  Your "Velocity" and "Acceleration" fields will be in the same inches or mm units as your "Counts Per Unit".

If you bought a rig from a manufacturer, they will most likely be able to tell you the value to enter into "Counts Per Unit".

The Steps per can also be calculated for any axis based on the following variables:

  • Micro Stepping (if any) in the motor driver
  • Degrees per step for your motor
  • Threads per inch on a lead screw
  • Any applicable gearing

However, the quicker and easier way is to measure the travel of an axis and calculate the "Steps per" based upon distance traveled with this Excel Sheet.

If an axis is moving, but it is not moving the distance you commanded, then the Counts Per Unit value is incorrect (or you have stalling because you have the acceleration set too high or the load is too heavy for the motors to move).  Lets assume this is the Z axis for the rest of the article, but it applies to any axis you deed to setup. You can change the Z axis Steps Per value and it will not have any affect on the other axes (although you should measure them too, just to make sure they are moving the correct distances also).

1) Bring your Z axis (or it's bit) down flush onto a block of wood.

2) Zero the Z DRO

3) Type the G0 Z1 or G0 Z-1 (whichever one will raise you above the wood.) on the MDI line and press Cycle Start.

4) Measure the distance traveled, and enter that into the Excel spreadsheet. Also enter in the distance commanded and the Counts Per unit (from the motor tuning section) into the Excel Spreadsheet.

5) If the distance commanded and the distance moved are not the same, the Excel Spreadsheet will tell you the new value you should be using for the Counts Per Unit value. Enter than value, and repeat these steps until the distance commanded is the distance moved.

 

Important notes:

  • The more accurately you measure the distance traveled, the more accurate your axis will be when you travel a commanded distance.
  • For your X and Y axes, try placing a small bit in your spindle and have it close to the surface of your ruler or work top (but not so close that it crashes).  The small point of your bit will let you make an accurate mark (with a pencil) on your worktop or to read your ruler accurately.
  • Start in the middle of your axis and only travel a tenth of an inch or so, just to get a ball park measurement.  On your first try, you will have no idea as to how many steps per inch you need, compared to what you are using;  A commanded 0.1" could result in a 20" move!  Make sure you can press the Stop or EStop button to prevent a crash, or get a rough value based off of jogging.
  • For your final, most accurate measurements, travel (measure) from about 1/2" (or 1 cm) in from one end of your axis to about 1/2" (or 1 cm) in from the other end of your axis.  Going almost the full length of the axis will reduce your measurement errors as much as you possibly can.

 


 

 

Homing and Limit Switch Setup and Issues

Homing input signals are only used during the homing process (like with Ref All Home), and the ESS will ignore all of the limit switch signals during the entire homing process.

Limit switch input signals are ignored during homing, but will prevent that axis's motion towards that limit switch, if that axis limit switch is active.

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.

 

Q: I tried to move axis but could only move them when limit switch override was engaged. Then I tried to home all axis but only Z tripped the limit switch and did not back off. Pressed Stop button then showed home complete. Message came up:
Back off any action home or limit switches, and then Ref, All Home Again.
You may need to press stop and then use Axis limit override button to jog.
Both ESS and Mach4 are set per setup guide.

 A: Jog your axes so that they are not touching any of your limit switches. Then in your screen set, switch to the diagnostics tab and look at the limit switches and see if Mach is showing that any/all of them are active. I'm willing to bet at least one of them is.

Open the ESS Config -> Pins tab, and then change the active high/low state for the limit switches that were showing active. Then press Okay to save, and then look at the screen set diagnostics tab again, and your limit switches should now be off.

Homing gets messed up (and won't back off) if your limit switches are at the opposite state of where they should be.

 


 

 

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

 For more information about this, please click here.

 


 

 

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

 

 

 


 

 

Parameter 1801 error

The Parameter 1801 error issue comes from upgrading an existing Mach installation when an old parameters.ini file was already there and it does not work with the new Mach build.

1) While Mach4 is closed, change parameter 1801 to something like -999999.99999   You must do this while Mach is shut down, otherwise that value will get overwritten when Mach closes. 

2) Don't mess with the permissions for the parameters.ini file.

 

 


 

 

Mach4 Input Signal Descriptions

ESS input pins should be named, and it is strongly recommended that you keep the {P#-**} naming scheme for the pins and add your alias after that, i.e. {P1-10} EStop. This makes it MUCH easier to identify the location of a pin and its functionality in an instant.

All ESS input pins are mapped to Mach4, and you can see them changing state in the inputs wizard.  This is sufficient for the Mach4 PMC to directly access the ESS input pins. Mach4 will produce a MSG_IO_CHAANGED message whenever the pin changes state.  However, this is not very useful for most of our core functionality.  So you will typically map an ESS input pin to one (or more) ESS input signals, which will then automatically map to the corresponding Mach4 input signal.  You should NEVER try to map SmoothStepper signals in the Mach4 Signal tabs, we will take care of that for you from the SmoothStepper plugin. When a mapped SmoothStepper signal changes, Mach4 will generate a MSG_SIG_CHANGED message.

The PMC uses plugin provided I/O in a polled manner only.

As of Mach4 build 5028+, the Mach4 signals tabs will allow you to enable or disable logging of signal change states on a per signal basis.   If you are asking for help with a log file, make sure all of the signals are being logged so we can see them changing in the log file (unless they are spamming the log file and totally irrelevant).

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.

 

Here are the home and limit switch signals for your motors:

  • Motor 0 ++ Limit:  Positive limit switch for Motor 0 (When active, this will stop all motor movement.)
  • Motor 1 ++ Limit:  Positive limit switch for Motor 1 (When active, this will stop all motor movement.)
  • Motor 2 ++ Limit:  Positive limit switch for Motor 2 (When active, this will stop all motor movement.)
  • Motor 3 ++ Limit:  Positive limit switch for Motor 3(When active, this will stop all motor movement.)
  • Motor 4 ++ Limit:  Positive limit switch for Motor 4 (When active, this will stop all motor movement.)
  • Motor 5 ++ Limit:  Positive limit switch for Motor 5 (When active, this will stop all motor movement.)
  • Motor 0 -- Limit:  Negative limit switch for Motor 0 (When active, this will stop all motor movement.)
  • Motor 1 - - Limit:  Negative limit switch for Motor 1 (When active, this will stop all motor movement.)
  • Motor 2 - - Limit:  Negative limit switch for Motor 2 (When active, this will stop all motor movement.)
  • Motor 3 - - Limit:  Negative limit switch for Motor 3 (When active, this will stop all motor movement.)
  • Motor 4 - - Limit:  Negative limit switch for Motor 4 (When active, this will stop all motor movement.)
  • Motor 5 - - Limit:  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. ESS Only.
  • Motor 1 Index:  If a rotational motor/axis or a servo motor (with index pin), this provides the precise rotational home. ESS Only.
  • Motor 2 Index:  If a rotational motor/axis or a servo motor (with index pin), this provides the precise rotational home. ESS Only.
  • Motor 3 Index:  If a rotational motor/axis or a servo motor (with index pin), this provides the precise rotational home. ESS Only.
  • Motor 4 Index:  If a rotational motor/axis or a servo motor (with index pin), this provides the precise rotational home. ESS Only.
  • Motor 5 Index:  If a rotational motor/axis or a servo motor (with index pin), this provides the precise rotational home. ESS Only.

 

Servo motors use encoders to know where they are, and they can (but do not need to) feed this information back into the ESS and Mach4/3.  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. These may be used for something else, by try to save them for the corresponding motor, for the sake of clarity.

  • 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 allow you to manually move a motor by spinning a MPG (Manual Pulse Generator) that feeds an A/B quadrature pulse signal into an encoder:

  • Aux Encoder 0 Phase A:  This general purpose encoder phase input is used with the phase B input.
  • Aux Encoder 0 Phase B:  This general purpose input is used with the phase A input.
  • Aux Encoder 1 Phase A:  This general purpose encoder phase input is used with the phase B input.
  • Aux Encoder 1 Phase B:  This general purpose input is used with the phase A input.
  • Aux Encoder 2 Phase A:  This general purpose encoder phase input is used with the phase B input.
  • Aux Encoder 2 Phase B:  This general purpose input is used with the phase A input.

 

 

  • Inhibit Jog:  When active, Mach4 will not Jog.
  • Inhibit MPG: When active, Mach4 will not respond to changes in the MPGs
  • 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.
  • Inhibit Motion:  When active, Mach4 will not generate motion.
  • No Wait:
  • Path Selection (Head):
  • Path Selection 2 (Head2):

 

These are Probe inputs:

  • Probe (G31 or G31.0):  Probe (or digitize) input for the G31 or G31.0 command
  • Probe 1 (G31.1):  Probe (or digitize) input for the G31.1 command
  • Probe 2 (G31.2):  Probe (or digitize) input for the G31.2 command
  • Probe 3 (G31.3):  Probe (or digitize) input for the G31.3 command

 

 Additional Spindle Input signals:

  • 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.
  • Spindle 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.)  The Spindle Encoder (above) can generate much more precise speed measurements at lower RPMs.

 

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 (Arc Okay):  This signals indicates that the plasma cutter's torch Arc is OK (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.

 

  • Tool Group Reset:
  • Tool Life Override:
  • Tool Retract:
  • Tool Skip:
  • User Interrupt:

 

 

These are for jogging motors:

  • 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.
  • Jog OB1 + : This will jog the OB1 axis in the (+) direction.
  • Jog OB1 - :  This will jog the OB1 axis in the (-) direction.
  • Jog OB2 + : This will jog the OB2 axis in the (+) direction.
  • Jog OB2 - :  This will jog the OB2 axis in the (-) direction.
  • Jog OB3+ :  This will jog the OB3 axis in the (+) direction.
  • Jog OB3 - :  This will jog the OB3 axis in the (-) direction.
  • Jog OB4+ :  This will jog the OB4 axis in the (+) direction.
  • Jog OB4 - :  This will jog the OB4 axis in the (-) direction.
  • Jog OB5+ :  This will jog the OB5 axis in the (+) direction.
  • Jog OB5 - :  This will jog the OB5 axis in the (-) direction.
  • Jog OB6+ :  This will jog the OB6 axis in the (+) direction.
  • Jog OB6 - :  This will jog the OB6 axis in the (-) direction.

There are 64 general purpose inputs.  A 32 bit integer maps General Purpose Inputs  #0 to #31 to #Vars #1000 to #1031:

  • Input #0:  General purpose input. #Var #1000
  • Input #1:  General purpose input. #Var #1001
  • ...
  • Input #31:  General purpose input. #Var #1031
  • Input #31:  General purpose input. Not mapped to a #Var
  • ...
  • Input #62:  General purpose input. Not mapped to a #Var
  • Input #63:  General purpose input. Not mapped to a #Var
  • This may increase to Input #255 for 256 inputs.

 


 

 

Mach4 Output Signal Descriptions

ESS output pins should be named, and it is strongly recommended that you keep the {P#-**} naming scheme for the pins and add your alias after that, i.e. {P1-4} Y Axis Primary, Motor 1 Step. This makes it MUCH easier to identify the location of a pin and its functionality in an instant.

Mach4 output signals need to map to an ESS output signal, which would then map to an ESS output in order to generate a change on an output pin.  ESS Only Output signals (like motors, PWMs and Charge Pumps) need to map to an ESS output pin in order to generate a change on an output pin.  You should NEVER try to map SmoothStepper signals in the Mach4 Signal tabs, we will take care of that for you automatically from the SmoothStepper plugin.

The PMC uses plugin provided I/O in a polled manner only.

As of Mach4 build 5028+, the Mach4 signals tabs will allow you to enable or disable logging of signal change states on a per signal basis.   If you are asking for help with a log file, make sure all of the signals are being logged so we can see them changing in the log file (unless they are spamming the log file and totally irrelevant).

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 5 Dir,  Motor 5 CCW or Motor 5 Quad B

Any motor (0 through 5) may be assigned to any Mach4 axis (X, Y, Z, A/U, B/V, C/W, OB1, OB2, OB3, OB4, OB5 or OB6).

 

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.

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

 

Laser Related Outputs:

  • Laser PWM/XY Velocity PWM: This is the PWM output to run a laser or generate an XY Velocity PWM signal.
  • Laser On:

Spindle related outputs.

  • Spindle Step or 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 Direction:  This output retains the current spindle motor 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).
  • Spindle Speed Check: Set to wait for the spindle speed to be stable.
  • Spindle Rate Override: Shows that this is active
  • Spindle Rate Override Disabled:
  • SRO Not Allowed: This says that the Spindle Rate Override is not allowed.

 

Misc outputs:

  • Alarm:
  • Charge Pump:  This output provides a 12.5 kHz signal when active, so external hardware knows that Mach4 and the ESS are running.
  • Compressed Air On
  • Coolant, Flood (M08, M09):  This output activates the Flood Coolant with M08 and shuts it off with M09.
  • Coolant, Mist (M07, M09):  This output activates the Mist Coolant with M07 and shuts it off with M09.
  • Current Hi/Low: This output activates to change a drive from low current to high current mode, for upcoming motion.
  • Cut Recovery: Cut Recovery Signal
  • Digitize Trigger:  This output activates when the Probe is active with a G31/G31.x command.
  • 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).
  • Dwell: This output activates while a G4 Dwell command is active.
  • ESS, Is Moving: This output activates when motion is being generated by Mach4 and the ESS.
  • ESS, XY Feed Rate PWM: Used for Height Control to show the current percentage of actual vs commanded feed rate.
  • Feed Hold:  This output activates when Feed Hold is active.
  • F.H. Not Allowed
  • Feed Hold Disabled
  • Feed Rate Override
  • Feed Rate Override Disabled
  • FRO Not Allowed
  • G-Code Running:  This output activates when G-Code is running (typically used for an indicator light).
  • GCode Complete
  • Jog Cont: This output activates when jogging is set to continuous jog mode.
  • Jog Enabled: This output activates when jog mode is enabled.
  • Jog Inc: This output activates when jogging is set to incremental jog mode.
  • Jog MPG:  This output activates when jogging is set to Manual Pulse Generator (MPG) jog mode (from a pendant or similar device).
  • Limit Override:   This output activates when the Limit Override is active.
  • 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).
  • Machine Enabled: This output activates when the machine is enabled.
  • Machine Idle:
  • Machine Probing:
  • Nitrogen On:
  • Oxygen On:
  • Parts Finished: This output activates when the G-Code finishes running, and the parts are finished.

 

  • Rapid Rate Override:
  • Retract Signal:
  • Run Ops - Block Delete:  This output activates when Block Delete is active.
  • Run Ops - Opt Stop (M01): This output activates when optional stop is active (when a G-Code file calls M01).
  • Run Ops - Reverse Run: This output activates when Reverse Run is active.  (This runs a G-Code file backwards.)
  • Run Ops - Single Block:  This output activates when Single Block is active.

 

  • Shutter On:
  • Soft limits On: This output activates when soft limits are active.
  • Tool path Mouse Down: This output toggles when the tool path 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 Tool path capture mode.
  • Tool Change:  This output activates when an automatic tool change is occurring, or while a manual tool change is waiting for a Cycle Start.
  • Tool Change B:
  • User Interrupt: Shows that it is active.
  • Waiting On Tool Signal

 

 

  • X ++ switch active:  Activated when one of the motors that makes up the X axis has a positive limit switch pressed.
  • X - - switch active:  Activated when one of the motors that makes up the X axis has a negative limit switch pressed.
  • X Home switch active:  Activated when one of the motors that makes up the X axis has a Home switch pressed.
  • X Axis is Homed: This will be active as long as the axis has been homed successfully.
  • Moving Axis X: The axis is in motion.

 

  • Y ++ switch active:  Activated when one of the motors that makes up the Y axis has a positive limit switch pressed.
  • Y - - switch active:  Activated when one of the motors that makes up the Y axis has a negative limit switch pressed.
  • Y Home switch active:  Activated when one of the motors that makes up the Y axis has a Home switch pressed.
  • Y Axis is Homed: This will be active as long as the axis has been homed successfully.
  • Moving Axis Y: The axis is in motion.

 

  • Z ++ switch active:  Activated when one of the motors that makes up the Z axis has a positive limit switch pressed.
  • Z - - switch active:  Activated when one of the motors that makes up the Z axis has a negative limit switch pressed.
  • Z Home switch active:  Activated when one of the motors that makes up the Z axis has a Home switch pressed.
  • Z Axis is Homed: This will be active as long as the axis has been homed successfully.
  • Moving Axis Z: The axis is in motion.

 

  • A/U ++ switch active:  Activated when one of the motors that makes up the A axis has a positive limit switch pressed.
  • A/U - - switch active:  Activated when one of the motors that makes up the A axis has a negative limit switch pressed.
  • A/U Home switch active:  Activated when one of the motors that makes up the A axis has a Home switch pressed.
  • A/U Axis is Homed: This will be active as long as the axis has been homed successfully.
  • Moving Axis A: The axis is in motion.

 

  • B/V ++ switch active:  Activated when one of the motors that makes up the B axis has a positive limit switch pressed.
  • B/V - - switch active:  Activated when one of the motors that makes up the B axis has a negative limit switch pressed.
  • B/V Home switch active:  Activated when one of the motors that makes up the B axis has a Home switch pressed.
  • B/V Axis is Homed: This will be active as long as the axis has been homed successfully.
  • Moving Axis B: The axis is in motion.

 

  • C/W ++ switch active:  Activated when one of the motors that makes up the C axis has a positive limit switch pressed.
  • C/W - - switch active:  Activated when one of the motors that makes up the C axis has a negative limit switch pressed.
  • C/W Home switch active:   Activated when one of the motors that makes up C the axis has a Home switch pressed.
  • C/W Axis is Homed: This will be active as long as the axis has been homed successfully.
  • Moving Axis C: The axis is in motion.

 

  • OB1 ++ switch active:  Activated when one of the motors that makes up the OB1 axis has a positive limit switch pressed.
  • OB1 - -  switch active:  Activated when one of the motors that makes up the OB1 axis has a negative limit switch pressed.
  • OB1 Home switch active:  Activated when one of the motors that makes up the OB1 axis has a Home switch pressed.
  • Homed OB1
  • Moving Axis OB1: The axis is in motion.

 

  • OB2 ++ switch active:  Activated when one of the motors that makes up the OB2 axis has a positive limit switch pressed.
  • OB2 - - switch active:  Activated when one of the motors that makes up the OB2 axis has a negative limit switch pressed.
  • OB2 Home switch active:  Activated when one of the motors that makes up the OB2 axis has a Home switch pressed.
  • Homed OB2
  • Moving Axis OB2: The axis is in motion.

 

  • OB3 ++ switch active:  Activated when one of the motors that makes up the OB 3axis has a positive limit switch pressed.
  • OB3 - - switch active:  Activated when one of the motors that makes up the OB3 axis has a negative limit switch pressed.
  • OB3 Home switch active:  Activated when one of the motors that makes up the OB3 axis has a Home switch pressed.
  • Homed OB3
  • Moving Axis OB3: The axis is in motion.

 

  • OB4 ++ switch active:  Activated when one of the motors that makes up the OB4 axis has a positive limit switch pressed.
  • OB4 - - switch active:  Activated when one of the motors that makes up the OB4 axis has a negative limit switch pressed.
  • OB4 Home switch active:  Activated when one of the motors that makes up the OB4 axis has a Home switch pressed.
  • Homed OB4
  • Moving Axis OB4: The axis is in motion.

 

  • OB5 ++ switch active:  Activated when one of the motors that makes up the OB5 axis has a positive limit switch pressed.
  • OB5 - - switch active:  Activated when one of the motors that makes up the OB5 axis has a negative limit switch pressed.
  • OB5 Home switch active:  Activated when one of the motors that makes up the OB5 axis has a Home switch pressed.
  • Homed OB5
  • Moving Axis OB5: The axis is in motion.

 

  • OB6 ++ switch active:  Activated when one of the motors that makes up the OB6 axis has a positive limit switch pressed.
  • OB6 - - switch active:  Activated when one of the motors that makes up the OB6 axis has a negative limit switch pressed.
  • OB6 Home switch active:  Activated when one of the motors that makes up the OB6 axis has a Home switch pressed.
  • Homed OB6
  • Moving Axis OB6: The axis is in motion.

 

  • Cut Recovery: The Cut Recovery Signal
  • Speed Check: Set to wait for the spindle speed to be stable
  • Machine Idle: High when in the idle state
  • Machine Probing: High when in the probing state
  • Feed Hold Disabled
  • Feed Rate Override Disabled
  • Spindle Rate Override Disabled
  • Rapid Rate Override
  • Spindle Rate Override
  • Feed Rate Override

 

There are 64 general purpose outputs.  A 32 bit integer maps General Purpose Outputs  #0 to #31 to #Vars #1100 to #1131

  • Output #0:  General purpose output. #Var #1100
  • Output #1:  General purpose output. #Var #1101
  • ...
  • Output #31:  General purpose output. #Var #1131
  • Output #31:  General purpose output. Not mapped to a #Var
  • ...
  • Output #62:  General purpose output. Not mapped to a #Var
  • Output #63:  General purpose output. Not mapped to a #Var
  • This may increase to Output #255 for 256 outputs.

 

 


 

 

Pound Vars, #Var or Local Vars

Stack based local vars, 1 through 99.  Only the first 26 (starting with 1) are used:

  • A = 1
  • B = 2
  • ...
  • Y = 25
  • Z = 26

Common vars (cleared on startup), 100 through 199.

Common vars (retained across startups), 200 through 599.

Input signal shadows (read only), 1000 through 1099.  Only the first 32 are used:

  • Input #0:  General purpose input. #Var #1000
  • Input #1:  General purpose input. #Var #1001
  • ...
  • Input #31:  General purpose input. #Var #1031

Output signal shadows (read/write), 1100 through 1199.  Only the first 32 are used:

  • Output #0:  General purpose output. #Var #1100
  • Output #1:  General purpose output. #Var #1101
  • ...
  • Output #31:  General purpose output. #Var #1131

 

FRO_ON_OFF                   1227  FRO On or Off
CUR_DIA_INDEX                1228  Current Dia number (D)
CUR_TOOL_NUMBER              1229  Current tool number (T)
CUR_SELECTED_TOOL            1231  Current tool that is selected (Next T number)
CUR_LENGTH_INDEX             1232  Current Length number (H)
CUR_TOOL_XLENGTH_REGISTER    1233
CUR_TOOLDIA_REGISTER         1234  Register for the amount of tool dia offset
CUR_TOOL_ZLENGTH_REGISTER    1235
CUR_TOOL_YLENGTH_REGISTER    1236
CURRENT_TIP                  1237  Tool tip direction in Lathe mode for Tip Comp

CUR_CSS_LIMIT             1240
CUR_SPINDLE_SFPM       1241
CUR_SPINDLE_SPEED     1242
TRAVERSE_RATE           1243  Rate for traverse motions
FEEDRATE                     1244  Feed rate in current units/min
ROTATION_X                 1245
ROTATION_Y                 1246
ROTATION                     1247

MILL_Z_WEAR_START      2001  #2001-#2200 shadows #10001-#10200 Tool 1-200 height wear offset.
MILL_Z_WEAR_END          2200
MILL_Z_GEOM_START       2201  #2201-#2400 shadows #11001-#11200 Tool 1-200 height offset.
MILL_Z_GEOM_END           2400

WORK_SHIFT2_X              2500  Shadows 5201.
WORK_SHIFT2_Y              2600  Shadows 5202.
WORK_SHIFT2_Z              2700  Shadows 5203.
WORK_SHIFT2_A              2800  Shadows 5204.
WORK_SHIFT2_B              2900  Shadows 5205.
FIXTURE_G54_X                2501  Shadows 5221.
FIXTURE_G54_Y                2601  Shadows 5222.
FIXTURE_G54_Z                2701  Shadows 5223.
FIXTURE_G54_A                2801  Shadows 5224.
FIXTURE_G54_B                2901  Shadows 5225.
FIXTURE_G55_X                2502  Shadows 5241.
FIXTURE_G55_Y                2602  Shadows 5242.
FIXTURE_G55_Z                2702  Shadows 5243.
FIXTURE_G55_A                2802  Shadows 5244.
FIXTURE_G55_B                2902  Shadows 5245.
FIXTURE_G56_X                2503  Shadows 5261.
FIXTURE_G56_Y                2603  Shadows 5262.
FIXTURE_G56_Z                2703  Shadows 5263.
FIXTURE_G56_A                2803  Shadows 5264.
FIXTURE_G56_B                2903  Shadows 5265.
FIXTURE_G57_X                2504  Shadows 5281.
FIXTURE_G57_Y                2604  Shadows 5282.
FIXTURE_G57_Z                2704  Shadows 5283.
FIXTURE_G57_A                2804  Shadows 5284.
FIXTURE_G57_B                2904  Shadows 5285.
FIXTURE_G58_X                2505  Shadows 5301.
FIXTURE_G58_Y                2605  Shadows 5302.
FIXTURE_G58_Z                2705  Shadows 5303.
FIXTURE_G58_A                2805  Shadows 5304.
FIXTURE_G58_B                2905  Shadows 5305.
FIXTURE_G59_X                2506  Shadows 5321.
FIXTURE_G59_Y                2606  Shadows 5322.
FIXTURE_G59_Z                2706  Shadows 5323.
FIXTURE_G59_A                2806  Shadows 5324.
FIXTURE_G59_B                2906  Shadows 5325.

ALM                          3000  W: Writing to this var will produce a machine alarm.
CLOCK1                       3001  R/W: Millisecond timer, set to 0 when the machine is powered on.  Can be reset to any value.
CLOCK2                       3002  R: Accumulated time, in hours, of the machine.  (Hour Meter)
CNTL1                        3003  R/W: bit 0 high suppresses single block (default == not set), bit 1 high suppresses waits on MST codes (default == not set).
M_SBK                        0x01
M_MST                        0x02
M_FIN                        0x02  Same as SV_M_MST.
CNTL2                        3004  R/W: bit 0 high disables feed hold (default == not set), bit 1 high disables FRO (default == not set), bit 2 high enables exact stop (default == not set).
M_FHD                        0x01     
M_OV                         0x02
M_EST                        0x04
SETDT                        3005  R/W: Settings Data (bit 2 = 0 Inch, bit 2 = 1 Metric)
MSGSTP                       3006  W: Writing to this var will produce a machine stop.
MRIMG                        3007  R: Status of Mirror Image.
PRSTR                        3008  R: Program restart (0 or 1)
DEFAULT_UNITS                3005  Same as SV_SETDT R/W: (bit 2 = 0 Inch, bit 2 = 1 Metric)
DATE                         3011  R: Current Date (YYYYMMDD)
TIME                         3012  R: Current Time (HHMMSS)

EMPTY                        3100  R: returns NIL
PI                           3101  R: returns pi. (3.14159265358979323846)
BASE_LOG_E                   3102  R: returns base of natural logarithm E. (2.71828182845904523536)
MSTATE                       3103  R: returns the machine state.

PRTSA                        3901  R/W: Total number of parts machined for the file.  (cleared on file load).
PRTSN                        3902  R/W: Number of required parts
PRTST                        3903  R/W: Total number of parts machined for the machine.

The following modal information variables are read only.
MAINO                        4000  Main program number.
MOD_GROUP_1                  4001  Group 1  active G-code for motion
MOD_GROUP_2                  4002  Group 2  active plane, XY-, YZ-, or XZ- plane
MOD_GROUP_3                  4003  Group 3  absolute or incremental
MOD_GROUP_4                  4004  Group 4  arc center mode
MOD_GROUP_5                  4005  Group 5  G93 (inverse time) or G94 units/min
MOD_GROUP_6                  4006  Group 6  millimeters or inches
MOD_GROUP_7                  4007  Group 7  current cutter compensation side
MOD_GROUP_8                  4008  Group 8  tool length offset
MOD_GROUP_9                  4009  Group 9  canned cycles
MOD_GROUP_10                 4010  Group 10  for cycles, old_z or r_plane
MOD_GROUP_11                 4011  Group 11  scale mode
MOD_GROUP_12                 4012  Group 12  modal macro (G66,G66.1,G67)
MOD_GROUP_13                 4013  Group 13  spindle mode
MOD_GROUP_14                 4014  Group 14  coordinate systems
MOD_GROUP_15                 4015  Group 15  exact path or cutting mode
MOD_GROUP_16                 4016  Group 16  coordinate system rotation mode
MOD_GROUP_17                 4017  Group 17  polar mode
MOD_GROUP_18                 4018  Group 18  compensation mode
MOD_GROUP_19                 4019  Group 19  not used
MOD_GROUP_20                 4020  Group 20  not used
MOD_GROUP_21                 4021  Group 21  not used
MOD_GROUP_22                 4022  Group 22  not used
MOD_GROUP_23                 4023  Group 23  not used
MOD_GROUP_24                 4024  Group 24  not used
MOD_GROUP_25                 4025  Group 25  not used
MOD_GROUP_26                 4026  Group 26  not used
MOD_GROUP_27                 4027  Group 27  not used
MOD_GROUP_28                 4028  Group 28  not used
MOD_GROUP_29                 4029  Group 29  not used
MOD_GROUP_30                 4030  Group 30  not used

M_MOD_GROUP_1                4031  M Code Modal Group 1  not used
M_MOD_GROUP_2                4032  M Code Modal Group 2  not used
M_MOD_GROUP_3                4033  M Code Modal Group 3  not used
M_MOD_GROUP_4                4034  M Code Modal Group 4  stopping, and specialized m codes. (m0,m1,m2,m30,m60)
M_MOD_GROUP_5                4035  M Code Modal Group 5  I/O on and off. (m62,m63,m64,m65,m66,m29)
M_MOD_GROUP_6                4036  M Code Modal Group 6  tool change. (m6)
M_MOD_GROUP_7                4037  M Code Modal Group 7  spindle. (m3,m4,m5)
M_MOD_GROUP_8                4038  M Code Modal Group 8  coolant. (m7,m8,m9)
M_MOD_GROUP_9                4039  M Code Modal Group 9  feed and speed override switch bypass. (m48,m49)

TC_SPINDLE_POS               4077  Encoder position to orient to for tool changes (from marker pos == 0).

BUFB                         4102  last buffered B code value.
BUFD                         4107  last buffered D code value.
BUFE                         4108  last buffered E code value.
BUFF                         4109  last buffered F code value.
BUFH                         4111  last buffered H code value.
BUFM                         4113  last buffered M code value.
BUFN                         4114  last buffered N code value.
BUFO                         4115  last buffered O code value.
BUFS                         4119  last buffered S code value.
BUFT                         4120  last buffered T code value.
BUFP                         4130  last buffered P code value.

ORIGIN_OFFSET_X              4140
ORIGIN_OFFSET_Y              4141
ORIGIN_OFFSET_Z              4142
ORIGIN_OFFSET_A              4143
ORIGIN_OFFSET_B              4144
ORIGIN_OFFSET_C              4145

LAST_OUTPUT_X                5001
LAST_OUTPUT_Y                5002
LAST_OUTPUT_Z                5003
LAST_OUTPUT_A                5004
LAST_OUTPUT_B                5005
LAST_OUTPUT_C                5006

CURRENT_MACH_X               5021
CURRENT_MACH_Y               5022
CURRENT_MACH_Z               5023
CURRENT_MACH_A               5024
CURRENT_MACH_B               5025
CURRENT_MACH_C               5026

AXIS_OFFSET_X                5030  Used to save the offset with the G92.3 command
AXIS_OFFSET_Y                5031
AXIS_OFFSET_Z                5032
AXIS_OFFSET_A                5033
AXIS_OFFSET_B                5034
AXIS_OFFSET_C                5035

CURRENT_ABS_X                5041
CURRENT_ABS_Y                5042
CURRENT_ABS_Z                5043
CURRENT_ABS_A                5044
CURRENT_ABS_B                5045
CURRENT_ABS_C                5046

G92_OFFSET_X                 5050  Used to save the offset with the G92.3 command
G92_OFFSET_Y                 5051
G92_OFFSET_Z                 5052
G92_OFFSET_A                 5053
G92_OFFSET_B                 5054
G92_OFFSET_C                 5055

PROBE_POS_X                  5061  G31 Skip position
PROBE_POS_Y                  5062
PROBE_POS_Z                  5063
PROBE_POS_A                  5064
PROBE_POS_B                  5065
PROBE_POS_C                  5066

PROBE_MACH_POS_X             5071  G31 Skip machine position
PROBE_MACH_POS_Y             5072
PROBE_MACH_POS_Z             5073
PROBE_MACH_POS_A             5074
PROBE_MACH_POS_B             5075
PROBE_MACH_POS_C             5076

HEAD_SHIFT_X                 5081
HEAD_SHIFT_Y                 5082
HEAD_SHIFT_Z                 5083
HEAD_SHIFT_A                 5084
HEAD_SHIFT_B                 5085
HEAD_SHIFT_C                 5086

G76 Turn Registers
G76_MIN_PASS_DEPTH           5140
G76_FINISH_DEPTH             5141
G76_FINISH_PASSES             5142
G76_THREAD_ANGLE             5143
G76_CHAMFER_AMOUNT           5144
G76_CUTTING_METHOD           5145

CUR_COMP_X                   5157  Program x, used when cutter comp on
CUR_COMP_Y                   5158  Program y, used when cutter comp on
CUR_COMP_Z                   5159  Program z, used when cutter comp on

G_30_XPOS                    5181
G_30_YPOS                    5182
G_30_ZPOS                    5183
G_30_APOS                    5184
G_30_BPOS                    5185
G_30_CPOS                    5186

WORK_SHIFT_X                 5201
WORK_SHIFT_Y                 5202
WORK_SHIFT_Z                 5203
WORK_SHIFT_A                 5204
WORK_SHIFT_B                 5205
WORK_SHIFT_C                 5206


106    Max Fixtures,  G54 to G59 + G54.1 P1 to G54.1 P100:
FIXTURE_G54                  5221  5221- 5226 1st axis to 6th axis
FIXTURE_G55                  5241  5241- 5246 1st axis to 6th axis
FIXTURE_G56                  5261  5261- 5266 1st axis to 6th axis
FIXTURE_G57                  5281  5281- 5286 1st axis to 6th axis
FIXTURE_G58                  5301  5301- 5306 1st axis to 6th axis
FIXTURE_G59                  5321  5321- 5326 1st axis to 6th axis

FIXTURE_G541P1               7001  7001- 7006 1st axis to 6th axis
FIXTURE_G541P2               7021  7021- 7026 1st axis to 6th axis
...
FIXTURE_G541P48              7941  7941- 7946 1st axis to 6th axis
FIXTURE_G541P49              7961  7961- 7966 1st axis to 6th axis
FIXTURE_G541P50              7981  7981- 7986 1st axis to 6th axis

FIXTURE_EXPAND2              8001  Fixtures G54.1 P51 to G54.1 P100
FIXTURE_G541P51              8001  8001- 8006 1st axis to 6th axis
FIXTURE_G541P52              8021  8021- 8026 1st axis to 6th axis
...
FIXTURE_G541P99              8961  8961- 8966 1st axis to 6th axis
FIXTURE_G541P100             8981  8981- 8986 1st axis to 6th axis


G_30_P2_XPOS                 5351
G_30_P2_YPOS                 5352
G_30_P2_ZPOS                 5353
G_30_P2_APOS                 5354
G_30_P2_BPOS                 5355
G_30_P2_CPOS                 5356

G_30_P3_XPOS                 5361
G_30_P3_YPOS                 5362
G_30_P3_ZPOS                 5363
G_30_P3_APOS                 5364
G_30_P3_BPOS                 5365
G_30_P3_CPOS                 5366

G_30_P4_XPOS                 5371
G_30_P4_YPOS                 5372
G_30_P4_ZPOS                 5373
G_30_P4_APOS                 5374
G_30_P4_BPOS                 5375
G_30_P4_CPOS                 5376

WAIT_RESULT                  5399

ROTATION_G68_NO_R            5410

APPROACH_DIST_X              5440  Approach distance for the G60 Unidirectional approach command
APPROACH_DIST_Y              5441
APPROACH_DIST_Z              5442
APPROACH_DIST_A              5443
APPROACH_DIST_B              5444
APPROACH_DIST_C              5445

Tool Compensation system variable locations, 10000 through 20000.  Fanuc Tool Comp Memory C.  Tools limited to MC_TOOLS_MAX
MILL_LEN_COMP                MTOOL_MILL_HEIGHT      #11001-#11999 Tool 1-999 height offset.
MILL_LEN_WEAR                MTOOL_MILL_HEIGHT_W    #10001-#10999 Tool 1-999 height wear offset.
MILL_DIA_COMP                MTOOL_MILL_DIA         #13001-#13999 Tool 1-999 dia offset.
MILL_DIA_WEAR                MTOOL_MILL_DIA_W       #12001-#12999 Tool 1-999 dia wear offset.
MILL_X_COMP                  MTOOL_MILL_X           #15001-#15999 Tool 1-999 x offset.
MILL_X_WEAR                  MTOOL_MILL_X_W         #14001-#14999 Tool 1-999 x wear offset.
MILL_Y_COMP                  MTOOL_MILL_Y           #19001-#19999 Tool 1-999 y offset.
MILL_Y_WEAR                  MTOOL_MILL_Y_W         #17001-#17999 Tool 1-999 y wear offset.
MILL_POCKET                  MTOOL_MILL_POCKET      #18001-#18999 Tool 1-999 pocket.

LATHE_X_COMP                 MTOOL_LATHE_X          #15001-#15999 Tool 1-999 x offset.
LATHE_X_WEAR                 MTOOL_LATHE_X_W        #10001-#10999 Tool 1-999 x wear offset.
LATHE_Y_COMP                 MTOOL_LATHE_Y          #19001-#19999 Tool 1-999 y offset.
LATHE_Y_WEAR                 MTOOL_LATHE_Y_W        #14001-#14999 Tool 1-999 y wear offset.
LATHE_Z_COMP                 MTOOL_LATHE_Z          #11001-#11999 Tool 1-999 z offset.
LATHE_Z_WEAR                 MTOOL_LATHE_Z_W        #16001-#16999 Tool 1-999 z wear offset.
LATHE_NOSE_COMP              MTOOL_LATHE_TIPRAD     #17001-#17999 Tool 1-999 nose radius offset.
LATHE_NOSE_DIR               MTOOL_LATHE_TIPDIR     #12001-#12999 Tool 1-999 nose direction.
LATHE_IMAG_POS               MTOOL_LATHE_IMAG_POS   #13001-#13999 Tool 1-999 imaginary position.
LATHE_TOOLSLIDE              MTOOL_LATHE_TOOLSLIDE  #18001-#18999 Tool 1-999 axis slide.


 

 

Lua Errors in Mach4

In Mach4 builds 4999+, you may see a Trace error when you open your profile. This is likely because the screen se is calling for "C:\Mach4Hobby\Modules\trace.luac" which is not called mcTrace. Either add Trace.luac to that folder or change your screen set you use mcTrace instead.

 

Missing Lua Trace module

If you see popup messages with the word Trace in them, or you receive strange error messages when you load the screenset, you may be missing lua's required "Trace.luac" module.  Download it from here and save it into your "C:\Mach4Hobby\Modules\" folder, and then restart Mach4.  This should fix your error.  We have updated the v3 Laser screenset to point to the new mcTrace functions instead of Trace.  The new version is 3.5 and is identical to v3.0 except for the function call names.  We're not sure which version of Mach this change occurred.

LuaTraceError.png

 

 

 

 

"Lua: Error occurred while opening file. Cannot open "C:\Mach4Hobby\Profiles\YOUR PROFILE NAME\Macros\mcLua.mcc:" No such file or directory".

Close Mach4, and then go into your "C:\Mach4Hobby\Profiles\YOUR PROFILE NAME\Macros\" folder.  Delete all of the *.mcc files (complied lua script files) in that folder.  The next time you start Mach4, it will automatically recompile all of your scripts (*.mcs) and generate new *.mcc files.

 

 

"Lua: Error while running chunk"

If you just upgraded Mach4, from 4092 (or earlier to the new lua build, then that is your problem.  Or if Mach4 upgrades to a version newer than lua 5.3 that would be your problem.   See the next topic, Lua Build Changes for how to delete the *.mcc files.

However this error message can also indicate that you have a coding mistake in your macro (likely the last one you were working on) or in your screen set lua code there is a mistake.

Before you modify your screen set, you should really make a backup copy of your screen set (or your entire C:\Mach4Hobby\ folder before you do any of this, just in case you make a mistake!  That way you can revert easily!

Before you modify your macros, you should really make a backup copy of your macros (or your entire C:\Mach4Hobby\ folder before you do any of this, just in case you make a mistake!  That way you can revert easily!

 

Lua Build Changes

Mach4 build 4092 marked the transition from lua 5.2 to lua 5.3.  This will affect ALL compiled scripts.

If you are using a profile or scrips created BEFORE Mach4 Build 4092, and using a Mach4 build later than that (or the other way around) you should:

1. Make a backup copy of your entire "C:\Mach4Hobby\" folder and keep it in a safe place. 

2. Open "C:\Mach4Hobby\Profiles\" and then perform a search for  "*.mcc" in that folder and below. 

3. Delete all of the *.mcc files that are found.  When you open Mach4 the next time it will recompile all of the scripts.

 

 


 

 

Lua Code to Save to a File

Here is some handy lua code that will create a new file and pop up a message box where you enter the desired feed rate.

Just add the function to screen load script and call the function from a button:

function CreateNewTeach()

local MyNum = wx.wxGetNumberFromUser("Select or enter a feed rate", "Feed Rate:", "Teach Feed Rate", 50, 1, 1500) --Default, min, max
local MyGcode = string.format("(File created using CreateNewTeach function)\nF%0.4f", MyNum)
local Teach = wx.wxGetCwd() .. "\\GcodeFiles\\Teach.tap" --Define the file name and location
file = io.open(Teach, "w+") --Open the file in update mode, all previous data is erased
--file = io.open(Teach, "a+") --Append update mode, previous data is preserved, writing is only allowed at the end of file.
file:write (MyGcode) --Write the Gcode file
file:flush (Teach) --Save written data
file:close (Teach) --Close file
end

 

 


Mach4 Macros

You should really make sure you read and understand the "C:\Mach4Hobby\Docs\Mach4 Scripting Manual.pdf" before you start writing or modifying macros.  The information below should be considered more current than the 2022 version of the manual.

I have some other macro information and examples here, and the other pages at that level.  And another page here.

I also have another macro page here, that will help inform you about common macros.

Mach4 has core macros where it does everything internally, without a lua script.mcs file.  These macros are:

  • m03
  • m04
  • m05
  • m07
  • m08
  • m09
  • m62
  • m63
  • m64
  • m65
  • m66
  • m67
  • m68

You can REPLACE the functionality of those stock M codes with a lua macro, but you have better know what you are doing and provide ALL of the functionality in your replacement script.

Functionality can be supplemented with the following scripts (your script would run BEFORE the stock actions happen in Mach4 core):

  • m00
  • m01
  • m02
  • m29
  • m46
  • m48
  • m49
  • m96
  • m97
  • m98
  • m99

m30 is a special M code.  It will first do some stock actions:
1. Turn off any G92 offsets
2. Clear the programmed X, Y, Z, A, B, C positions.

And then if the m30 script exists, it replaces
1.  Stop Spindle
2.  Cancel Cutter Comp
3.  Stop Mist
4.  Stop flood coolant

Following that, the following stock actions are done:
1. Program End
2. Rewind

m47 is a throwback to Mach3 and is essentially deprecated now. In Mach4 build 5000 and earlier it runs the m1047.mcs script, if it exists, and then restarts the GCode program.  Now, (above Mach4 5000), it only runs the m47.mcs file if it exists.

M codes m10 through m99 (inclusive), not listed above, are also available for scripting and do not have stock functionality inside Mach4 core.

M codes numbered m100 up to m9999 have no Mach4 core stock functionality, and are available for you to use. 

There are two additional special macros:

  • For the Spindle Speed S parameter, you may have a custom spindlespeed.mcs script.
  • For the Tool Change T parameter, you may have a custom t.mcs script.

 

You can write your own macros (M codes), and store them in your profile's Macros folder, "C:\Mach4Hobby\Profiles\YOUR_PROFILE_NAME\Macros\". All macros in this folder must be uniquely numbered.  All macro file names and m#s should be lowercase only, NEVER UPPER CASE.  This goes for your file name and inside the script.  Upper or lowercase does not matter in the GCode itself though.

Please read the next article to see our special SmoothStepper macros.


Special SmoothStepper Macros

Mach4 works great at processing GCode, but it doesn't provide a clean and direct way to get information into the ESS.  The way we work around this is by using special macro commands to pump (comment) information into the ESS's registers where it can be processed by the ESS's plugin.  In order to do this, it is recommended that you break the GCode with a G04 P0.5 pause before and after each (group) of these commands.   (If these commands are at the beginning of a GCode file, then you don't need a pause beforehand.)  Why do we need the pause?  It is so that these changes will not affect commands currently in the motion buffer, and that any new commands going into the buffer will utilize these processed commands.

These macros (or any macros you want to use), MUST be in you C:\Mach4Hobby\Profiles\YOUR_PROFILE_NAME\Macros\ folder if they are to work.   If your Mach4 folder structure is different, adjust accordingly.

Macro commands that pass data through the (...) field in GCode, only work in GCode, not MDI!

Here is a list of the supported macros:

 

New in ESS285, temporarily (until you restart Mach) invert ESS output pin Active High/Low state while running GCode:

1. Execute a G4P0.5 delay (this only needs to be as large as your ESS buffer size).

2. Go into the registry and change all of the desired registers in "ESS/Pins/ESS/Pins/Port#-Pin#_InvertActiveHighLowConfig" =1

3. Execute m2010(UPDATE_REGISTRY_OUTPUT_PIN_INVERSIONS=1)

4. Execute a G4P0.5 delay (this only needs to be as large as your ESS buffer size).

The log file should show this if you invert output pin 2-16:

m2010_InvertActiveHighLowState.png

 

 


Laser Setup

Jim Neeb @ JN WoodWorks made a great video showing you how to set up and run the ESS in Laser Rastering mode and the images it can produce. We would like to sincerely thank him for his assistance in testing our plugin and in producing this video.  Here is his Google drive with a bunch of shared files too.

 

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 (but please use build 283 or newer), 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.

 

If you can't get your laser PWM power level to change, make sure to check these common issues:

1. Make sure that the lua macros have been added to your profile's macros folder (see the next section).

2. You are using the  M2001(PWM_MAX = 90) and M2001(PWM_Min = 5)  commands in your GCode. You can use values other than the 90 and 5, but those are good values to start testing with.

3. Use 80% power for your initial testing. 

Set the laser PWM Frequency (Hz) for both Raster and especially Vector to at least 1050 Hz (you can go much higher if you wish).  at 1000 Hz, you can only reliably get up to 96% power.   At 1050 Hz or higher, you can get up to 100% power.  This will be fixed in ESS build 284 or higher.

 

4. Your BOB's pins are numbered like this

Correct pin numbering

and not like this

Wrong pin numbering.

 

Requires

ESS Plugin.   Open the Zip file and place the "Warp9Mach4.m4pw" and the  "Warp9Mach4.sig" files in "C:\Mach4Hobby\Plugins\" folder.  Overwrite the existing files if prompted.

 

Lua Macros and Command Scripts:

  • Download these lua macros, unzip them, and place these macros in your "C:\Mach4Hobby\Profiles\YOUR_PROFILE_NAME\Macros\" folder.  These macros will be discussed in the next section.  When the Macros are run, they should send information to the log file.  If you don't see anything in the log file, then you most likely are using an old version of the ESS plugin OR you do not have LUA and Regfile plugins enabled in step 1 (below).    (You may need to right click on the link and then click Save As.)

 

Screen Set:

  • ESS Laser Screen Set v 3.5  Place this file in the "C:\Mach4Hobby\Screens\" folder. <- Recommended for Latest versions of Mach4 (identical to v3.0 except uses mcTrace calls)
  • ESS Laser Screen Set v 3.0  Place this file in the "C:\Mach4Hobby\Screens\" folder. <- Recommended for Older versions of Mach4 (identical to v3.5 except uses Trace calls)
  • ESS Laser Screen Set v 1.0  Place this file in the "C:\Mach4Hobby\Screens\" folder.  <- Old
  • If the screenset won't open, or you see "Trace" messages, or has error messages  please read here.

 Macros:

You can find the SmoothStepper laser macros here.

Background Information:

Why did we make the laser use these other features instead of just M3/M5 like in Mach3? 

  • The main reason is safety - if a laser turns on unexpectedly, it is very dangerous. 
  • The next reason is that M62P#s allow the precise starting of the laser with the starting of a G00, G01, G02 or G03 based motion command and the precise termination of the laser burn with a M63P# and the next motion command.
  • Finally, there are a lot of machines that now do spindle work and/or laser work and/or plasma THC work.  Since these are three very different processes potentially running within the same GCode file, the MUST be controlled separately from a safety and effective working standpoint.

 

How to turn the laser on:

In Mach4, the ESS will only enable it's laser for 3 scenarios (assuming you have set up the config correctly):

  1. You checked the box in the ESS laser config to allow test firing, then on the screen set pressed test enable, and then hold down on the test fire button. This will end when you let go of the test fire button.
  2. For laser vector mode you issued the m2003 commands to set up your base values, then the m2004 to enable laser vector mode, and then issued a m62 P# that turned on your laser PWM output.  This will end with a M63P# to shut off the laser or a M2005 disables the laser.
  3. For laser Raster mode you specified the file you wanted with m2000, did the m2001 config commands, and then did m2002 to start the laser raster. This will end when the laser image finishes.

 

Setting Up The Configuration:

1. To set up a Laser, go to Mach4 Menu -> Configure ->Control..>(was Mach4) -> Plugins.  Make sure that the Core, LUA, Regfile and ESS plugins are enabled.  At the time of this writing we recommend Mach4 v 4162 and ESS v 246 or NEWER.

 Laser Plugins

 

2. Now, go to Mach4 Menu -> Configure ->Plugins... -> ESS ### -> Pins Config Tab:

  • Determine which output pin will be your Laser PWM output pin (I picked 2-17).  
  • Determine which output pin will be your Laser Gate output pin (I picked 2-16).  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 (or be able to) wire it up.

Pins Config

3. 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

4. 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. Set the laser PWM Frequency (Hz) for both Raster and especially Vector to at least 1050 Hz (you can go much higher if you wish).  at 1000 Hz, you can only reliably get up to 96% power.   At 1050 Hz or higher, you can get up to 100% power.  This will be fixed in ESS build 284 or higher.   For Rastering you need to go higher to get multiple PWM cycles per pixel.
  • 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.
  • The Air Assist button on the screen set, will control whichever output # (0-63) that you assign to it in section 3.

Laser Tab 1

Laser Tab 2

5. 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).

 

 

 


  

Laser Vectoring Lines

You can find the SmoothStepper laser macros here.

Notes for laser rastering on a rotational axis:

  1. Section 4 of the setup (laser power speed compensation) may not work correctly when a rotational axis (A/B/C) is commanded, and the laser will be running at 0% power since the instantaneous feed rate is not be calculated correctly in ESS build 283. Please disable speed compensation (uncheck both boxes) or only select linear speed comp when testing this problem.
  2. G93 (Inverse Time Feed) mode may provide better results with a rotational axis than G94 (Feed per Minute) mode.  remember that G93 REQUIRES a F value in every line of GCode that has a G# feed move (i.e. G1, G2, ...)

 

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 (this only works in GCode not in the MDI window) 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  Value must be between 0.0 and 1.0 This will update "ESS/Laser/Vector/Gate_Delay" on the next m2004 command and affect the laser's gate then. If this is not used, the values from ESS laser vector config tab will be used instead.
  • m2003 (LASER_VECTOR_GATE_DURATION=0.5) ***<- This will set the Gate Duration to 0.5 Value must be between 0.0 and 1.0 This will update "ESS/Laser/Vector/Gate_Duration" on the next m2004 command and affect the laser's gate then. If this is not used, the values from ESS laser vector config tab will be used instead.
  • m2003(M63_DELAY_ENABLE=1) <- Servos have following lag that steppers do not.  Turn this OFF with a 0 and ON with a 1
  • m2003(M63_DELAY_MS=50) <- This will keep the laser lasing for an additional 50 ms after the GCode told the ESS to shut the Laser Gate off with a M63 P#
  • m2003(LASER_AIR_ASSIST_TOGGLE) <- This will toggle the Laser Air Assist output on or off.  This would typically be used in a screen set button. Normally you would turn the laser air assist output On with a M62 or M64 P# and Off with a M63 or M65 P#

*** Notes on Vector Gate Delay and Duration: The period of your Laser Vector base frequency's PWM Duty will to be 1.  The Gate Delay and Duration values MUST sum up to be 1.0 as well. The ESS plugin will ensure that these values are between 0 and 1.0  If the Delay and Duration values sum up to be larger than 1.0, the plugin will keep the Gate Duration value and reduce the delay value so that they do sum up to 1.0

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 S commands -> M67 for images

This requires Mach4 4809 (or newer) and ESS 283 or newer for proper performance.

If you are burning vector lines and need to change the power level for each line, M67 mode will work well for you.

If you are rastering something like a vector logo or image that only has up to 100 power level changes max, this will work well for you. 

If you are trying to burn something like the Fox image (shown three sections later in Laser Raster Alignment), where there are thousands of tonality adjustments (individual pixels changing power levels) it will break the constant velocity motion chain, making things run very slow and producing over burned pixels or hot spots. While this feature does work for rastering a photograph, it is slower and more prone to image errors than if you were to use ESS Rastering in the next article.  Why? Because it requires many more acceleration cycles and also requires optimal CV performance.

M67 is a macro command that is processed directly by Mach4 and is not downloadable, just like m62, m63, m64, and m65.

Vectric (and other CAMs) allow you to convert an image into GCode and raster it with S commands.   However those S commands will break Constant Velocity (CV) in the Mach4 planner and cause all sorts of issues with detailed images.  That is why you can issue M67 commands instead of S commands, and the M67 commands will not break CV.    I personally still prefer using the Bitmap rastering in the next section since it will produce better results directly off of a bitmap image, but if the M67 approach does what you need, great!

For more specifics, please view the original forum post here.

 M67 Analog Output Capabilities (or real time PWM changes like with Vectric S commands on every line).

For Analog Out 0, Spindle PWM, you need to have the ESS config set up so the spindle would work with a M3 S1000 command. There does not need to be anything special in the GCode for the Spindle PWM to work with a m67 E0 Q###
For Analog Out 1, Laser PWM, you need to have the ESS config set up so that the ESS can run normal laser vector GCode files. In addition, you MUST provide a m2004 macro to allow the Laser PWM to activate, and you should really have a m2003 (LASER_VECTOR_PWM_PERCENTAGE=0.0) command to make sure the laser power is off before you start running. You should end the GCode with a m2005 and another m2003 (LASER_VECTOR_PWM_PERCENTAGE=0.0) command to make sure the laser power is off.

Also please keep in mind that every M67 command MUST have a G0/G1/G2 command immediately follow it that will produce at least 1 step of motion. (However, you can stack multiple M62/M63/M67 commands.) If there is not at least 1 step of motion, Mach4 will ignore the m62/m63/m67 command.


M67 E0 Q# and S# control the same Spindle PWM generator. You should not mix the two command styles in the same Gcode program due to making it more confusing to debug, but you may if you have a good reason to.

The S# will only update the Spindle PWM at the beginning of every ESS plugin main loop, which happens ever 1/40th of a second (replace the 40 with your ESS plugin frequency). This change does not go through the ESS motion FIFO buffer, so it will happen before the X/Y motion it was commanded with (typically about 1/10th of a second sooner than you would expect).

The M67 E0 Q### will update the Spindle PWM speed as soon as the motion data is pulled out from Mach4, but that means several M67 E0 Q### commands can collapse onto each other, and only the last one will survive. This change does not go through the ESS motion FIFO buffer, so it will happen before the X/Y motion it was commanded with (typically about 1/10th of a second sooner than you would expect).

This means that the Spindle PWM should only be used as an analog output if you are making fewer than 10 intensity/speed changes per second, and that you are okay with the changes happening about 1/10th of a second before the motion.

Just because it uses the output signal Spindle PWM, does not mean that you can't use Analog Out 0 for something else like a 3D printer or a laser....




M67 E1Q# and m2003 (LASER_VECTOR_PWM_PERCENTAGE=#) command control the same Laser PWM generator. You should not intermix mix the two command styles in the same GCode program since the m2003 (LASER_VECTOR_PWM_PERCENTAGE=#) is only processed at the start of each plugin main loop which happens ever 1/40th of a second (replace the 40 with your ESS plugin frequency). This means that the m2003 (LASER_VECTOR_PWM_PERCENTAGE=#) is NOT synchronized with motion! The only exception to this is that you should have m2003 (LASER_VECTOR_PWM_PERCENTAGE=0.0) at the beginning and end of your GCode to ensure that the laser power is turned off until the M67 E1Q# turns the Laser PWM power on at the appropriate place in the GCode.

You should not intermix Laser vector PWM M62P# and M63P3 numbers with M67 E1Q# commands in the same GCode.

The M67 E1Q# Analog Out 1 Laser PWM values are passed with the motion data through the ESS's FIFO, and will correspond precisely with the motion commanded. This also can be changed with every motion time slice which is 1/1024th of a second. The Analog Output 1 Laser PWM is much faster and more precise than Analog out 0's Spindle PWM.

Just because this uses the output signal Laser PWM, does not mean that you can't use Analog Out a for something else like a 3D printer or a second spindle....




Here is some sample GCode:

G90
(Run the SPINDLE PWM first)
G00 x0 y0

m67 E0 Q75  (This will turn the Spindle PWM output ON at 75%)
g0 x4
m67 E0 Q25 (This will turn the Spindle PWM output ON at 25%)
g0 x0.1
m67 E0 Q0 (This will turn the Spindle PWM output OFF = 0%)
g0 x0.0

M00 (stop so user has to press Cycle Start to continue)

(Now setup to Run the LASER PWM )
m2003 (LASER_VECTOR_PWM_PERCENTAGE=0.0)
(The next three m2003 lines are optional and not required if you have your Laser Config tab set up right)
m2003 (LASER_VECTOR_FREQUENCY=5000)
m2003 (LASER_VECTOR_GATE_DELAY=15)
m2003 (LASER_VECTOR_GATE_DURATION=85)  
m2004 (This will Enable the Vector Laser PWM - REQUIRED!)

G00 x0 y0
m67 E1 Q66.6  (This will turn the Laser PWM output ON at 66.6%)
g0 x4
m67 E1 Q33.3 (This will turn the Laser PWM output ON at 33.3%)
g0 x0.1
m67 E1 Q0 (This will turn the Laser PWM output OFF = 0%)
g0 x0.0
M2005 (This will Disable the Vector Laser)

M30



Here is the log file and the other related settings:

 




Here are the details for this window from C:\Mach4\Docs\AnalogSettingsDescription.txt

Analog description in the controller configuration

Numerator: The total voltage swing.  e.g. 0v to 10v is 10, -10v to 10v is 20.
Denominator: The total width of the DAC/ADC.  e.g. 10 bit is 1024, 12 bit is 4096, 14 bit = 16384, 16 bit = 65536, etc...
Offset: Used for bidirectional DAC/ADC devices, e.g. -10v to 10v where 0 raw value is -10v and +10v = the width of the device.

DAC Examples: (DAC is Digital to Analog which is an analog output)

10 bit DAC 0v to 10v:  

The total voltage swing is 10v, so the numerator is 10.  10 bits has a max value of 1024, so the denominator is 1024.  The DAC is not bidirectional so the offset is 0.  The clculation is as follows:

(Desired Volt / (Num/Den)) + Off = DAC Value

(10 / (10/1024)) + 0 = 1024.  So to get an analog voltage of 10v, the DAC will be loaded with 1024.  
( 5 / (10/1024)) + 0 = 512.   So to get an analog voltage of 5v, the DAC will be loaded with 512.
( 1 / (10/1024)) + 0 = 102.4. So to get an analog voltage of ~1v, the DAC will be loaded with 102.

14 bit DAC -10v to +10v:

The total voltage swing is 20v, so the numerator is 20.  14 bits has a max value of 16384, so the denominator is 16384.  The DAC is bidirectional so the offset will be half of the total width, so 8192.  
The clculation is as follows:

(10 / (20/16384)) + 8192 = 16384
( 0 / (20/16384)) + 8192 = 8192
(-10 / (20/16384)) + 8192 = 0

It is not important to actually know how the value is calculated.  It is more important to just put the correct values in for the numerator, the denominator, and the offset.  But the formula may help you to understand what is going on behind the scenes.


ADC Examples: (ADC is Analog to Digital which is an analog input)

How inputs are setup is really no different than how the outputs are setup.  But the calculation is diffeent.  

10 bit ADC 0v to 10v:  

The total voltage swing is 10v, so the numerator is 10.  10 bits has a max value of 1024, so the denominator is 1024.  The DAC is not bidirectional so the offset is 0.  The clculation is as follows:

(ADC Value - Offset) * (Num / Den) = Volts

(1024 - 0) * (10 / 1024) = 10v
(512 - 0) * (10 / 1024) = 5v
(102 - 0) * (10 / 1024) = .99609375 (~1v)
(0 - 0) * (10 / 1024) = 0v

 


 

Laser Rastering Bitmap Images Directly

Jim Neeb @ JN WoodWorks made a great video showing you how to set up and run the ESS in Laser Rastering mode and the images it can produce. We would like to sincerely thank him for his assistance in testing our plugin and in producing this video.

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.

As of build 285 (and for even a while before), you can raster at any velocity and DPI you want to as long as your laser and motors can keep up with it. 

Here are the lua script commands used to set up the Laser Raster. You can find the SmoothStepper laser macros here:

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. 

A good file path and name would be something like this:  C:\Mach4Hobby\LaserFiles\ButterflyImage_600x900.bmp   This file path is in the Mach4 folder.  Also there are no spaces, dashes or other special characters in the file name (the underbar is safe to use).   In linux systems (amonsg others) and in certain software packages, special characters like dashes (-) can cause all sorts of havok in a file path or name, and I would recommend that you avoid using spaces, dashes or other special characters at all times with file names like these.

2. m2001 (Comment), this only works in GCode not in the MDI window:

  • 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 (RASTER_X_AXIS_ACCELERATION_PERCENTAGE=100.0)  New in ESS build 285.  100.0 is in percentage and will use the Mach4 motor tuning acceleration value(s) for the X axis.  This allows you to slow your axis acceleration rate down to 0.1% or increase it to 1000.0% of what is specified in motor tuning, so that the rastering motion will accelerate differently than normal GCode motion and jogging. This can either reduce vibrations in your equipment or decrease the time to raster an image. This value is only consumed from the registry when m2002 is processed.
  • m2001 (RASTER_Y_AXIS_ACCELERATION_PERCENTAGE=100.0)    New in ESS build 285.  100.0 is in percentage and will use the Mach4 motor tuning acceleration value(s) for the Y axis.  This allows you to slow your axis acceleration rate down to 0.1% or increase it to 1000.0% of what is specified in motor tuning, so that the rastering motion will accelerate differently than normal GCode motion and jogging. This can either reduce vibrations in your equipment or decrease the time to raster an image. This value is only consumed from the registry when m2002 is processed.
  • 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.  ***NOTE*** if your Mach4 Motor Tuning tab has the "Reverse?" checked for a motor, that will flip all of these starting corners!  Never check the motor tuning "Reverse?" box - instead change the active high low value for that Motor's Dir Pin on the ESS Config -> pins tab.

* #=1 starts in the image's LOWER LEFT corner and moves to the image's Upper Right corner. Moves +X and +Y. >^

* #=2 starts in the image's LOWER RIGHT corner and moves to the image's Upper Left corner. Moves -X and +Y. ^<

* #=3 starts in the image's UPPER RIGHT corner and moves to the image's Lower Left corner. Moves -X and -Y. v<

* #=4 starts in the image's UPPER LEFT corner and moves to the image's Lower Right corner. Moves +X and -Y. >v

  • 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 (PWM_ZERO=0) This will set the Zero PWM Duty Cycle
  • 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".
  • m2001 (COMP_FOR_ACCEL_DIST_X=1) If set to 1, the X axis will move away from the starting point of the image, the distance of the acceleration ramp. When the image is burned, the starting corner of it should be right where Mach left the X-Y axis.   The post comp moves after the image burns will bring us right back to where Mach left us.   Setting this to 0 means that the X axis will NOT make pre-comp move, and then the image will be offset by the acceleration distance.
  • m2001 (SHOW_IMAGE_CORNER_POSITIONS=1) This is not implemented, and will do nothing. But you shouldn't use it now, because I may use it in the future. 


3. m2002 (This starts the Laser Raster) This will tell the software to start the laser raster process.  Make sure to have a G04 P0.5 pause JUST BEFORE AND AFTER THIS COMMAND!

 

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)

G4 P0.5 (Pause so the previous macro commands can be fully processed!!!! THIS IS CRITICAL!)
M2002(This starts the Laser Raster)
G4 P0.5 (Pause on this line while the raster happens. THIS IS CRITICAL!)

G0 X0 Y0

(End of GCode)

 

 

 


 

Laser Image Files

Here is a known good Image file and the GCode file that runs it.  You will need to change the path in the GCode file to point to the image location on your PC.

 

Not all photo editing software is created equally.  In fact some of it is quite horrid and cannot even output the headers correctly for image files!  When the header files in the image are mangled, you will get error messages similar to:

"The image offset is 1078 bytes declared vs 54 bytes calculated"

or

“This image has 0 bytes declared vs 207740 bytes calculated!”

In these cases, please try GIMP.  It is free and open source software, that is simple to use but also very powerful, and best yet, it works.

 

Once GIMP is installed, open your image file into it, and then export the image (to the same or a different name).  As you do the export process, please make sure to:

  • Expand "Select File Type (By Extension)" and select "Windows BMP Image"    -    "bmp" for Bitmap, and then click on export. 
  • Under Compatibility Options, CHECK the box for "Do not write color space information"
  • Select 24 bits "R8 G8 B8)"

 

Gimp Export

Gimp Export File Type

 

Gimp Export Options

 

 


 

Laser Raster Line Alignment

For Laser Rastering, each row starts by accelerating up to the commanded velocity (feed rate) at which point the SmoothStepper will start issuing the PWM values for each pixel.  Once all of the pixel data for the row has been used (over the distance commanded for the row in the image), the X axis motion then decelerates to a stop so the Y line distance can be moved before the next row is rastered in the opposite direction.  If you motors or axes have lag (this could even be just a little backlash pullout) you will have a horizontal offset in your rastered image.  You can easily see if this is the issue by selecting the option in the Laser tab for "Laser Raster Even Rows Only", and the alignment issue will be gone on your next image. Please make sure you uncheck this option after you have verified that this is the issue.

To fix this issue, you will need to adjust your "Motor Delay Distance" in C:\Mach4Hobby\Plugins\_Laser_Raster_Velocities.txt  

Your delay distance will need to be essentially 50% of the distance you are off by in your original alignment at that velocity or feed rate.  The faster your feed rate, the larger your Motor Delay distance will need to be.  It is best to enter specific distance values for all of your common feed rates, but the software will interpolate the distance based off of higher and lower values.  Once these changes have been made your image should be in perfect alignment.  More information regarding the setup is inside the "_Laser_Raster_Velocities.txt" file itself.  Please make sure to include one or two distance lines for feed rates faster than you expect to use so you are covered on the high end if you forget.

First try with Laser Raster Line Alignment Issues

Fox Bad

 


Second and Third tries with Laser Raster Line Alignment Issues, and success on the Fourth attempt.

Fox Good

 

The image above shows that the alignment was corrected with the proper motor delay distance.  However, the quality of the image still suffers a little bit due to insufficient resolution; increasing the DPI would help to improve the quality of the image.

 

 

 

 


 

IPG Fiber Laser

An IPG Fiber laser has the power level clocked in 8 bits wide on the rising edge of a latch (pin 9).   How do you make that happen?

For a post processor exporting GCode:

Set up a fake C axis, with a step per of 1001, a high velocity and high acceleration.  You should get almost a rectangle on the resulting graph.  Why a fake C axis? Because then we can issues a bunch of incremental steps that will let our M62/M63 motion commands execute right with the start of a step on the C axis - even though no C axis physically exists.  You will need to use an unused ESS motor (5, 4 or 3 typically) as a dummy motor for the C axis.

M62 P# will turn an output ON (at the beginning of the next motion command) and M63 P# will turn that output OFF (at the beginning of the next motion command), if followed by a G0, G1, G2 or G3  motion command that moves at least one step.  You may combine multiple M62s and M63s together on separate rows or a single line.

Assuming that you are using pins D8 to D1  on the laser as output numbers 8 to 1, and the latch as output 9, your post processor GCode should look like this for a power change (I will do a bunch of M6*s for the 8 bits, but they would need to be M62s to turn bits on and  M63s to shut bits off):

 

G91 (Switch to incremental position mode)

M62 P8 (turn bit 8 on)

M63 P7 (turn bit 7 off)

M6* P6 (turn bit 6 on/off)

M6* P5 (turn bit 5 on/off)

M6* P4 (turn bit 4 on/off)

M6* P3 (turn bit 3 on/off)

M6* P2 (turn bit 2 on/off)

M6* P1 (turn bit 1 on/off)

G00 C 0.001 (A move of 1 step to make the M62/M63 commands operate)

M62 P9 (turn latch on with rising edge)

G00 C 0.001 (A move of 1 step to make M62 enable the latch)

M63 P9 (turn latch off)

G00 C 0.001 (A move of 1 step to make M63 disable the latch)

G90 (Switch back to absolute position mode)

 

That is the end of the GCode that should be produced by your post processor for a power change.

 

Your post processor would need to convert your desired power level into an 8 bit power level that is then assign to each bit.  I will leave that as an exercise for you.

 

Lua code in a screen set button:

For a power change when you are not running GCode, you would need to make a screen set button apply lua code.  Here is an example for Go To Work Zero that will show you how to modify a button: http://documentation.warp9td.com/Hardware/ESS/Software_Mach4/lua/lua_Go_To_Zero.htm

 

mc.mcCntlMdiExecute(inst, "G04 P0.3 \n M64P8 M65P7 M6@P6 M6@P5 M6@P4 M6@P3 M6@P2 M6@P1 \n G04 P0.1 \n M64 P9 \n G04 P0.1 \n M65 P9 \n G04 P0.1")

 

That has a G4 provide a 0.3 second pause so we know that the ESS command buffer will empty.  Then it uses M64s to turn outputs ON instantly and M65s to turn outputs OFF instantly.  A G04 pause of 0.1 seconds then enable the latch, pause and disable the latch with a final pause.

 

You would need to convert your desired power level from a screen set DRO into an 8 bit power level that you then assign to each bit.  I will leave that as an exercise for you.

 

Andrew

 

 

 

 


 

(Torch) Height Control

 

Height Control (HC) is also commonly referred to as Torch Height Control (THC) and is commonly used in plasma cutting operations.  However, this can also be used with Oxy-Acetlyne, water jet and Laser cutting operations.  For this reason we will not use the term torch when referring to Height Control.

 

Changes in Mach4 vs Mach3:

In Mach3, Height Control was partially integrated into the Mach3 program, had no real error reporting when something went wrong, and used the same M3 macro as the spindle. 

In Mach4, the we started from scratch to implement Height Control and everything is inside the ESS plugin (and TMC3in1 plugin as appropriate).  This allowed us to have more flexibility, better error reporting and better performance overall.  Another significant change is that instead of M3 we now use M62 to turn the torch on and instead of M5 we use M63 to turn the torch off.   This has two distinct benefits.  The first is that you won't accidentally turn on the Spindle in a machine that has a spindle and a plasma unit - a giant safety improvement.  The second reason is that the M3 macro is not coordinated with your motion data and may be off by up to half a second!  This is not a huge issue when you start a spindle and let it get up to speed for a few seconds, but when you are vaporizing metal, milliseconds count!  With M62 and M63 the torch on and off commands are precisely synchronized with the start of the next motion command. This also allows for precise timing of a pierce delay.

Types of Height Control:

  • Manual Mode.  This allows you to use the keyboard to adjust the Z height up and down, which is the simplest form of height control but it is 100% manual.  This is common in Oxy-Acetlyne and water jet cutting. (Operationally this is almost identical to Up/Down Mode so the two modes are combined together. The only differences are two inputs and a button to select which mode you are in.) There are no anti dive capabilities here, other than the operator.

 

  • Up Down Pins Mode (like with Proma Controller), Manual Mode (Oxy-Acetylene) or no THC.  This is the simplest kind of automated Height Control, and it offers the least flexibility.  You have to manually adjust your target tip volts on the Proma controller, and the SmoothStepper just responds to UP and Down input signals to control the Z Height.  (Operationally this is almost identical to Manual Mode so the two modes are combined together. The only differences are two inputs and a button to select which mode you are in.) There are almost no anti dive capabilities here.  This will also let you run without THC (Torch Height Control) or in Manual mode if you are using Oxy-Acetylene.

 

  • Mach4's built in THC Mode (totally independent of the SmoothStepper).  This utilizes a PLC to read the tip volts.  Mach allows you to change your target tip voltage, and will generate Up and Down Z motion to correct the height.  However, there is some lag and there are limited anti dive capabilities.

 

  • The WarpRunner (or its predecessor the TMC3in1) Torch Height Controller, which was designed to interface directly to the ESS and adjust the cut height over 1000 times per second.  Since it communicates directly with the ESS and there is no buffering of data, there is almost no lag in response.  There are 6 different Anti Dive modes, and almost all of the run time settings for the WarpRunner can be controlled by macros in your GCode!  This offers the most flexibility and performance.

 

 

 

 


 

ESS Specific Height Control Features

 

  • Arc Okay going out will cause a feed hold while cutting. The Resume Cutting button will enable so you may fire the torch and resume cutting.
  • Probe activation while torch is on will cause a feed hold, if enable on the ESS Config -> Probe tab. The Resume Cutting button will enable so you may fire the torch and resume cutting.
  • There is a pierce counter available so you may keep track of your pierces.
  • Precision Delay after Pierce
  • Support for the TMC3in1 Torch Height Control Hardware

 


 

Height Control - Up Down Pins Mode (Proma Style), Manual Mode (Oxy-Acetylene) or No THC Modes

Requires:

Mach4 Build 4305 or newer. Mach4 had an issue where if there was a probe command in the next 20 lines (lookahead buffer), Mach4 would freeze up and need to be restarted if you had pressed Feed Hold and Stop (or the Arc Okay signal caused a stop) and then pressed Cycle Start.  This has been fixed in build 4305 and newer.

ESS Plugin.   Open the Zip file and place the "Warp9Mach4.m4pw" and the  "Warp9Mach4.sig" files in "C:\Mach4Hobby\Plugins\" folder.  Overwrite the existing files if prompted.

 

m2020 Height Control Command Script.  Place this file in the "C:\Mach4Hobby\Profiles\YOUR PROFILE NAME\Macros\" folder.

  • m2020.mcs script.  (You may need to right click on the link and then click Save As)

 

Screen Set. Place this file in the "C:\Mach4Hobby\Screens\" folder.

 

Optional:

  • Sample Height Control Profile - Your motors, motor tuning and limit switches and EStop will be different.. When you first open Mach4, in the Select Profile window, you may Import this profile.

 

Sample GCode:

This sample GCode has a G31 probe command for touch off, you should adjust the numerical values as appropriate for your machine!  The positions of the cuts and the feed rates should also be adjusted for your system.

  • Manual Mode GCode example - NONE.  Manual Mode does not really need any GCode other than possibly setting the Z Max and Z Min Height Control limits.  If you want to add that in, you can copy those lines out of the following example.
  • Up Down Mode sample GCode.  This was made with the SheetCam Default Up Down.job

How Height Control Works - Manual Mode

In order to keyboard buttons or screen set buttons to manually adjust the Z axis height while cutting, you need to do several things:

  • Get Mach4 working with your motors, home and limit switches, and other basic equipment by following the Getting Started Guide here.
  • Follow the Core Height Control setup instructions below, and also the Manual Mode specific requirements.
  • Enable Mach.
  • Press the "H.C. ON/OFF" to turn Height Control On.  Without this set to ON, the ESS will ignore all Height Control Signals.
  • Make sure that the Height Control Mode Type is set to the correct mode (1, HC_MODE_TYPE_MANUAL).  You can do this with either the Height Control Mode Type setting in the ESS config, or with the "Set HC Manual" button on the screenset.
  • Manual mode ignores the Torch Relay and Arc Okay signals.
  • While GCode is running you may press the Up or Down keys on the keyboard or the Up or Down buttons on the screen set. The ESS will respond to these commands and adjust the Z axis height accordingly.

 

How Height Control Works - Up Down Pins Mode

In order to allow a (Proma style) Torch Height Controller to automatically adjust the Z axis height while cutting, you need to do several things:

  • Get Mach4 working with your motors, home and limit switches, and other basic equipment by following the Getting Started Guide here.
  • Follow the Core Height Control setup instructions below, and also the Up Down Pin Mode Specific requirements.
  • Enable Mach.
  • Press the "H.C. ON/OFF" to turn Height Control On.  Without this set to ON, the ESS will ignore all Height Control Signals.
  • Make sure that the Height Control Mode Type is set to the correct mode (2, HC_MODE_TYPE_UP_DOWN_PINS).  You can do this with either the Height Control Mode Type setting in the ESS config, or with the "Set HC UP/Dn Pins" button on the screenset.
  • Activate the torch in GCode.  Once the Arc Okay signal activates, the ESS will respond to the Z axis movements commanded by the Height Controller.

 

 

Core Height Control Setup Instructions:

1. Open the Mach4 Configuration:  Menu -> Configure -> Control...

TMC

 

2. In the Plugins tab , you will need at least these plugins enabled:

  • Core
  • LUA
  • Regfile
  • ESS
  • Optional - Keyboard Inputs.  You will need this if you are going to use keyboard keys.

If you don't have all these plugins enabled, the hardware will not work right.  You may use additional plugins as needed.

If you enable any plugins, you will need to restart Mach4 for those plugins to function properly.

Plugins

 

3. Open the ESS Configuration:  Menu -> Configure -> Plugins... -> ESS

TMCPlugin Choices.png

 

4.  H.C. tab:

  • For Manual Mode
    • Height Control Mode, select "Manual Up/Down (Oxy-Acetylene)".  This will be your default choice but it can be modified with the screen set button. 
    • Select an input number for the Keyboard Up Key and an input number for the Keyboard Down Key.  These input numbers will be from 0 through 63.  Don't reuse the same input number.  We will continue setting the keyboard up here.
    • You may ignore Z axis limits, or select Work Coordinate limits.  Machine Coordinate limits are not recommended.
    • You don't NEED to use a Torch relay, but you may want to.
  • For Up Down Pin Mode
    • Height Control Mode, select "Hardware Controller: Up Down Pins (Proma Style)". This will be your default choice but it can be modified with the screen set button. 
    • You may ignore Z axis limits, or select Work Coordinate limits.  Machine Coordinate limits are not recommended.
    • Enable the Torch Relay and select an available output number between 0 and 63.  Which ever number you choose, you will need to use that number for M62P# (followed by a G0/G1/G2/G3 motion command)to turn the torch on and M63P# (followed by a G0/G1/G2/G3 motion command) to turn the torch off. Assign this output number signal to the Port # and Pin used by the relay that controls your torch.   You may also assign a pierce delay time after Arc Okay before your GCode motion is executed again.

TMC

 

5. Pins Config tab - The critical pins here are:

  • For Manual Mode:
    • You don't need any special pins, except for whatever you need to turn on your cutting device.
  • For Up Down Pin Mode you will need pins for:
    • The Arc Okay (THC ON) input signal
    • THC UP input signal
    • THC DOWN input signal
    • Probe (touch off) input signal
    • Torch Relay output signal

Pins for the rest of your equipment:

  • Dummy Laser Gate Signal - This was the last row of the H.C. tab
  • Your motor pins - set as needed
  • Your homing and limit pins - set as needed
  • Your EStop and Probe pins - set as needed
  • Etc...

TMC

 

6. Input Signals tab:

  • For Manual Mode:
    • You don't need any special signals. 
  • For Up Down Pin Mode you will need signals for:
    • The Arc Okay (THC ON) input signal
    • THC UP input signal
    • THC DOWN input signal
    • The probe signal used for the G31 touch off.
  • All other input signals are as needed for your your system.
  • If/Once you finish setting up the Keyboard Inputs to Inputs 9 and 10, they will appear as Keyboard in the Mapping column.

TMC

 

7. Output Signals tab:

  • For Manual Mode:
    • You don't need any special pins. 
  • For Up Down Pin Mode you will need pins for:
    • Output # for your torch relay

 

All other output signals are as needed for your your system.

  • Your Motor signals
  • Any other outputs signals you may need

TMC

 

Your profile should be set up with the core configuration required for Height Control to work.  The exception is keyboard inputs for Manual Mode.

 

 8. Open the Keyboard plugin: Menu -> Configure -> Plugins... -> Keyboard Inputs

 

 TMC

 

 

 9. Add two inputs, "HC Z UP" and "HC Z DOWN".  Press the area under "Key" to select the keyboard keys you wish to use.  After pressing OK, RESTART MACH4.  If you don't restart, the keyboard keys will not work.

 

 TMC

 

 

 9. Open the Mach4 Config and go to the Inputs tab.   "Menu -> Configure -> Control... -> Input Signals"

  • Set input #9 to "HC Z UP" (or the input # you picked with the key name you used).
  • Set input #10 to "HC Z DOWN" (or the input # you picked with the key name you used).
  • Those two keyboard keys should now make your Z axis move up and Down when Mach4 is Enabled, H.C. is turned ON, and you are set to Manual Up/Down HC mode.

 

 

 

How to use the Screen Set

 

TMC

 

1. Press Enable in the lower left of the Mach4 screenset, otherwise some of the buttons will have no effect.


2. You need to click on the "H.C. ON/OFF" button to allow Height Control to move the Z axis.


3. "Set HC Manual" will force this screenset into Manual Mode.

  • Clicking on "Manual Z Up" or pressing the corresponding keyboard key for "HC Z UP" will move the Z axis Up, both in idle mode and while running GCode.
  • Clicking on "Manual Z Down" or pressing the corresponding keyboard key for "HC Z DOWN" will move the Z axis Down, both in idle mode and while running GCode.

4. "Set HC Manual" will force this screenset into Manual Mode.

  • If your Torch is activating the "Arc Okay" signal (THC ON), then the Hardware Controller can command the Z Axis Up with the "THC UP" signal or the Z Axis Down with the "THC DOWN" signal.
  • If the "Arc Okay" signal goes out, cutting will be halted.  Tee "Resume Cutting" button will be become clickable, so you can backup to a good pierce point and then resume the cut.

5. The "Reset Pierces" button will reset the number of pierces to 0 and clear the red indicator showing that the number of pierces exceeds the specified limit.

Watch the videos listed near the start of this article to see this screenset in use.

 

 


Available M2020 (...) macro commands for Up Down Mode and Manual Mode

You DON'T need to use any of these macro commands listed here!  However, they provide the ability to automate your projects in the CAM post-processor and to have much more control than with any other Height Controller that we know of.

These macro commands allow you to adjust TMC3in1 and ESS Height Control settings directly from your GCode!  This allows you to set up your post processor to configure your entire job.   It is recommended to include a G04 P0.1 command after the last M2020(...) macro in a group of macros (or after a single one by itself) so that the macro will be processed before the next line of GCode is acted upon.

The bold portion is what you put in your GCode, including the opening and closing parens ().  The non-bold text afterwards is my description of the command, and SHOULD NOT BE IN YOUR GCODE.

The value after the equal sign is an example value, use the actual value that you need. 

 

  • m2020 (HC_Z_MAX_VALUE=1.001) Set the Z Max Value if using Machine coordinate or Work coordinate Z axis limits.
  • m2020 (HC_Z_MIN_VALUE=-0.12) Set the Z Min Value if using Machine coordinate or Work coordinate Z axis limits.
  • m2020 (HC_WORK_Z_ZEROED=1) This tells the SmoothStepper that the work coordinates just changed and that the Z Max and Z Min should be recalculated.
  • m2020 (ESS_TORCH_TOGGLE) This should only be used by a screen set button or a recovery script.
  • m2020 (ESS_TORCH_RESUME_WAIT_FOR_ARC_OKAY=1) This should only be used by a screen set button or a recovery script.
  • m2020 (ESS_TORCH_RESUME_USE_PIERCE_DELAY_WAIT_FOR_ARC_OKAY=1) This should only be used by a screen set button or a recovery script.
  • m2020 (ESS_TORCH_STATE=1) 1 will turn the torch on, 0 will turn the torch off.  While you could use it in your GCode instead of M62P#/M63P#, you shouldn't because it will not be timed with motion.  This should only be used by a screen set button or a recovery script.  This won't wait for Arc Okay or give you a pierce delay.
  • m2020 (ESS_DELAY_AFTER_ARC_OKAY=0.512)  This sets the precision delay time in seconds from when the Arc Okay input signal activates until X, Y or Z axis motion will occur.
  • m2020 (HC_Z_VELOCITY_UP_SPEED_PERCENTAGE=50)  This sets the percentage of full speed Z, that the Z axis should move when an THC UP signal is received.
  • m2020 (HC_Z_VELOCITY_DOWN_SPEED_PERCENTAGE=20)  This sets the percentage of full speed Z, that the Z axis should move when an THC DOWN signal is received.

 


What should I use for the pierce delay?

Typically, most plasma users just use a  G04 P# after firing the torch, to get a pierce delay. The provided SheetCam post processor would generate output which would look something like this:

...
N2170 M62P3 (>>>Torch ON<<<) 
N2180 Z0.1500 (Force a small move in Z to make M62 fire the torch)
N2190 G04 P0.4 (DELAY)
N2200 G01 Z0.0600 F20.0 (Drop to cut height)
(Move X and Y here to make the cut_
...

The G4P# works fine in Mach4, for a general delay, and it will work just fine for most users. However, some users are cutting REALLY thin metal that loves to warp, and they want very precise timing and control over the pierce time. That is why we developed the command :
M2020 (ESS_DELAY_AFTER_ARC_OKAY=.015) <---- This will give 15 ms of delay once the Arc Okay signal turns ON

This lets your specific tool (for a specific metal type and thickness) in SheetCam (or whatever CAM program you are using) specify an ultra precise time delay - after the Arc Okay turns. Then in SheetCam's tool # specific Pierce delay window you would set it to 0, so it won't add in an extra delay time.

Use SheetCam's tool # specific Pierce delay value if you want a delay that starts with the torch On command starting the pierce. Notice that this is after starting the pierce, not after getting the Arc Okay signal. You will get a variable amount of delay each time after the Arc Okay turns on, because some (or all) of the delay will be before the arc okay turns on.


If you need a SPECIFIC pierce delay after the Arc Okay turns ON, then use the ESS_DELAY_AFTER_ARC_OKAY command to get a precise delay, but don't use a G04P# then.

 


As for the length of time to delay for the pierce, use your torch's manual for a starting point for that thickness of metal. In general:

  • If your pierce hole is much wider than the lines you are cutting, the pierce time is too long.
  • While waiting in the pierce delay, your arc is going out because all of the metal is blown away, the pierce time is too long.
  • If you are using thin sheet metal, and it is warping around the pierce hole, the pierce time is too long.
  • If the arc has not fully pierced through the metal before the X and Y cuts start happening, then the pierce time is too short.

 


 

Height Control - Mach4's built in THC Mode

The SmoothStepper does not have anything to do with THC in this mode (other than moving motors, controlling outputs and reading inputs).  This version of THC is performed totally in Mach4 by lua scripts written and maintained by Mach4 (Newfangled Solutions). 

Here is the current Mach4 Plasma Configuration PDF as of 2019 04 25.  You should check your "C:\Mach4Hobby\Docs\Plasma_Configuration.pdf" file to see if it is newer or if they have an updated version on their website.

 


 

Height Control - WarpRunner (or its predecessor the TMC3in1)

 

WarpRunner

The WarpRunner is for sale here.

 

All of our WarpRunner and TMC3in1 documentation has moved to our documentation site, here.

 

 


 

SheetCam Setup

This is the SheetCam setup guide for Mach4 and the ESS.   Please be aware that there are two versions:

 

 

Up Down Pins Mode SheetCam Setup

1. Download and install SheetCam TNG Stable or Development from here.  Either Development or Stable will work, but only Development will allow you to import the rules.  It takes about 90 seconds to recreate the rules from the screenshots below.

 

2. Open SheetCam, then go to "Menu -> Options -> Machine"

SheetCam

 

SheetCam

 

 

2a. Click on the "Post Processor" tab, and then at the bottom click on "Import Post", select this file (after you have downloaded to your machine - you may need to right click and "Save As")

 

2b. While still in the "Post Processor" tab, click on "Edit Post",  Find the two lines:

  • torchOnCode = " M62P3 (>>>Torch ON<<<)"
  • torchOffCode = " M63P3 (<<<Torch OFF>>>)"

Change the P3 to match the output number you have selected for your torch relay.   P3 is for Output#3, P27 is for Output#27, etc...

SheetCam

 

2c.  Save the file and close out of SheetCam.  This step is required for the post processor to update SheetCam correctly.

 

 

3. If you DON'T have a tool table. Here is a Default Up Down.job file to use if you don't have anything.  Download the file (you may need to right click and "Save As").  Open the file, and it will launch SheetCam for you.  There is a sample part to cut.

 

4. In SheetCam click on "Menu ->Tools -> Cutting Rules".  You may need to drag on the window to the right to widen it.  Click on "Load" to import these rules.  (If you already have some rules you will need to add these new ones or modify your existing rules to match).  Select this file (after you have downloaded to your machine - you may need to right click and "Save As") ESS UP DOWN Mach4 v001.rule These values are in inches, and you may need to modify the distances to match your machine's capabilities.  These are just a starting point.

 

SheetCam

SheetCam

 

 

5a. All the numerical values I provided are just place holder values.  You will need to adjust them to meet the needs or your processes.  You will need to adjust your "Menu -> Options -> Machine - Post Processor -> Set custom post Options" values.  You can change these values as appropriate.

SheetCam

 

 

5b.  If you click on "Menu ->Tools -> Tool Table" and switch to the plasma tab, you can edit all of your plasma tools at once.  Or you can just double click on an individual tool from the main screen's Tools window. 

SheetCam

 

 

6. Import your CAD file (or use the provided default.job) and you should be able to generate GCode now by clicking on "Menu -> File -> Run Post Processor".  Please read the SheetCam manual or watch YouTube videos to learn how to use the rest of SheetCams many features.

 

 

 

 

TMC3in1 Setup

1. Download and install SheetCam TNG Stable or Development from here.  Either Development or Stable will work, but only Development will allow you to import the rules.  It takes about 90 seconds to recreate the rules from the screenshots below.

 

2. Open SheetCam, then go to "Menu -> Options -> Machine"

SheetCam

 

SheetCam

 

 

2a. Click on the "Post Processor" tab, and then at the bottom click on "Import Post", select this file (after you have downloaded to your machine - you may need to right click and "Save As")

  • TMC3in1 Mach4 v003.scpost Version 003.  This has been modified so that you specify the "Pierce Drop to Fire Torch" which will bring you down to pierce height.
  • TMC3in1 Mach4 v002.scpost Version 002 added GCode comments to make it easier to see where the Torch is turning on and off, along with when a Probe/Reference is happening (as shown in 2b below).
  • TMC3in1 Mach4 v001.scpost

 

2b. While still in the "Post Processor" tab, click on "Edit Post",  Find the two lines:

  • torchOnCode = " M62P3 (>>>Torch ON<<<)"
  • torchOffCode = " M63P3 (<<<Torch OFF>>>)"

Change the P3 to match the output number you have selected for your torch relay.   P3 is for Output#3, P27 is for Output#27, etc...

SheetCam

 

2c.  Save the file and close out of SheetCam.  This step is required for the post processor to update SheetCam correctly.

 

 

3. Do just step 3a or both steps 3B and 3c.

3a. If you DON'T have a tool table. Here is a Default TMC3in1 v003.jobt template file to use if you don't have anything.  Download the file (you may need to right click and "Save As").  Open SheetCam and click on "Menu ->File -> Open Job Template" and select this file.  

  • This will provide you with two code tools (shown in step 3b) that you will need for the rules in the next step to work.   Make sure that you are using Output#4 for AD2, otherwise edit the Tool Code so that the outputs match your P#.
  • This will also provide the Rules

 SheetCam

 

 

 

3b. If you already have a tool table. Click on "Menu ->Tools -> Code" Add the two following Code snippets - but don't include the quotes:

  • Code Name: "THC Inhibited via AD2"  Actual Code Snippet: "M63P4 (***THC Inhibited, AD2***)"  SheetCam

 

  • Code Name: "THC Allowed via AD2"  Actual Code Snippet: "M62P4 (+++THC Allowed, AD2+++)"SheetCam

 

Make sure that you are using Output#4 for AD2, otherwise edit the Tool Code so that the outputs match your P#.

The asterisks and pluses were added to the comment lines above to make it easier to see them in the GCode.

The Code Snippets should now appear in your Tools Window.  Close SheetCam.  You don't need to save your changes to the current file, but you do need to save the default tool set when prompted, so click Yes for the default tool set save prompt so these values are saved.  Otherwise you may delete them (repeatedly) by pressing Control-Z in a higher level window... Don't ask.

SheetCam

 

 

3c. In SheetCam click on "Menu ->Tools -> Cutting Rules".  You may need to drag on the window to the right to widen it.  Click on "Load" to import these rules.  (If you already have some rules you will need to add these new ones or modify your existing rules to match).  Select this file (after you have downloaded to your machine - you may need to right click and "Save As") TMC3in1 Mach4 v003.rule  These values are in inches, and you may need to modify the distances to match your machine's capabilities.  These are just a starting point.

Make sure that the Inhibits and Allows are in the same places that I have highlighted.  If they are not, double click on the rule and change the code snippet selection so that they match.

SheetCam

 

 SheetCam

 

4. All the numerical values I provided are just place holder values.  You will need to adjust them to meet the needs or your processes.  You will need to adjust your "Menu -> Options -> Machine - Post Processor -> Set custom post Options" values.  AD1 and AD3 ENABLE are set to 1 (enabled) to begin with, since this will stop most diving.  Once you are comfortable with that, enable AD2 by setting it to 1 and get used to working with that.   Once you have that working, enable AD4 and get that working correctly with your system.

SheetCam

 

 

5.  If you click on "Menu ->Tools -> Tool Table" and switch to the plasma tab, you can edit all of your plasma tools at once.  Or you can just double click on an individual tool from the main screen's Tools window.  You will see that at the bottom of each tool you may set the desired Target Tip Volts, Target Band Volts, Linear Response voltages and the precision ESS Delay after Arc Okay values.  You can set these values differently for each tool, and the TMC3in1 will use these values automatically for your job.

SheetCam

 

 

6. Import your CAD file (or use the provided default.job) and you should be able to generate GCode now by clicking on "Menu -> File -> Run Post Processor".  Please read the SheetCam manual or watch YouTube videos to learn how to use the rest of SheetCams many features.

 

 

 


 

Fusion 360 Plasma Setup

While we primarily provided support for our OEMs to get up and running with SheetCam, there are some individuals who wish to use Fusion 360.  We understand that, but we don't really have the time to support it.  However, we did work with one of our customers to help make a Fusion 360 post for Mach4 and the ESS.  Save this "Mach4plasmaESS_Fusion360.cps" to "C:\Users\YOUR_PROFILE\AppData\Local\Autodesk\Autodesk Fusion 360\CAM\cache\posts\". This is written assuming that you will be using Output #3 for the Torch Relay which is why we say P3 after the M62 or M63.  If you decide to use a different output number, great, but change the number after the P to match. 

Here you can see the relevant changes (save it or open it in a new tab for a bigger view).

Fusion 360

 

 

 


 

Rotational Axis Commands

Notes:

1) Make sure you go to Mach4's Menu -> Configure -> Control -> Defaults -> Control Mode and chose Mill or Lathe as appropriate for your machine.  There are a bunch of other relevant settings here especially the Spindle Mode as either Constant RPM or Constant Surface speed.

2) In Mach4's Menu -> Configure -> Control -> Axis Mapping tab, you can see that Axis 3 (A or U), Axis 4 (B or V) and Axis 5 (W or C) can have motors assigned to them.  These axes are U/V/W if linear and A/B/C if rotational. If rotational, and you want them to rollover (361 degrees is reported as 1 degree), you need to select that option in the General tab.

 

If your spindle is a Step/Dir servo motor assigned as axis C (or A or B), it is coordinated so it moves in sync with the X, Y and Z axes.  In this case you can issue commands like this:

C 3600.0 Z -05  F 360.0 

Which results in the spindle rotating 10 revolutions or 3600 degrees while the Z axis descends 10 mm (or your current units) resulting in a 1 mm (or your current units) pitch thread formed at 1 revolution per second or a feed rate of 360.

C 0.0 Z 0.0 F 360.0

This command retracts the tap back out of the hole.  This is effectively rigid tapping, and works without any spindle encoder feedback.  This can easily break your tap if you command too fast of a speed, your servo spindle lags, the tap slips in the collet or if the chip load binds the tap. We don't recommend that you should do this, but you can try if you are willing to risk your tap and the work piece.  If you were to try, practice with paraffin wax where you won't break anything.  Or use a Tapmatic head and that will save a lot of frustration when tapping!

Another area where using the Step/Dir servo spindle as a C axis is useful is on a lathe where you want to index (rotate to 0 degrees) your work piece and then rotate it 90 degrees (or whatever) to make flats or drill holes into it.

With ESS plugin 285 and higher you can switch your spindle back and forth between a C axis with coordinated motion (above) and SS Motor mode, where the spindle is uncoordinated (i.e. free running at a specific speed).

TODO: Include instructions for switching back and forth.

 


 

Lathe Threading

Both Mach4 and Mach3 support threading operations with G32 and G76 commands. The start of each threading pass is synced with the (required) Spindle Index Pulse. 

G32, G76 and G99 all require RPM feedback from your spindle to operate (i.e. at least a spindle index pulse).

For specific usage instructions on how to use a lathe in Mach4 and the lathe specific GCode, please read your C:\Mach4Hobby\Docs\Lathe GCode Programming.pdf

Also you will need to go to Menu -> Configure -> Control... -> Defaults and change your Control Mode from Mill to Lathe.

 

Mach4 build histories and issues:

G76 and G32 worked just fine in Mach build 4360 (available here) and lower, with ESS build 259 (but those are ancient now so don't try using them on a new install).

Something broke G76 in Mach4 build 4385 through at least 4563, so don't use those builds of Mach4. (This was not an issue in the ESS plugin, just a Mach4 specific build issue, so any ESS plugin version should work.)

Lathe threading with G32 and G76 are working properly with Mach4 4580 (and newer) and ESS 268 or 269 (and newer).  However, if you are doing a new install, you should install the currently recommended builds from here.
 

 

Speed compensation to match instantaneous RPMs:

Your lathe spindle does NOT run at a constant RPM.  Some spindles have poor speed control circuitry and will not hold exactly at a specific speed.  Other motors are underpowered for your load.  All will experience an instantaneous drop in speed when the tool first starts cutting. The SmoothStepper will automatically adjust the feed speed speed of the Z and X motors 1000 times per second to compensate for the instantaneously measured spindle RPM.  The instantaneously measured spindle RPM is calculated by the spindle Index pulse (once ever revolution which will typically be much less than 1000 times per second) or the spindle Encoder A channel, which is much more accurate due to multiple RPM updates per revolution. 

  • Even if you are using the Spindle Encoder to measure the RPMs more accurately, you must still have the Spindle Index signal hooked up as well.  Without the Spindle Index signal, we can't determine the 0 degree location required for starting each threading pass. (0 degrees is the index sensor location, and it does not matter which direction it is orientated, only that it doesn't move.  This will make sure each subsequent threading pass starts at the same location.)
  • If hooking up the spindle encoder, you only need to hook up Spindle Encoder A channel for the RPM measurements to be made.  However, without the Spindle Encoder B channel hooked up, the encoder will just dither back and forth between values.  With the Spindle Encoder A and B channels hooked up, the encoder value will count up or down (depending on the rotational direction).
  • You don't want or NEED 1000 RPM updates per second, because you will loose your resolution, see here.  The ideal scenario is 40 effective pulses to 100 effective pulses (<--- ideally) up to 250 effective pulses per second for the ESS to adjust to changing rotational velocities while threading.  Even as few as 5 updates per second will make a significant difference compared to less than 1 update per second.

 

Spindle Motor Options: 

Threading works with any of the following ESS spindle options:

  • PWM spindle control
  • SS Motor Step/Dir spindle control (MUST USE MOTOR 5) or
  • Mach4 OB Step/Dir Spindle control (a STEP DIR Spindle MUST USE MOTOR 5 for the OB motor). 

When the GCode starts a threading pass, we halt all motor motion on motors 0 through 4 so that we can wait for the index pulse to tell us to go. 

  • If you are running a Step/Dir Spindle on motors 0, 1, 2, 3 or 4 it will be instantly stopped at the beginning of each threading pass, and you will get a clunk or a reduction in spindle speed for an instant, until the Spindle Index signal pulses. 
  • On motor 5, we allow the Step/Dir spindle to maintain it's current velocity while waiting for the index pulse.   This is why you want to be on motor 5 instead of motors 0 through 4 for your Step/Dir Spindle.
  • The PWM spindle is not affected by this.

 

If using a Step/Dir Spindle, you may wish to do these three steps to help prevent clunking:

1) Make sure your Step/Dir Spindle is configured as motor 5 (see the previous paragraph).

2) Go to Mach4 Menu -> Configure -> Plugins… -> ESS v... - Warp9 Tech Design, Inc -> Motors tab and check the box for "Enable AntiClunk Mode for Servo Motors".

3) Change your screen set's stop button so it will feed hold stop instead of just dead stopping your Step/Dir Spindle motor.

 

 

 

 

 

 

 

 

 

 

Go to top