Switching a laser under Mach control.
With a laser the depth of cut is related to the time of exposure so that, for the same power setting, slow federates will cut deeper than fast federates. If there is any delay between the laser being switched on and the subsequent axis movement a deep spot is produced at the beginning of the kerf and likewise if there is any delay between the axis movement stopping, at the end of the kerf, and the laser being switched off another deep spot is also produced. This effect seems to be no problem when cutting right through or when profile cutting but it does cause problems and creates poor looking work when engraving (for example, a fine line engraved into a soft wood appears to have a dot at each end of the line). So to produce neat work, a method of rapidly switching the laser coincident with axis motion starting and stopping is necessary.
The existing spindle commands M3/M4 and M5 are really not suitable, mainly because of the delay they exhibit (after all they are designed to switch a spindle, which already has inherent spin up / down delay). Likewise the M7/M8 and M9 commands have similar (albeit not so much) delays. A command set which shows much less of a delay is the M11P1/M10P1 combination which will switch the Output #1 on/off at the exact time of the next axis movement. The 'P' relates to the Output# number where P1 would be Output#1, P2 would be Output#2 and so on.
Because Mach was a constantly evolving product (as of mid 2014 it's development ceased and no future revisions are planned following the introduction of Mach4) some of it’s routines / subroutines were rewritten with each new revision in order to create improvements in both speed and function. However, in some versions changes were made in the way Visual Basic or to be correct Cypress Basic routines, in particular, behave (what used to work perfectly subsequently needed some re-coding to work properly again – the Auto Tool Zero macro is a typical example of this).
At about revision R3.042.040 the M11/M10 commands stopped working correctly and following my discussions with Artsoft the problem was later resolved with revision R3.043.056.
During the period when M11/M10 was not working correctly I reverted back to 'plan B' of using an axis direction signal for laser switching. The technique here is to edit the existing GCode or modify the post processor used so that the +axis moves are just one step (in my case +0.002) and the –axis moves are also just one step (-0.002) then set the axis direction pin to the laser trigger pin allocation. The time delay between the axis completing the two virtual steps and the laser switching is so small that it can almost be considered instantaneous and when I return to engraving the fine line in a soft wood there is no longer a dot at each end of the line. In order to minimize any conflicts I chose to use my (imaginary) B axis direction pin for laser control where the B axis ‘steps per’ are set to 1 and the B axis direction pin is mapped to the laser trigger (pin 16 in my case) then any GCode is edited (or the post processor used modified) to replace the Z axis moves with B1 to turn the laser on and B0 to turn it off. Again these commands can almost be considered as instantaneous and tests have shown it to have equal results to when any other axis direction pin was used.
Returning to the M11P1/M10P1 command set – these undocumented calls were written into the original Mach code by Art (founder and creator of Mach3) for the sole purpose of controlling a laser or other fast acting device and they have quite special properties. The standard M commands (M3,M5) typically take 100mS between switching an output and the GCode continuing whereas M11P1 currently takes 2mS and M10P1 1mS under the same conditions.
So, for reliable operation, Mach3 revision R3.043.056 or later should now be used if M11/M10 laser switching is required.
Looking to the future and Mach4 there have now been discussions with various external motion controller manufacturer's and it has been decided to use the command set M62/M63. This may change if any conflicts are discovered but currently (Jan.2015) within Mach4 the command M62P1 will turn on Output#1 and M63P1 will turn off Output#1 and in most respects these commands behave in exactly the same manner as the Mach3 M11/M10 command set.
Just for fun, here is a short video of Mach4 in operation with my laser...
(Article partially re-written and up-dated as of 16th Jan. 2015)