Skip to content

Feature: Add Laser Inline Power control#153

Merged
scotthsl merged 1 commit intoSnapmaker:mainfrom
brent113:laser-inline_power
Jan 17, 2022
Merged

Feature: Add Laser Inline Power control#153
scotthsl merged 1 commit intoSnapmaker:mainfrom
brent113:laser-inline_power

Conversation

@brent113
Copy link

This pull request adds a new feature: Laser Inline Power. This greatly enhances job completion time and quality for many types of jobs.

This pull request implements a feature from Marlin that was added to Marlin after Snapmaker forked. This addition is based on the work contained in this pull: MarlinFirmware/Marlin#15335. Inline laser power is also a standard feature on GRBL firmware, another common laser cutter firmware.

Summary of New Features

  • Enables optional use of inline power control by using a new I parameter on M3-M5 in the form of M3 Pxx I (https://marlinfw.org/docs/gcode/M003.html)
  • Increases compatibility by adding traditional power specified with the 0-255 S parameter in form of M3 Sxx
  • Adds optional new parameter Sxx and Pxx to G0-G3 movement commands to move with inline laser power specified in the form of G1 Yxx Pxx. (https://marlinfw.org/docs/gcode/G000-G001.html)
  • A G28 home command disables the laser for enhanced safety.
  • Increases compatibility by adding traditional power specified with the 0-255 S parameter in form of M3 Sxx

Additional Changes

  • A G28 home command disables the laser for enhanced safety.
  • Modified how the fan and power limits are controlled in toolhead_laser.cpp to accommodate calls from within the stepper ISR by not triggering CAN communications within the ISR.
  • Removes handler for unsupported air assist / coolant controls so that they return the standard unknown gcode handler so as to properly communicate to controlling software that air assist is unavailable.

When not enabling laser inline power the machine behaves the same as previous firmware, with the exception of the change made to G28.

Description of Laser Inline Power Behavior

When enabled by using the I parameter laser control is moved into the planner and motion control modules to allow for smooth power changes.

First a review of previous laser power control:
The M3 command first calls planner.synchronize(); which waits for all motion to complete. The machine decelerates and comes to a stop, then the laser power is changes, and then the machine accelerates to continue. Each deceleration/acceleration results in additional dwell that affects the accuracy of dwell timing, resulting in a slightly darker than intended laser burn. This is most pronounced when using continuously variable power in software like Lightburn (Lightburn calls this 'grayscale' mode, which is not dithered).

New behavior of laser inline power
Control of the laser power has been moved into the planner and stepper ISR. The planner adds the requested power onto the motion block. As the blocks are executed in the stepper ISR the laser power is scaled with acceleration trapezoid to eliminate darkening caused by the machine moving at less than the commanded speed with the full laser power.
image

As the laser power is being controlled via the planner the planner.synchronize(); is not necessary which allows the machine to use optimized exit and entry velocities similar to 3D printing.

Comparison between old and new behavior
Here is a sample from a job using grayscale mode from Lightburn without laser inline power. Each concentric circle on the left and vertical line on the right is where the laser power changed, resulting in a pause as the motion came to a stop and resumed.
image

By enabling laser inline power and eliminating harmful motion pauses the job completes approximately 2x faster and is of higher quality.
image

When Lightburn or other software is configured to use inline power it generates gcode similar to the following:

G1 X0.3 S131.3
G1 X0.7 S130.1
G1 X0.1 S129.5
G1 X0.8 S128.9

@brent113
Copy link
Author

brent113 commented Oct 14, 2021

This patch was developed primarily on firmware v1.10.1. ~6 people have been testing this with me without issue for the past year.

Changes from the recent firmware were merged but there has been minimal testing done compared to with v1.10.1. Testing has now been done on the most recent firmware, and all functionality is identical.

Testers have reported speedups of jobs generated in Lightburn with inline power of up to 4x compared to Luban jobs due to the elimination of pauses.

This pull request maintains full compatibility with Luban. However, additional value would be added in the future by enabling inline power gcode generation within Luban to reduce job completion times.

@scotthsl
Copy link
Collaborator

Hi @brent113
Thank you very much for your contribution! We are recently optimizing the performance of laser engraving in snapmaker 2.0, which will improve the efficiency and quality.
We are currently doing internal testing on the above optimization, after testing we will integrate this FEATURE you submitted and then test it together, thanks again for your contribution to snapmaker2.0.

Best Regards
Scott

@brent113 brent113 closed this Nov 20, 2021
@brent113 brent113 deleted the laser-inline_power branch November 20, 2021 18:17
@brent113 brent113 restored the laser-inline_power branch November 20, 2021 18:18
@brent113
Copy link
Author

brent113 commented Nov 20, 2021

Rebased onto latest Snapmaker commits

@brent113 brent113 reopened this Nov 20, 2021
@prueker
Copy link

prueker commented Dec 1, 2021

@scotthsl is there any update how the testing is going and an ETA when we can expect this to be released into the firmware?

@snapmaker-lixiaolong
Copy link

Hi @brent113
Thank you very much!
Today we have packaged and submitted your PR sumission to our testing team and it is currently being tested.

@scotthsl scotthsl merged commit d8413db into Snapmaker:main Jan 17, 2022
@pauserratgutierrez
Copy link

Any update on this? When it's gonna be available for us?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants