In order to achieve directional control like the M3/M4 pair, we¢re going to have to wait for additional circuitry.
very few CNC machines can spin their spindle in both directions, on/off is what
they all offer (even speed is missing on many)
Presently the gpios all come up as tristate on reset. I¢d suggest we leave
them alone unless a Bxx code specifically addresses one, then set that one as
an output as the first part of an ¡on¢ or ¡off¢ command. I don¢t believe there
is a down side to re-configuring an output as an output - anyone have input on
this?
If we define one of the outputs as the spindle, it should be off on reset. At
reset time we don’t know what’s where we are, so we should not have anything on.
Thinking more about the Bxx commands, we could use a second parameter to indicate which AUX to switch:
‘B21 P n’ turns off AUXn (AUX1-3)
‘B31 P n’ turns off AUXn (AUX1-3)
I’d limit the command to AUX1-3 as AUX4 is currently used for zeroing zAxis with the G38.2 gcode, and AUX5&6 pin definitions differ between the beta and v1 boards.
I agree with David on this point. For those trying to learn the ins and out of G-code it would be nice to implement as many of the relevant g-codes as possible.
Does that mean there’s an automatic z home command lurking in there?
I wasn’t suggesting reversing the router’s rotation, which would requiring rewiring the innards, just listing them for completeness. Not planning to burn up a few bits by spinning them backwards.
Althought there is the 1500W cooled VFD spindle on the wish list…
Why not just use M42 like Marlin’s pseudo sort of standard. Then we could learn how to use Fusion 360 and write a post processor.
This moose started with organic cad (cellulose wrapped around graphite, and processed into sheet form lying on plant corpses) and doesn’t quite get the hang of this ephemeral electronics based stuff. Heekscad looks dead, time to learn something new…
M42 Pn Sxxx
P An optional pin number. If omitted use the LED pin.
S Required. The state value to set, 0-255…
“M42 immediately changes a hardware pin’s state. This can cause bad things to happen if not used correctly. Use with caution!‘
Rather than any arbitrary pin, how about limiting the valid choices to AUX1-3 and using the AUX number for P? These three will not do PWM, so in the pure Marlin form, any S value < 128 sets the output LOW, else HIGH. M42 P2 S255 would set AUX2 HIGH.
Yes, G38.2 is implemented, but only for the z axis. A wire from AUX4 to the non-spinning bit and a grounded piece of metal on the surface beneath for it to touch when z should be set to zero.
The S value allows for PWM/analog pins; I’d recommend that it be limited to 0 (off) and non-zero, preferably 1, for on. They say in the description (of course I can’t find that one now; the chaotic state of Marlin after the open source spat has resulted in several references) that it will not allow you to change any pins that are currently in use so no varying the hotend PWM power or stepping the motors, and I thought it said digital pins were (or should) be 0 or 1.
So for G38.2 you’d need to connect the bit to +5, the test surface to ground, and it’d just work? Alligator clips and a piece of aluminum foil on top of the workpiece? No more messing around to zero it? I’ve been tweaking it over a piece of scrap and turning the router on to see if it just barely touches, which is a pain. I’m using 1/4 OSB as a spoil sheet, and the cutting depth for the measure-it calibration is so shallow that the marks are hard to find in the rough flakeboard.
I’m thinking about moving the Zenbot off the drafting table, finding one of those automatic parallel gadgets, and just scanning paper for cutting. Not too seriously, not sure where I’d move the ZB. Seems like every CAD program has a steep learning curve, haven’t gotten to the pick-em-up quick point with CAD.
Completely OT, but I just ordered a handful of blue pills (no, not those blue pills) and an st-link programmer; no special plans, just to dink around with them (neighbor’s got an old traffic light that he wants me to make blink, might be fun to us it instead of a Nano like the last one I got suckered into). Wonder how those would work on a Maslow (probably won’t find the time…), or maybe as an independent motion controller - feed it new positions in pseudo-steps and let it decide how to get there.
Connect the bit to AUX4, that pin’s internal pull-up provides the 5v. Tin foil will work, I use a 8x10 piece of scra aluminum as it’s handy. The z value you give is the ‘bailout’ point, if AUX4 hasn’t changed to 0 before reaching this z value, the command stops all processing same as the STOP button. I use a slow feed rate to sneak up on the aluminum, and I’ve set my Macro1 to run this, though a small .nc file would work as well.
I’ll volunteer to write the code, unless someone else wants to. I have B21/B31 ready or could do M42 pretty quickly if that is the path chosen instead. No time to get it tested before tomorrow’s release, though !
BTW, shouldn’t the build number be 0.84 since last Wednesday? Do the build numbers reflect the release as well?
I’ll second the suggestion for M03 and M05, that will make things work with many CAM packages with a GRBL setting.
@ Bar - what is the current limit on the controller board? I’d like to also switch my dust collection with the same pin. I have several SSRs that I plan to use, just want to make sure I keep things within the recommended limits.
M3 and M4 control spindle direction, not on/off. If we are to follow the LinuxCNC standard, one needs a speed as well, which outputs to a separate PWM pin. M5 shuts off the PWM pin and does not alter the state of the pin controlled by M3/M4.
I’d like not to get into that .
@TomTheWhittler I’ve always just used M03 to turn the spindle on and M05 to turn it offf. The machines I’ve used did not have directional control, and were clockwise rotation, which led to my choosing M03. The Speed command is not required in concert with the M03 command, and in the absence of spindle speed control would not do anything. I know that SprutCam (an expensive CAM program, but powerful) and Cambam utilize M03 to start the spindle in the gcode produced. I have not used Fusion so I can’t speak to that, but a quick google search seems to show that Fusion does utilize M03 and M05 in standard post processing.
@blurfl M03 and M04 actually do turn the spindle on, as well as setting the direction of rotation. I have not looked into the Maslow code, but it would be the code that implemented the gcode command and could likely be set up to simply send a high/low signal to an output pin in response to M03 and M05.
One other nice thing about this feature is that using the relay controlled power strips that folks have already posted, the Spindle On command could also activate the vacuum. Remembering to turn on the vacuum is the bane of my miter sawing life
I like that idea. Two separate IoT devices controlled by the same I/O pin. One ioT for the vacuum with it’s separate power line / breaker and the other Iot for the router with its own breaker. That keeps the power load spread over a couple of power runs and circuit breakers instead of just one if plugged into the same outlet.
The Bxx codes or the M42 code would require you to edit your .nc program to add the command that turns the gpio pin on and off at the appropriate time. Perhaps ‘on’ near the beginning of the file after the static settings are read in, and ‘off’ just before the M2 ‘program end’ command at the end of the file.
That is not hard to do, and assures that you considered when to turn something on and off.
Hmmm, in my experience, M03 starts the spindle, M05 stops it. I might have an S statement in there to set a speed, but this is how I’ve been running my little CNC since I automated the spindle switching. This may have a lot to do with the controller board I am using though (Protoneer’s CNC Hat).
Looking at the Protoneer CNC Hat forum it looks like
"Bertus Kruger wrote: ↑
Thu Jun 15, 2017 7:03 pm
The latest version of GRBL uses PWM. This is to control spindle speed.
To enable the spindle, use the M5/M3 commands and then set the speed with S1000."
So something like this could be implemented for both turning on/off a router and then later for a variable speed spindle using PWM.
In this snip-it segment of the Protoneer forum they were discussing how the Protoneer CNC hat board would be setup to run a relay.