How Do I set up a Laser?
Diode laser power supplies typically have an inbuilt time delay before the laser beam can be turned on. This allows time for the laser to generate a coherent beam and the internal voltages to stabilize. If you manually flip a switch to power the laser, that should give sufficient time before you start your GCode.
If you use a M3 command in your GCode to turn the laser’s power supply on, you must allow time for stabilization using a Pause, G4 command,or by setting an appropriate spindle spin-up delay. The M3 command activates an Output# which is mapped to an output pin which in turn activates a relay (or a solid state relay — SSR) to connect the necessary supply voltage to the laser power supply.
Once enabled the laser’s power is controlled using a PWM signal. Assuming for a moment that everything was linear, a 100% PWM signal would switch the laser ON to full power, a 50% PWM signal would give half power and a 0% PWM would turn the laser OFF.
The ESS generated PWM signal is mapped to an output pin (set active low) which is in turn connected to the TTL input of the laser’s power supply. It may be preferable to use an opto-isolator or SSR (or similar) here, just to protect the ESS, but be aware of signal inversion and don’t use anything that will cause any measurable delay to the PWM switching signal.
Since a GCode S### command breaks the Constant Velocity movement chain in Mach, it is not practical to change laser power level settings on a regular basis using S### commands. (The S### command and all Macro commands will cause a slight pause (possibly hundreds of milliseconds) to occur when they are executed — except for M11/M10 and M62/M63 discussed next.)
Mach3 incorporates the M11Px/M10Px commands which perform a very special function within GCode that is running – they can switch an Output# ON or OFF without breaking the constant velocity chain, and the changes are synchronized with the start of the next motion command (G0, G1, G2 or G3).
Mach4 incorporates the M62Px/M63Px commands which perform a very special function within GCode that is running – they can switch an Output# ON or OFF without breaking the constant velocity chain, and the changes are synchronized with the start of the next motion command (G0, G1, G2 or G3).
In a typical laser setup, an opto-isolator circuit is used to gate the PWM signal with the M62/M63 (M11/M10) output. The GCode command M62P1 (M11P1) allows the PWM signal to pass into the laser TTL input. The GCode command M63P1 (M10P1) prevents the PWM signal from getting to the TTL input. This allows you to quickly turn the laser’s output on and off as you move around the work area.
Once the job has been completed the laser is disabled (it’s power switched OFF) using the GCode M5 command, or manually with a switch.
(This article was originally written by Tweakie, and we edited it a bit.)