Just to be clear, I don’t have a laser, nor do I control my spindle speed from a pin. My advice comes from crawling around in the Marlin files, and I have helped several people getting their laser working or solved other pin-related issues.
Also, in version.h, i am seeing that it is version 2.0.7.2. I do need see any references to V510 or V509.
This is a bit troubling. This means you are not using the source from the V1 maintained github release point. Your version number is coming from version.h. The V1 maintained versions override that number with this line:
#define STRING_CONFIG_H_AUTHOR "(V1 Engineering, Ryan, 510S)"
This also means that any of my assumptions about the status of what is enabled or disabled in the firmware go out the window.
So there are a couple of things to look at. First, let’s figure out what pin is getting defined as the laser pin. There may be more elegant ways, but I suggest you go to this line in your pins_ramps.h file:
#define SPINDLE_LASER_PWM_PIN
Insert just above this line some garbage. Typing “asdf” on that line will do it. Anything that will not compile. Try and compile the file. If you get an error, you know that area of the code is getting compiled, and therefore almost certainly the spindle enable will use pin 4 and the PWM will use pin 6. If it does not compile, then you know you have some setting issue that is not executing that code, so either some other pin is being used, or no pin at all.
If the pin is okay, then you will need to start checking how you have your spindle setup. For example, this define:
#define CUTTER_POWER_UNIT
…sets how the values in your M3 are interpreted. If it is set for RPM and you are using PWM values, the spindle will never come on. That is, if it is set to RPM it is by default going to expect and values between SPEED_POWER_MIN (5000) and SPEED_POWER_MAX (30000), so a value of 255 will be interpreted as ‘off’.
Edit: While you should be able to get this working, if all you are doing is turning your spindle on and off, you can use a fan pin and a M106 and M107 to control the pin. This is what I do. If your relay expects 5V, you will need to reassign one of the fan pins to an available 5V pin.