Remap Pin D9 to Pin 44 for Laser PWM

I am adding a laser to my MPCNC with Arduino Mega 2560 with Ramps 1.4. To do this I am attempting to remap D9 fan to pin 44 (pin 7 of Aux2) for PWM control of the laser. I was running Marlin 1.0.1 and read that this had bugs in it. I have since updated to Marlin 1.1.8 which is supposed to be the latest and greatest. It is compiling and loading OK but my D9 is still active and pin 44 seems to be sitting around 2 VDC all the time regardless of what I have the fan set to.

Any tips on how to fix this? Is there a better pin for me to map to?

How are you remapping it? Are you sure you’ve changed the right place?

Thanks for the reply. I am remapping in the pins_Ramps.h


// Heaters / Fans


#ifndef MOSFET_D_PIN

#define MOSFET_D_PIN -1


#ifndef RAMPS_D8_PIN

#define RAMPS_D8_PIN 8


#ifndef RAMPS_D9_PIN

#define RAMPS_D9_PIN 44 //remapped 9 to 44


#ifndef RAMPS_D10_PIN

#define RAMPS_D10_PIN 10



That sounds right. Some Old Guy Coding walked through it in this video:

I don’t think he changed anything other than the one line “#define RAMPS_D9_PIN” Not sure exactly which version of Marlin he was working in, but it worked for me in the suggested version in the software download section here and on the new dual endstop version. Are you using the download from this site? Made other changes to the code? Maybe re-download Marlin and start fresh?

All I recall changing in the pins_Ramps.h was the following:

#define FAN_PIN 9 // (Sprinter config)


#define FAN_PIN 44 // (Sprinter config)


Mike I have used both the download version from this site and tried the latest Marlin had to offer.

Grasping at straws, but my setup uses the full graphic controller and I had to install the library for it, but I doubt that would have anything to do with this.

Perhaps I need to manipulate this?

#define SOFT_PWM_SCALE 0

Setting to 1 will double the frequency

#ifndef RAMPS_D9_PIN

#define RAMPS_D9_PIN 44 //remapped 9 to 44


That might not be active, if someone has set RAMPS_D9_PIN somewhere else. You can put in a message, to see if it’s being compiled:

#ifndef RAMPS_D9_PIN

#define RAMPS_D9_PIN 44 //remapped 9 to 44

#error Good news everyone the code is reaching this location


If you don’t see that error message when compiling, then it’s being set somewhere else. It doesn’t have to be that exact sentence, but it does have to be a futurama reference. :slight_smile:

1 Like

I’m looking closer at this fan code, and I’m not sure I like it at all. I think there might be a bug in it (said every software engineer about every piece of code, ever).

What about just setting the laser with M42?

M42 P44 S255
M42 P44 S0

You should be able to put that in your CAM software or gcode tools to control the laser instead, right? Is there something I don’t understand about the magic of the fan pin?

This just seems broken to me: (from Conditionals_post.h) #define HAS_FAN0 (PIN_EXISTS(FAN)). Seems like it should be dependent on FAN_PIN, not FAN.

That code looks really old, so I must be crazy.

Verify with this firmware, this is proven good. You could have a bad ramps board…


Some Old Guy Coding did that, but per his re-wiring video, 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.

Thanks everybody. I tried everybody’s suggestions to no avail. I went ahead and ordered a new ramps board and will try again when I get it. I can only assume at this point that that part of my board is bad.

Grettings, I have purchased 2 new Arduino/Ramps board combos since my last post, one had a defective Arduino and the other setups smoked when I applied power so they were non starters.

I brought home and O-Scope from work and found that on my original setup there is no PWM on either the D9 Pin or the remapped pin 44 which explains whey I can’t drive the laser. Its still possible that something is wrong with the Ramps board.

Question: Is there any other setups that I should worry about to enable PWM?

Question: Is there another hardware combo other than the Arduino/Ramps that I could use to drive the MPCNC with a laser?

All boards. I had to switch to the Ultimachine line of boards, I have not looked back since. The import ramps have just been compromised too far.

1 Like

Are you saying I should consider the Ultimachine manufactured Ramps board?

Thanks Ryan. Pleas excuse my questioning, I have been messing with for a month and am fairly frustrated. With the mini Rambo 1.3, what LCD’s does it support? Can I still use the same LCD I used on my Ramps wish SD support?

Do you have a version of firmware already setup for Laser TTL PWM? Instructions for wiring?

Understandable, Imagine that times a few hundred boards / customers. Yes all the same LCD’s.

I don’t have a laser firmware for any board. The instructions should link to the mini-rambo edits. If they are not on linked on the laser page let me know and I can find them after shipping this evening.