<p>I am using LightBurn to laser engrave on wood. I am just trying to print some letters. </p>

<p>In the softwares preview the output looks correct. The black part is where the laser should burn and the red part are traversal/scan lines
<a href="https://i.stack.imgur.com/nLs8P.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nLs8P.png" alt="enter image description here"></a></p>

<p>When i actually print it the negative space is burnt by the laser (basically where the traversal/scan lines are shown in the preview above)</p>

<p><a href="https://i.stack.imgur.com/DjRPw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DjRPw.png" alt=""></a></p>

<hr>

<p>What I was able to figure out is that:</p>

<ul>
<li><code>M42 P4 S255</code> properly turns on the laser when I send this command on its own,</li>
<li><code>M42 P4 S0</code> properly turns off the laser.</li>
</ul>

<p>But the issue is when I send the following G-code, the following happens:</p>

<pre><code>M42 P4 S255 &lt;--- Laser turns on for a flash of a second
G1 X15 &lt;--- By the time the movement starts the laser is already off.
M42 P4 S0
</code></pre>

<p>When i stopped using PWM (via the D11) and instead connected directly to D9 (which is for the fan) this issue stops occurring. So this issue is only occurring when I use PWM. Any Guidance on what to check</p>

<p><strong>Update:</strong> I read the following on another forum. This might be the root cause here.</p>

<blockquote>
  <p>M42 is an immediate command and would turn on the laser before it reached its intended start point, M106 and M107 are buffered so the on/off can happen in its intended locations.</p>
</blockquote>

[{'answer_id': 10287, 'author': 'cmm', 'author_id': 2082, 'author_profile': 'https://3dprinting.stackexchange.com/users/2082', 'pm_score': 2, 'selected': False, 'text': '<p>This is too long for a good comment but may fall short of being a true answer.  If the mods prefer, I can recast it as a set of comments.</p>\n\n<p>There are several differences between using a GPIO pin as a binary data pin and using one as a PWM pin, and the behavior depends on several factors:</p>\n\n<ol>\n<li>Is the PWM pin a native PWN pin with hardware support, or is the PWM function being implemented with software?</li>\n<li>Has the PWM pin been initialized as a PWM pin?</li>\n<li>What processor type is used?</li>\n<li>What is the PWM frequency?</li>\n<li>Is the pin a TTL compatible output [0.4 V low, 2.7 V high]?  CMOS?  What Vcc?</li>\n<li>For that matter, what is the CPU?</li>\n</ol>\n\n<p>As @0scar points out, the fan control pin is typically not connected directly to the fan, but instead uses a FET to provide isolation and switch more current than the output pin can provide.  Depending on the circuit, it may be inverting or non-inverting.  M42 Pxx S255 may be full on or full off.  When the fan is controlled through the fan G-code, the firmware can take possible inversion into account.</p>\n\n<p>You haven\'t said what the input circuit to the laser involves.  </p>\n\n<ol>\n<li>It is active high or active low?  </li>\n<li>Does it require a pulse train to keep the output on, or is it\nstatic?  I don\'t know how yours works, but I could imagine designing\na laser module to require a continuous stream of pulses to keep the\nbeam active so that a failure in the drive circuit could not create\na safety hazard.</li>\n<li>Is it a TTL compatible input [0.7 low, 2.4 high]?  CMOS?  What Vcc?</li>\n<li>Is it something else?</li>\n</ol>\n\n<p>Laser etching is generally on-topic for this group given the close association with 3D printing tech, but people are less familiar with the "standard systems".  For some of us to be helpful (especially for me to be helpful) we need more of the circuitry and firmware context.</p>\n'}, {'answer_id': 10741, 'author': 'codeNinja', 'author_id': 16492, 'author_profile': 'https://3dprinting.stackexchange.com/users/16492', 'pm_score': 4, 'selected': True, 'text': '<p><code>M42</code> command is an immediate command. This means that it will run before the move GCode commands finish. This is exactly what I was facing. </p>\n\n<p>This video has the walk-through of solving the issue: <div class="youtube-embed"><div>\r\n                <iframe width="640px" height="395px" src="https://www.youtube.com/embed/LEjgp77TIy4?start=625"></iframe>\r\n            </div></div></p>\n\n<p>Here is the relevant PDF it talks about: <a href="https://www.v1engineering.com/wp-content/uploads/2016/01/MPCNC-laser-add-on-walk-through-Rev2.0.pdf" rel="nofollow noreferrer">The 2.8 watt, $100 Laser\nUpgrade for MPCNC</a>.</p>\n\n<p>Here is the relevant section on page 7 of the PDF:</p>\n\n<blockquote>\n  <ol>\n  <li><p>The laser driver requires a 5 volt TTL input control signal. The\n  Marlin fan control Mcodes (M106 and M107) will be used to\n  control the laser .Unfortunately, the Ramps fan output (D9) is a\n  12 volt signal so we can’t use it. We\'ll need a quick firmware edit\n  to remap the fan output from pin D9 (12v) to pin 44(5v).</p></li>\n  <li><p>Make a backup copy of your Marlin firmware folder first. Open\n  the pins_RAMPS_13.h file in your Marlin firmware folder with a\n  text editor (Wordpad). Search for the line where the fan pin is\n  assigned and change it from pin 9 to pin 44.</p></li>\n  <li><p>Save the changes and flash the revised firmware back onto your\n  Mega board. </p></li>\n  </ol>\n</blockquote>\n'}]
['https://3dprinting.stackexchange.com/questions/10010', 'https://3dprinting.stackexchange.com', 'https://3dprinting.stackexchange.com/users/16492/']