Skip to content

M106/M107 synchronization with motion for use with laser modules (on fan pins)#16077

Closed
DrywFiltiarn wants to merge 6 commits intoMarlinFirmware:2.0.xfrom
DrywFiltiarn:feature/synchronous-m106_m107
Closed

M106/M107 synchronization with motion for use with laser modules (on fan pins)#16077
DrywFiltiarn wants to merge 6 commits intoMarlinFirmware:2.0.xfrom
DrywFiltiarn:feature/synchronous-m106_m107

Conversation

@DrywFiltiarn
Copy link
Contributor

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:
IMG_1987
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:
IMG_1992
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:
IMG_1998
IMG_1999

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.

@DrywFiltiarn DrywFiltiarn changed the title M106/M107 motion synchronization (for use with laser modules) on fan pins M106/M107 synchronization with motion for use with laser modules (on fan pins) Dec 2, 2019
@shitcreek
Copy link
Contributor

shitcreek commented Dec 3, 2019

Is all this change neccesary since the solution was simply to remove the limit check_axes_activity frequency as suggested in #16058 ?

@DrywFiltiarn
Copy link
Contributor Author

DrywFiltiarn commented Dec 3, 2019

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.

@thinkyhead
Copy link
Member

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 bugfix-2.0.x branch and be careful to target bugfix-2.0.x when resubmitting the PR. It may help to set your fork's default branch to bugfix-2.0.x.

See http://marlinfw.org/docs/development/getting_started_pull_requests.html for full instructions.

@thinkyhead thinkyhead closed this Dec 3, 2019
@DrywFiltiarn DrywFiltiarn deleted the feature/synchronous-m106_m107 branch December 3, 2019 08:39
@MichaelDu9226
Copy link

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:
IMG_1987
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:
IMG_1992
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:
IMG_1998
IMG_1999

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.

@MichaelDu9226
Copy link

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:
IMG_1987
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:
IMG_1992
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:
IMG_1998
IMG_1999

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.

@DrywFiltiarn
Copy link
Contributor Author

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:
IMG_1987
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:
IMG_1992
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:
IMG_1998
IMG_1999

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.

The image was generated using Lightburn (free trial for one month)

@MichaelDu9226
Copy link

Thanks.A very nice software for me

@Sebbb
Copy link

Sebbb commented Aug 13, 2020

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.

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