M106/M107 synchronization with motion for use with laser modules (on fan pins)#16077
M106/M107 synchronization with motion for use with laser modules (on fan pins)#16077DrywFiltiarn wants to merge 6 commits intoMarlinFirmware:2.0.xfrom DrywFiltiarn:feature/synchronous-m106_m107
Conversation
|
Is all this change neccesary since the solution was simply to remove the limit check_axes_activity frequency as suggested in #16058 ? |
Personally I think it is. Because increasing or removing the 10Hz limit from check_axis_activity does still not guarantee synchronization between the fan pwm and motion. In fact it would potentially cause worse issues I think. As G0/G1 moves go into the planner, it will then proces any incoming M106/M107 code. If it gets processed more often it will be out of sync even worse then it already is. Also I did not like removing that check rate as it’s there for a reason, namely reducing cpu cycles spent on side processes that are less important (to a degree) than motion and other tasks. |
|
Thanks for your contribution! Unfortunately we can't accept PRs directed at release branches. We make patches to the bugfix branches and only later do we push them out as releases. Please redo this PR starting with the See http://marlinfw.org/docs/development/getting_started_pull_requests.html for full instructions. |
|
|
The image was generated using Lightburn (free trial for one month) |
|
Thanks.A very nice software for me |
|
I assume, this patch is not necessary anymore since Marlin 2.0.6, as setting the laser intensity inline with S.. for the next movement works perfect. |





Requirements
Improving laser grayscale scan-line engraving using Marlin on a 3D printer or purpose build machine, when using a fan-port to control the PWM signal to fire the laser module.
Description
This feature change is aiming to implement synchronous support of M106/M107. The goal of this is to take back control of when these commands fire in the motion cycle of Marlin, so that they can be used to fire the laser at the right moment or turn it off again at the right moment. Default nature of Marlin is to apply M106/M107 gcode commands as soon as it can through use of an interval controlled (~10Hz) call on check_axes_activity() in the planner.
Both the "as soon as possible" and the low call rate of the check_axes_activity() method prevent high quality laser engraving through the fan ports.
Situation before the changes contained in this pull request:

In above image you can clearly see the misfiring of the laser module. It has lines where they should not be due to the laser falsely being turned out, and on the other side it's missing lines where there should have been.
The same engraving redone with the changes contained in this pull request:

This image shows that the synchronization of the pwm controls with M106/M107 has a great impact on the engraving quality. Note that the speed of this image at 10mm/s is due to the fact it was testing with a low power 500mW laser, so going fast won't do much otherwise. The synchronization principle is fully functional with high(er) speeds as well.
Benefits
The M106/M107 commands will become synchronized and will get executed in order of communication to Marlin, which allows highly accurate firing of a laser module on a printers part cooling fan pwm port.
With synchronized M106/M107, people that want to run laser modules on their 3D printers (and may be limited to using the fan port, i.e. Creality Ender for instance with the stock board), can achieve very high quality laser engravings, something that can't be done without the synchronized M106/M107 commands.
Some more examples of the results with the changes in this pull request:


Related Issues
Use of M106/M107 has been mentioned in the following ticket, as well as example pictures of the issue of non-synchronous fan pin control in the planner.