DW660 Relay / Octoprint

I’m running ramps 1.4 and using a generic 5v 2 CH relay to turn the router on/off. It uses pin 57 on the ramps and M42 P57 S0 to turn it on and M42 P57 S255 to turn it off . It works great manually sending the code or running a file from sd card. My problem is when I run a file though Octoprint it shuts the router off during the last pass before the movements are actually finished. Sometimes only an inch to go, other times half way though the pass. Could I just add a pause or delay before the M42 P57 S255?

I use a similar setup. But I use the fan pins instead. and Just send a M106 to turn on and a m107 to turn off. I haven’t had any problems with it turning the router of early. Also you can toggle the router on and off with the fan button in octoprint. I have modified the post processor in fusion 360 to add the G-code automatically.

here is my start G-code

;1001
;T11 D=3.175 CR=0 - ZMIN=-14 - flat end mill
G90
;Units in mm
G92 X0 Y0 Z20
M84 S1800 ;Change Stepper disable timeout to 30 minutes
M106 ;Turn on spindle

;Inside-1
G1 Z15 F400

and my end G-code

G1 X521.501 Y173.046 Z-13.683 F250
G1 Z15 F400
M107; Turn spindle off
G1 X0 Y0 Z20 F2000
M84 S1800 ;Change Stepper disable timeout to 30 minutes

The problem is that the M42 command is bypassing the planner, so it happens right away. The M3,M5, M106,M107 get added to the planner’s list of things to do, so they would happen after all the other movements finish.

I think the delay would also just go into the queue, and the M42 would happen before the delay was done.

Another option is to connect the relay to the pi, and have it start/stop before each print job. I don’t know why I haven’t tried that before. I wrote a tutorial on thingiverse to do that with my printer and a light:

That’s pretty easy - insert M400 before your M42

http://marlinfw.org/docs/gcode/M400.html

But proper way is enable cnc/laser features in the firmware and define a pin used by M3/M5

Thanks for the replies. I currently use the fan pins and M106/M107 for my laser. I was trying to avoid using them for the router as well. I run Octoprint on a PC, I wouldn’t know where to start hooking up the relay to it.

How can I enable the cnc/laser functions in marlin to make use of M3/M5 ?

I found this on Marlinfw.org But I can not find it in the pins_RAMPS.h

In the pins_MYBOARD.h file for your board make sure the following pins are defined:
#define SPINDLE_LASER_ENABLE_PIN xx   // digital pin

http://marlinfw.org/docs/configuration/laser_spindle.html

Configuration_adv.h

//#define SPINDLE_LASER_ENABLE
#if ENABLED(SPINDLE_LASER_ENABLE)
...
\src\src\pins\pins_RAMPS.h
//
// M3/M4/M5 - Spindle/Laser Control
//
#if ENABLED(SPINDLE_LASER_ENABLE) && !PIN_EXISTS(SPINDLE_LASER_ENABLE)
#if !defined(NUM_SERVOS) || NUM_SERVOS == 0 // try to use servo connector first
#define SPINDLE_LASER_ENABLE_PIN 4 // Pin should have a pullup/pulldown!
#define SPINDLE_LASER_PWM_PIN 6 // MUST BE HARDWARE PWM
#define SPINDLE_DIR_PIN 5
#elif !(ENABLED(ULTRA_LCD) && ENABLED(NEWPANEL) \
&& (ENABLED(PANEL_ONE) || ENABLED(VIKI2) || ENABLED(miniVIKI) || ENABLED(MINIPANEL) || ENABLED(REPRAPWORLD_KEYPAD))) // try to use AUX 2
#define SPINDLE_LASER_ENABLE_PIN 40 // Pin should have a pullup/pulldown!
#define SPINDLE_LASER_PWM_PIN 44 // MUST BE HARDWARE PWM
#define SPINDLE_DIR_PIN 65
#endif
#endif

Thanks Guffy. For using it just to control a relay which should I use for the relay pin, SPINDLE_LASER_ENABLE_PIN or the SPINDLE_LASER_PWM_PIN ?

i think SPINDLE_LASER_ENABLE_PIN

1 Like

Again thanks for your help. Maybe I’m missing something but my Configuration_adv.h has no section to enable the spindle… I don’t see a spindle section at all. Do you know if the pre-configured firmware on here has those options in it? Or do I need to download new firmware?

This is from marlin 2.0. I didn’t check 1.x

1 Like