I believe this is fully implemented…but I am actually not sure exactly how.
From looking at the code it appears to be on AUX port #1
From line 1217 in CNC_Functions.h:
void setSpindlePower(boolean powerState) {
/*
* Turn spindle on or off depending on powerState
*/
// Need to add settings to choose the method and pin number here
// but hard-code these for now
int controlPin = AUX1;
The gcodes in the ‘M’ family are decoded in CNC_Functions.h starting around line 1647 in ‘executeMcodeLine()’.
Codes 0, 1, 2, 3, 4, 5, 6 and 30 are implemented.
0 - program pause
1 - optional pause/halt/stop
2 - program end
3 - spindle on - clockwise
4 - spindle on counterclockwise (here, same as #3)
5 - spindle off
6 - tool change, pause for response
30 - program end with return to top
3 & 4 turn the spindle on, 2, 5, 6 & 30 turn it off.
So it looks like AUX1 (pin 17) should go high by the current firmware based on M codes when the router should be spinning, but you need to turn useServo to false as it’s not configurable on line #1226 in current master.
I’m going to confirm this works as expected, and start working on getting this configurable (servo vs GPIO) as a GroundControl option.
I don’t believe any of the AUX pins on the Maslow board can do PWM when hosted by an Arduino Mega, so on/off control is the only option. A different host (Teensy 3.6 or 3.6) could control a servo.
Rather than changing GroundControl, isn’t there an ‘S’ code in Linuxcnc that would set the spindle speed? Implementing that in the firmware would expand compatibility.
Right, but spindle speed isn’t supported by single speed routers, and this is in relation to the M codes for simply powering on/off the router. Spindle speed is only useful for setting RPM regardless of power state (M3/M4), which we cannot currently do, and what I’m working towards. Done with the code and testing it out now.
Correct me if i’m wrong but you can use a spindle speed output for on/off commands, you just set the PWM output to 100% then the relay sees it as a on command. I think the command is like S1000 plus the M command and you are golden.
Can someone please mark up the through holes on Aux 1-4? I’ll only be putting a header on AUX1 but knowing where the 5V & Ground is will save me the time of metering it out. Why reinvent the wheel?