spindle relay?

Sorry if this has been asked but I can’t find it. I want to be able to turn my spindle on and off by the software. I am using mini rambo. what do I need for parts (relay?) and where or how do I hook it up to the mini rambo board?

You can add a relay to a fan port but automating that is a dangerous game. You should never leave the CNC alone these can catch fire way more readily than a 3D printer.

So do I have to change anything in the Marlin firmware?

Can I just hook a relay from the fan pin to the power of my router and then give a command in the g code to start and stop it?

Are there any directions for the setup of this? And how to start and stop it in G-Code?

I hear you on the safety aspect. I’m always in the shop while this is cutting but it would be nice if I’m doing something else in the job stop that it would home itself or go back to 00 and shut the spindle off. Plus I like learning and playing around with these sort of things. So any setup of this or diagrams would be greatly appreciated.

You can do it with or without firmware changes. Gcode to turn the fan all the way on, 255, or all the way off, 0, will do it.

I have a PID controller coming hopefully really really soon. It will also be able to do this and so much more so maybe give me a week or so and I will do some sort of write up.

1 Like

Cool thanks looking forward to it. :slight_smile:

When I had one on my mpcnc I had the signal coming from the part fan header on the ramps board. Would issue an M106 to start the router and shop vac, they were attached to the same relay, then a M107 when done, or when I hit the software e-stop in repetier. Even though I don’t really leave it alone, it’s nice to have it stop the router when it’s done in case I went for a pee break, or am tooling around somewhere else in the barn.

1 Like

how fancy do you want to get?

The simplest solution is to listen to someone else and use a fan connection.



Marlin supports a M42 command to set a pin state: http://marlinfw.org/docs/gcode/M042.html

The pins refer to the atmega 2560 microcontroller. There are probably several pins that are not being used but probably are hooked up to a connector (like a fan, motor, GPIO)


This microcontroller is hooked up to a rambo board like this one

Find a pin that is not being used by tracing a candidate back to the microcontroller. If it is a digital pin it can be set to 1 (5v) or 0 (ground). This 5v can be used to power a 5v relay that can switch 120ac. One has to be careful not to choose a relay that will draw more current (mA) than the pin is rated for or it will burn. This can be checked on the datasheet for the atmega 2560.

If it is an analog pin then you can use M42 set a number from 0-255 (0-ground, 255=5volts) and now you could use that to control the speed of your spindle for example (need more electronics for that).

There is also an I2c bus on the rambo board and this can be used to talk to all kinds of hobbyist sensor or control boards. Since Marlin is open source you can edit the firmware to add a gcode command that does not exist to send messages through a wifi board to other automated devices in the room (like the robot arm with a paintbrush to paint your sign) or tweet a photo your project.




1 Like

Ah ha! Found it! I knew this would have been asked. Thanks Woodknack. Did you ever et this up? If so, how’d you go about it? I’m thinking of doing the same on my Rambo. Sounds like the fan pin is the easiest and it’s already in the firmware AFAIK so I suspect that’s the route I’ll go here.

@Ryan, did you ever do anything with a PID controller?

Yup PID is linked in the shop, I am sold out of the PCB’s though. I use it on my red and black machine.

Do I read that correctly that the PID controller will not only enable on/off but also speed?

Yup…but it not a polished “product” yet. Once it started working I wanted to add all sorts of bells and whistles so it got shelved until I can spend a large chunk of time on it to at least add a screen.

And bluetooth? ; )

nope that is for you to do.


That’d have so much more effect embedded…

[attachment file=96824]