Spindle stop by gcode

Hi all,

If already solved in another thread, kindly ask to point by link.

I’d like to carry out spindle stopping after gcode is finished. Maybe there is some specific pin designated and corresponding Marlin command for it?

WARNING: Be careful when working with Mains voltages.

I assume familiarity with connecting Mains voltages through a mechanical relay such as the one shown in the picture. Be careful to check if the voltages and currents you plan to switch through the relay matches the specs on the relay.

The setup shown in the picture works for a Ramps board.

The control pin for the relay is connected to the PSON pin on the Ramps board (Brown wire). Mine is a 1.6, and other versions of the Ramps board may have the PSON pin in a different location.

VCC for the relay is connected to the VCC pin on the Ramps board (Red wire).

Edit the following lines in the Configuration.h file:

#define POWER_SUPPLY 0 --> #define POWER_SUPPLY 1

//#define PS_DEFAULT_OFF --> #define PS_DEFAULT_OFF

Insert M80 (turn on PSU) as part of your start code.

Insert M81 (turn off PSU) as part of your end code.

Thanks! Now yet ready to try, need to buy relay modules. Will report when done.

https://www.amazon.com/Iot-Relay-Enclosed-High-Power-Raspberry/dp/B00WV7GMA2/ref=sr_1_2?m=A3D4241373L385&marketplaceID=ATVPDKIKX0DER&qid=1559735268&s=merchant-items&sr=1-2

 

Just wire it to the part fan header and use gcode to start and stop the fan, which will power on and off the spindle.

Why is your relay’s GND connected to +5V on your RAMPS 1.6?

Looks to me like relay gnd is connected to ramps gnd on one of the servo slots.

My bad. I am inattentive this morning.

Here’s the problem.

In current uptodate marlin for MPCNC declaring “Default off” makes PSON pin to turn on. Meaning that when pin is +5V then it is “PSU off” state. Then you “M80” - PSON pin turns off. “M81” - PSON pin again +5V.

Which means that when I finish job and turn off arduino - spindle suddenly starts working. How safe and comfortable is that?

I’m not new to programming, I think I will handle it. Just an info.

I agree this is troubling. Good catch.

You’ve probably already solved it but I think it should be sufficient to instead use

#define POWER_SUPPLY 2

This appears to invert the logic so power on is active high instead of active low. Then use the normally open relay contacts instead of the normally closed ones.

Thanks, gotta try

Thank you for the heads up.

My Arduino and spindle are powered from the same circuit, i.e. the same on/off-switch/emergency-button kills both, which is why I haven’t seen the problem.

And… yes, finally I can confirm it works! :slight_smile: