If you just want the answer then here it is
The code is broken for 8 bit controllers trying to use RPM mode. PWM255 and PERCENT work.
In the code in the src file there is a line in class SpindleLaser that reads
return unitPower ? round(100 * (cpwr - SPEED_POWER_FLOOR) / (SPEED_POWER_MAX - SPEED_POWER_FLOOR)) : 0;
I tracked down a Github Marlin fixā¦ one word addedā¦ floatā¦
return unitPower ? round(100 * float(cpwr - SPEED_POWER_FLOOR) / (SPEED_POWER_MAX - SPEED_POWER_FLOOR)) : 0;
Make that change and you can set spindle speed from 0 to 50000 and get proper PWM output on Pin 4 (on RAMPS) which is the SECOND set of servo pins on the board.
How I got thereā¦
Total newbie here, just finished my MPCNC, RAMPS controller, dual endstops. Got it built, working, cutting, but was MANUALLY controlling the spindleā¦
Spindle speed control was my biggest hurdle of this project I thinkā¦First trying to figure out what pin was the PWM pin took me foreverā¦ Eventually figured out that the second servo set of pins does this on the RAMPS board.
Still didnāt workā¦ was missing somethingā¦
Once I found that I learned you have to modify the Marlin firmware to turn on the spindle control
#define SPINDLE_FEATURE
Had to uncomment this in Configuration_adv.h to ENABLE spindle control
And unfortunately while I was there I saw the options for spindle controlā¦ PWM255 (0-255 values for PWM); PERCENT (0-100 percent for PWM); RPM (0-50000RPM) and PWM255 is the default
I thought āhey, I want RPM not PWM255ā which was another define right there in the code.
THATS WHERE I SHOT THE HOLE IN MY FOOT!!!
The code is brokenā¦
PWM255 mode works
PERCENT mode works
RPM mode is broken (if you are using an 8 bit controller like a mega2560 used on the RAMPS configuration like I wasā¦)
I beat myself up for a long time on this before I even realized that PWM255 and PERCENT workedā¦
So I went with PWM255 and edited my ESTLCAM tools to set RPM to 255ā¦ (or whatever was approrpiate between 0 and 255)
But it bugged me so I went after it again todayā¦
Thats when I found some github commits on the Marlin siteā¦ I figured the issue I was having was that I grabbed the code from V1Engineering that was customized for dual endstops etcā¦ that fix wasnāt in thereā¦
So I downloaded Marlin direct from githubā¦ same RPM issueā¦ Huh?
Well in addition to being a newbie to MPCNC I am also pretty newbie to github so I didnāt know where to go from there other than back to the Marlin I downloaded from V1Engineering and just add the fix directly into my copy of the sourceā¦
Then I stumbled onto the V1Engineering forum and this topicā¦ so I figured maybe this post will help someone else get back many hours of their life that I never will.