<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel>
        <title>M42 on pwm pin only outputs 5V or 0V</title>
        <description> I&#039;ve been trying to use my prusa i3 printer with Marlin to move around a laser, switching it on and off using the command: M42 D11 SXX. The laser has TTL communication and should be able to support a pwm input. My board is an MKS Base (a single-board ramps 1.4 setup) and D11 is a pwm pin that is exposed to control servos.

The issue is that although I&#039;m able to switch the pin between output between 0 and 5V using M42 D11 S0 and M42 D11 S255, respectively, I can&#039;t get any values in between. Anything from S0 to S128 yields 0V and S128 to S255 gives me 5V. 

What&#039;s going on here? Why is D11 acting like a plain digital output? I&#039;ve tried the above on pins D12, A11, A12, and D2 (For D2 I disabled a max endstop, it&#039;s pullup resistor, and removed it from the sensitive pins list). I even edited out the &quot;digitalwrite&quot; line of M42 in Marlin&#039;s main.cpp. Always the same behavior. Is this a bug with M42? Is pwm disabled on my board for some reason? Am I crazy?

Thanks in advance.</description>
        <link>https://reprap.org/forum/read.php?147,651203,651203#msg-651203</link>
        <lastBuildDate>Fri, 11 Sep 2026 13:18:40 -0400</lastBuildDate>
        <generator>Phorum 5.2.23</generator>
        <item>
            <guid>https://reprap.org/forum/read.php?147,651203,651563#msg-651563</guid>
            <title>Re: M42 on pwm pin only outputs 5V or 0V</title>
            <link>https://reprap.org/forum/read.php?147,651203,651563#msg-651563</link>
            <description><![CDATA[ You can use any pin, which is not configured and used by a timer. Afaik there are at minimum two timers. OC1A for stepper and a second one for other tasks like ADC and co. Maybe a third one for advanced stepping algorithm.<br />
I would not use D10.]]></description>
            <dc:creator>Wurstnase</dc:creator>
            <category>Firmware - experimental, borrowed, and future</category>
            <pubDate>Tue, 12 Apr 2016 12:40:44 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?147,651203,651558#msg-651558</guid>
            <title>Re: M42 on pwm pin only outputs 5V or 0V</title>
            <link>https://reprap.org/forum/read.php?147,651203,651558#msg-651558</link>
            <description><![CDATA[ Ah okay, thanks Wurstnase. So I can't use D11 or D12 because Timer1 is being used for driving the steppers. What about D2 (unused x max endstop)? I believe this is on timer3. I also have an unused extruder (D10) but the connection is through a power transistor. If I'm desperate, could I solder a lead to the gate of this transistor and leave the source/drain floating? Thanks!]]></description>
            <dc:creator>heyisaacsback</dc:creator>
            <category>Firmware - experimental, borrowed, and future</category>
            <pubDate>Tue, 12 Apr 2016 12:16:52 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?147,651203,651447#msg-651447</guid>
            <title>Re: M42 on pwm pin only outputs 5V or 0V</title>
            <link>https://reprap.org/forum/read.php?147,651203,651447#msg-651447</link>
            <description><![CDATA[ Maybe the timer for that pin is already used in an interrupt.<br />
<br />
Edit: Yes, it's used for the stepper interrupt.]]></description>
            <dc:creator>Wurstnase</dc:creator>
            <category>Firmware - experimental, borrowed, and future</category>
            <pubDate>Tue, 12 Apr 2016 07:31:25 -0400</pubDate>
        </item>
        <item>
            <guid>https://reprap.org/forum/read.php?147,651203,651203#msg-651203</guid>
            <title>M42 on pwm pin only outputs 5V or 0V</title>
            <link>https://reprap.org/forum/read.php?147,651203,651203#msg-651203</link>
            <description><![CDATA[ I've been trying to use my prusa i3 printer with Marlin to move around a laser, switching it on and off using the command: M42 D11 SXX. The laser has TTL communication and should be able to support a pwm input. My board is an MKS Base (a single-board ramps 1.4 setup) and D11 is a pwm pin that is exposed to control servos.<br />
<br />
The issue is that although I'm able to switch the pin between output between 0 and 5V using M42 D11 S0 and M42 D11 S255, respectively, I can't get any values in between. Anything from S0 to S128 yields 0V and S128 to S255 gives me 5V. <br />
<br />
What's going on here? Why is D11 acting like a plain digital output? I've tried the above on pins D12, A11, A12, and D2 (For D2 I disabled a max endstop, it's pullup resistor, and removed it from the sensitive pins list). I even edited out the "digitalwrite" line of M42 in Marlin's main.cpp. Always the same behavior. Is this a bug with M42? Is pwm disabled on my board for some reason? Am I crazy?<br />
<br />
Thanks in advance.]]></description>
            <dc:creator>heyisaacsback</dc:creator>
            <category>Firmware - experimental, borrowed, and future</category>
            <pubDate>Mon, 11 Apr 2016 15:12:07 -0400</pubDate>
        </item>
    </channel>
</rss>
