High Voltage Warning

The Laser module is the part of Smoothie that allows you to control laser cutters.

In general, laser cutters use a CO2 tube to generate the laser beam used for cutting and engraving.

Those tubes contain CO2 gas, and a high-voltage Power Supply Unit is used to pass electricity through the gas, generating the beam.

Using G-code, you tell Smoothie where to move and when to cut.

Smoothie moves the motors, and the Laser module talks to the laser power supply to tell it when to turn off and on, and using how much power.


Be very careful with the laser tube side of your Power Supply: voltages there are commonly around 40,000 volts, making it very dangerous. If you are not qualified to handle this kind of voltage, please contact a professional. Always make sure everything is powered down before manipulating anything. For laser cutters, you will get some extra features (in particular nice laser-specific screen information on panels) if you use the "cnc" version of the firmware. Though the normal (edge) version will work fine. See flashing the firmware and choose the file called firmware-cnc.bin.

Wiring

In order to control the power of the laser tube, the laser PSU reads a PWM signal as its input.

Please look at the datasheet for your PSU to know which connection that signal is wired to.

From the Smoothieboard, you need to connect:

  • One GND pin to the Ground connection on the PSU
  • One of Smoothie’s PWM pins to the PWM input on the PSU

Both Ground pins are easy to find, and the PSU input you find in the manual/datasheet, now all you need is to find a PWM pin on the Smoothieboard.

There are 6 of them, but 4 of them are used for the step pins for stepper motor drivers.

Those for alpha and beta you won’t be able to use as you use those drivers to control the X and Y axes.

Depending on whether you have a Z axis, your gamma axis step pin could be used.

It is labelled ST3, on the JP12 header, near the M3 stepper motor driver.

You probably do not use your delta (M4) stepper motor driver on a laser cutter, so that pin can also be used, it is labelled ST4 on the JP15 header near the M4 stepper motor driver.

The other two are found near the microcontroller and the MOSFETS, on the JP33 header, and are labelled PWM0 and PWM1.

Choose which you will use, all have a GND header close-by (all are unlabelled) to make it convenient for wiring.

Now you need to find which GPIO pin/port number corresponds to the PWM pin you chose, so you can tell Smoothie which you’ll be using in the configuration file.

Pin number for configuration Label on the board Comment
2.2 STP3 Only if you are not using a Z axis/the gamma driver. Make sure you set gamma_step_pin to the “nc” value. The unlabelled pin in JP12 is GND.
2.3 STP4 Only if you are not using the delta driver. Make sure you set delta_step_pin to the “nc” value. The unlabelled pin in JP15 is GND.
2.4 PWM0 Only if you are not using the first small MOSFET (X8). All pins of JP10 are GND.
2.5 PWM1 Only if you are not using the second big MOSFET (X15). All pins of JP10 are GND.

Smoothieboard v2 has dedicated PWM outputs available on the Gadgeteer headers. These are high-resolution PWM outputs suitable for laser control.

Pin name for configuration STM32 Pin Location Comment
PWM1_1 PE9 Gadgeteer GD Timer 1, Channel 1 - High-resolution PWM
PWM1_2 PE11 Gadgeteer GD Timer 1, Channel 2 - High-resolution PWM
PWM1_3 PE13 Gadgeteer GD Timer 1, Channel 3 - High-resolution PWM
PWM1_4 PE14 Gadgeteer GD Timer 1, Channel 4 - High-resolution PWM
PWM2_1 PI5 Gadgeteer GC Timer 8, Channel 1

The Gadgeteer headers provide convenient 3-pin connections with signal, power, and ground for easy wiring.

Now that the PSU is wired to the Smoothieboard and that you know which pin you are using for control, you can change the configuration file to setup laser control.

Configuration

You now need to edit the “config” file on the SD card (the default configuration file already contains example laser lines so you may only need to edit/enable those) to add or setup the laser part as follows:

# Laser module configuration
laser_module_enable                          false            # Whether to activate the laser module at all. All configuration is
                                                              # ignored if false.
laser_module_pwm_pin                         2.5              # this pin will be PWMed to control the laser. Only P2.0 - P2.5
                                                              # can be used since laser requires hardware PWM
#laser_module_maximum_power                  1.0              # this is the maximum duty cycle that will be applied to the laser
#laser_module_minimum_power                  0.0              # this duty cycle will be used for travel moves to keep the laser
                                                              # active without actually burning
#laser_module_pwm_period                     20               # this sets the pwm frequency as the period in microseconds
[laser]
enable = true                # Whether to activate the laser module at all
pwm_pin = 2.5                # This pin will be PWMed to control the laser
                             # Only P2.0-P2.5 can be used (hardware PWM required)
#maximum_power = 1.0         # Maximum duty cycle applied to the laser
#minimum_power = 0.0         # Duty cycle for travel moves (keeps laser active
                             # without burning)
#pwm_period = 20             # PWM period in microseconds

If needed, replace the 2.5 value for with the pin you chose in the wiring section.

Save the file, reset the board, you are now ready for laser testing.

All options

V1 Setting V2 Setting Description
Whether to activate the laser module at all. All configuration is ignored if false. The laser module is used for laser cutting using a laser diode or CO2 laser tube. When set to `false`, the module is completely unloaded to free system resources. Must be enabled before any other laser settings take effect.
This pin will control the laser. Pulse width will be modulated to vary power output (PWM). The preferred and more descriptive parameter for specifying the PWM control pin for the laser. PWM duty cycle directly controls laser power output percentage. CRITICAL: Only hardware PWM pins are supported: 2.0 to 2.5, 1.18, 1.20, 1.21, 1.23, 1.24, 1.26, 3.25 and 3.26. Using non-PWM pins will disable the laser module with error message. Inverting pin logic with `!` prefix is useful for some laser driver circuits that are active-low.
DEPRECATED: Legacy parameter that specifies the pin controlling the laser through PWM. This setting has been superseded by for improved clarity. If this pin is not connected, the system will check instead. Only specific pins on the Smoothieboard support hardware PWM required for laser control. Use for all new configurations.
This pin turns on when the laser turns on, and off when the laser turns off. Provides a simple on/off signal synchronized with laser firing, independent of the PWM power level. This is a digital on/off signal, NOT PWM - it is either high or low. Commonly used to enable/disable air assist compressors, fume extraction fans, laser power supply enable pins for additional safety, or safety interlocks that monitor when laser is active.
This is the maximum duty cycle that will be applied to the laser. Value is from `0` to `1`. Acts as both a safety limit and calibration parameter - this value represents the highest power output the laser will achieve, even if G-code commands request 100% power. All S-values in G-code are scaled to this maximum. Example: Setting `0.8` means S100% produces 80% actual laser power. Useful for preventing damage to both materials and laser tube/diode. WARNING: Does not provide emergency shutoff - use kill switch for safety.
This duty cycle will be used for travel moves to keep the laser active without actually burning. Useful for some diode setups. Value is from `0` to `1`. Sets the minimum PWM duty cycle (baseline power) for the laser during travel moves and as a floor for all laser operations. Also known as "tickle power" or "keepalive power". Keeps laser diodes thermally stable by preventing complete shutoff and reduces thermal stress from constant on/off cycling. During cutting operations, the actual power is scaled between this minimum and the maximum power setting. WARNING: Non-zero values mean laser is always slightly active when module enabled.
DEPRECATED: This parameter has been deprecated and replaced by . It originally set a small baseline amount of power to keep the laser "tickled" (slightly active) during travel moves. If you have old configuration files using this parameter, it will still work as it provides the fallback default value for , but you should migrate to using instead for clarity and future compatibility.
Maximum S-value accepted from G-code commands. Determines the S-value range: set to `1.0` for S0.0-S1.0 range (standard), `100.0` for S0-S100 range, or `255.0` for S0-S255 range (common in laser software). The S-value is scaled to the 0-1 range internally based on this maximum. Does not affect actual laser power output, only G-code interpretation. Allows using G-code from different CAM packages without modification. Example: With `maximum_s_value=100`, S50 means 50% power.
Whether the laser power should be proportional to the current speed, so as speed of movement ramps up (and down), laser power is proportionally adjusted, so that the amount of laser power/quantity of photons for a given distance/area is always constant, even if speed has to increase/decrease progressively. This is true by default. Enables automatic power scaling based on actual instantaneous movement speed. When enabled (default), power calculation: `actual_power = requested_power × (current_speed / nominal_speed)`. Ensures uniform engraving depth and cutting quality despite speed variations, compensates for machine acceleration and deceleration automatically, prevents over-burning in corners where machine slows down. Can also be controlled at runtime via M221 P command. WARNING: Disabling may cause uneven cuts/engraving due to speed variations.
PWM frequency expressed as the period in microseconds. Sets the PWM period (and thus frequency) for laser control. The PWM frequency equals 1,000,000 divided by this period value. This frequency affects how smoothly the laser power can be controlled and must be appropriate for your specific laser driver electronics. The system uses this period to limit the maximum rate of power adjustments. Default is `20` microseconds.
Default S value for laser operations when no S parameter is specified in G-code. Represents laser power as a fraction from `0.0` (off) to `1.0` (full power). When G-code commands like M3 or M4 don't include an S parameter, this default value is used. Also serves as the initial power level before any S commands are received. Typical laser default is `0.8` (80% power). Set lower for testing, higher for production.

Example setup

Exactly how to wire your Smoothieboard to control your laser power supply is going to depend on the PSU itself, so we highly recommend you read the documentation for yours.

This is an example that should be the most common case, which you are most likely to encounter: the Chinese power supply with “H L P G IN 5V” connections.

In this example a RECI power supply but this should apply to most Chinese power supplies.

The basic idea is this: pin 1.23 (hardware PWM-capable) is configured as open-drain and inverted (1.23o!), then connected to the L (Low) TTL input on the power supply.

Ground from the Smoothieboard is connected to ground on the Power Supply.

The rest is specific to the supply: P is connected to G through the door switch and water protect circuits, this ensures that if the door is opened or the water chiller turns off, the laser is turned off.

Finally, IN is connected to 5V, setting the laser power at full (but it can still be modulated by Smoothie’s PWM).

Here you could in theory replace the jumper by a potentiometer, allowing you to manually adjust the maximum laser power.

The wiring looks like this:

Laser Power Supply Wiring

You then also need to configure the laser module accordingly:

# Laser module configuration
laser_module_enable                          false            # Whether to activate the laser module at all. All configuration is
                                                              # ignored if false.
laser_module_pwm_pin                         1.23o!           # this pin will be PWMed to control the laser. Only P2.0 - P2.5
                                                              # can be used since laser requires hardware PWM
[laser]
enable = true                # Whether to activate the laser module at all
pwm_pin = 1.23o!             # This pin will be PWMed to control the laser
                             # Only P2.0-P2.5 can be used (hardware PWM required)
                             # 'o!' means open-drain and inverted

Note on K40

The wiring above probably won’t work on a K40, which are fairly weird machines (cheap comes at a cost).

For K40, see the several build logs linked to at the top of this page.

In particular, you’ll likely need to increase the pwm frequency, and wiring might need to be different depending on your model.

Testing

Make sure your laser cutter enclosure is closed and that everything is safe. Wear laser protection googles, even if the machine is properly closed. Make sure your machine has a proper enclosure, and a switch on the door that turns it off when the door is opened. Do not do anything until this is properly setup. Lasers can make you blind. And bionic eyes are not there just yet.

Here is how Smoothie laser control works: G0 and G1 are exactly the same command, they take positional parameters (X10 Y5 Z3 for example) and move the tool to that position.

The only difference is that when using G0 the laser stays off, and when using G1 the laser is on, only during movement.

To test, try moving your laser with G0 and try moving it with G1:

G0 X10 F300
G1 X20 F300

You can set the power for the laser by using the S parameter. Values go from 0 (0%) to 1 (100%).

For example:

G1 X10 F300 S0.2

Supported G-codes

The following G-codes are supported by the Laser module:

  • G0: Move without activating the laser
  • G1/G2/G3: Move with the laser activated
  • S: The S parameter sets the current power of the laser, when it is activated, from 0 (0%) to 1 (100%).
  • M221 Snnn globally scales the laser power provided by G1 by nnn percent. So M221 S75 will scale the laser power to 75%.
  • M221 Rxxx: Set the PWM frequency to xxx Hz (Hertz). This specifies frequency, and not period, be aware and careful.
  • M221 P1: Temporarily disable proportional laser power (as per the laser_module_proportional_power configuration option, see its description for more details). This is not saved by the M500 command.

Supported commands

The following commands are available for testing (prepend @ in pronterface or M1000 in other hosts)

  • fire nnn where nnn is 0-100 percentage of power (example fire 10 will turn on laser at 10%)
  • fire off turn off the test fire and return to automatic mode.
If you want to learn more about this module, or are curious how it works, Smoothie is Open-Source and you can simply go look at the code, here.
This is a wiki! If you'd like to improve this page, you can edit it on GitHub.