Auto-power switch for router?

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;
1 Like

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.

1 Like

2, 5, 6 and 30 turn it off, surely?

We need to add support for the M commands in the g-code to trigger this pin.

2 Likes

Right you are - edited for posterity.

1 Like

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.

2 Likes

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.

1 Like

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.

4 Likes

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.

I added this to the wiki. Optional Alternative Parts and Vendors · MaslowCNC/Mechanics Wiki · GitHub

3 Likes

@skiz . How did you test on this go? I’d like to set AUX1 to drive a LED first, it that works I’ll wire up a powertail.

Thank you

It was merged this morning, ready to go. Thanks @skiz!

2 Likes

Yes I’m using it myself. I suggest adding M3 and M5 (on/off) as macros on
your GC

3 Likes

Again, thanks for that really elegant implementation of letting people customize the text on those buttons. Very slick!

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?

Thank you

Here you go :smile:

Edit - added AUX5&6…

5 Likes

So appreciated! Thank you

Does this mean that M03, M04, and M05 are now active in GC and working on Aux1?

1 Like

I haven’t tried them myself, perhaps @skiz or @Bee can answer.

I haven’t tested it yet either. The note above shows 3 & 4 as the same function - “On”

It should be in the next build or in theory you can do a build form source now.

1 Like