Spindle Enable Pin

Okay so there might be some topics that discuss this already, but im struggling to find my answer on here or googling in general. Below is my pins_ramps.h code and it says that my spindle enable pin is 4. However, I am struggling to determine which pin on the Ramps1.4 is actually pin 4.

Can anyone point out which pin is pin 4?

//

// M3/M4/M5 - Spindle/Laser Control

//

#if HAS_CUTTER && !defined(SPINDLE_LASER_ENA_PIN)

#if !NUM_SERVOS // Use servo connector if possible

#define SPINDLE_LASER_ENA_PIN              4  // Pullup or pulldown!

#define SPINDLE_LASER_PWM_PIN              6  // Hardware PWM

#define SPINDLE_DIR_PIN                    5

#elif HAS_FREE_AUX2_PINS

#define SPINDLE_LASER_ENA_PIN             40  // Pullup or pulldown!

#define SPINDLE_LASER_PWM_PIN             44  // Hardware PWM

#define SPINDLE_DIR_PIN                   65

#else

#error "No auto-assignable Spindle/Laser pins available."

#endif

#endif

According to this diagram, D4 is in the Servos block (bottom of the image). Given the orientation of this graphic, D4 is the top right pin in the Servos block. Note that the labeling is offset to the left of the pin blocks with a line indicating which block is being called out.

I did try that pin actually. I connect positive to D4 and ground to the GND pin, skipping the middle servo pin. Is that correct? I tried that setup and issued the M03 command in Repetier-Host and no luck. I have verified that the spindle turns on by touching a hot pin on the board and it switched the relay to turn the spindle on. So I have ruled that out. Just cant seem to write the D4 pin HIGH and LOW with the M3 and M5 commands.

A couple of things to check out. First, make sure the laser stuff is enabled. I know that laser support was not enabled in v509 of the firmware, but I’ve not checked v510. Here I did a diff of the Ramps and Rambo firmware.

The other issue I’ve seen is that some laser users were either failing to get the M3/M4 g-code to work or were getting bad results. When they went to inline commands, everything worked. Take a look at the g-code in the first post of this topic. The code uses the ‘S’ parameter of the G0 and G1 to control the laser.

I’m not sure how your defines are processed. You might also want to check pin 44.

#if HAS_CUTTER && !defined(SPINDLE_LASER_ENA_PIN)

In this line here (beginning of the code i previously posted), is it possible that it is not entering this ‘if’ statement? I am not sure about “HAS_CUTTER” and I cannot find where the SPINDLE_LASER_ENA_PIN is enabled, other than within the if statement that follows. But I have a feeling its not entering this if statment at all because the requirements might not be met.

Opinion?

So did you go through the diff I pointed you to in my last post? Laser support is not enabled in v510 of the Ramps firmware maintained by V1. I just checked. You have to make the changes in Configuration_Adv.h that are outlined in that diff. For example this line:

//#define LASER_FEATURE

If this does not get uncommented, then none of the laser features will work.

So if you’ve made those changes and it still does not work, let me know and we can debug some more.

Below is code that shows in my configuration_adv.h.

#define SPINDLE_FEATURE

//#define LASER_FEATURE

#if EITHER(SPINDLE_FEATURE, LASER_FEATURE)

#define SPINDLE_LASER_ACTIVE_STATE LOW // Set to “HIGH” if the on/off function is active HIGH

#define SPINDLE_LASER_PWM true // Set to “true” if your controller supports setting the speed/power

#define SPINDLE_LASER_PWM_INVERT false // Set to “true” if the speed/power goes up when you want it to go slower

#define SPINDLE_LASER_FREQUENCY 2500 // (Hz) Spindle/laser frequency (only on supported HALs: AVR and LPC)

I have only defined SPINDLE_FEATURE, as I am using a spindle, not a laser.

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.

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.

1 Like

First, I apolgize, I do have the line:
#define STRING_CONFIG_H_AUTHOR “(V1 Engineering, Ryan, 510S)”

Second, I do wish to only turn the spindle on and off with no speed control. So I just tried connecting to the two pin header directly adjacent the X stepper motor driver and it seems that is always actively high no matter what command i send. The spindle comes on and stays on. Do i need to change the firmware for this fan header in any manner?

The pin you highlight is 12V always on. Looking through the source in pins_ramps.h, what pin to use will depend on other defines. If any fan pin is enabled (and at least one should be), it will be D8, D9 or D4. D8 is most likely, but there is a weirdness in the pinout diagram. D8 is listed on the board, but the callout for the pin lists D11. Anyway, turn the fan on in g-code and test D8 and D9 (since you already have tested D4).

Edit, some of the defines list FAN1 while other list only FAN. They may be zero based, so in your fan g-code you want to test both 0 and 1.

Just to be clear, D8 and D9 are both screw terminal ports for heated beds and such correct?

Correct, and they will be 12V, so your relay needs to support 12 volts.

D9 works! What a relief. This will work perfect for now, however later down the road I probably will switch to spindle (M3) commands/controls rather than using the fan controls and incorporate PWM spindle control as well. But for now, I am set.

Thanks for your help and quick responses! It has been a life saver.

Glad you got it working. Just for future reference, did you include an index with the M106 command, and if so, which one?

I am not sure what you mean by index. If you mean assigned a speed value with M106, no I did not. Just simply used M106 and the M107 to turn if off.

I am not sure what you mean by index

Many boards have multiple fan pins. For example the Rambo 1.4 board has three, so I could:

M106 P2 S128

…to turn fan 2 on at half power. So without an ‘P’ parameter, you would be turning on Fan 0.

Edit: Not that you need it, but you might find that D8 is assigned to Fan 1.

1 Like

Oh okay I see! Thanks for the help Robert

D4 is the PWM signal pin on the servo connector. I use D4,D5,D6 for rgb led strips on my 3D printer since they’re easier to grab and right next to each other on the ramps board. The servo uses steady 5v dc + and - for motor power but the PWM signal on the signal pin says where to move to. This is the signal being retasked for spindle enable.

1 Like