-
If GRBL is the defacto standard for CNC gcode then it starts to make sense to have those commands when the firmware is in CNC mode (or maybe split up CNC mode to milling/turning/mutiaxis). What was not clear to me was that there was any particular standard for CNC gcode (other than the original gcode standard which everything has extended in different directions).
What does the gcode generation for subtractive CNC?
I am by no means an expert in any of this, just starting to wrap my head around all of it (so forgive me if this is wrong) But when I was looking at Fusion360 and its ability to send CAM gcode to UCCNC controller for my CNC router what i found was there is not a built in post processor for UCCNC like there is for Mach3.
But I also found a number of UCCNC pros discussing this on a forum where they tried a number of post processors inside Fusion360 and the one they found to not only produce compatible code for UCCNC but also Mach3 and others was the post processor called "WinCNC"
Wouldn't it make sense to base the Duets gcode abilities on that of what WinCNC produces since it seems to be the most compatible amongst many controllers, seems to me they did their homework on gcode compatibility and if i understand it correctly (have not taken the time to look yet) you are able to edit the post processors inside fusion to see what needs to be added to Duet
-
IMHO the easiest way to support all kind of dialects is to include a module, which enables any user to define his own G/M-codes and put them in the macro folder. Of course a global database can help collecting them, so less experienced users can use them too.
The config-override file then contains a list of the standard G/M codes that have been altered by the user.Starting point would be a basic RRF version, where most of the in/outputs are not reserved for fans, endstops, thermistors etc.
Pins required for stepper drivers stay reserved.I don't know if that's possible, but it would put an end to discussions which CNC dialect deserves support by RRF.
-
I think we need to understand the problem in more detail before recommending one action or the other.
A general gcode override ability as o_lampe suggests is interesting but I can see how that could end up being very complex to support, especially for inexperienced users.
Is anyone able to point me to a resource that lists the various CNC dialects (great term!), The various codes they use and what functionality that actually is?
-
I've counted more than 80 different post processors in Fusion 360. Way to much to work out the differences between them.
It seems they wrapped the firmware around the machine, now we try the opposite way: finding one code for all machines…I believe they all have some basic functions in common.
On my wish list are:
3 axis control incl. homing, spindle management, coolant-pump for spindle and part and maybe some safety inputs ( flow sensor for coolant, temp sensor for spindle, enclosure door switch ) -
80 post processors? So 80 different gocde dialects? thats unfortunate.
For your wishlist:
All axis can be homed using G1 with the S1 switch.
Much of the rest could be implemented using these reprap gcodes:-
M3: Spindle On, Clockwise (CNC specific)
-
M4: Spindle On, Counter-Clockwise (CNC specific)
-
M5: Spindle Off (CNC specific)
-
M6: Tool change
-
M7: Mist Coolant On (CNC specific)
-
M8: Flood Coolant On (CNC specific)
-
M9: Coolant Off (CNC specific)
-
M10: Vacuum On (CNC specific)
-
M11: Vacuum Off (CNC specific)
These are in the reprap gcode specification but not implemented in RepRapFirmware except for M3 which is Roland Mill specific
I think it makes sense to extend the the :
https://duet3d.com/wiki/G-code#M580:_Select_RolandGcode into a "select CNC" and then
Having additional temperature triggers to trigger macros is on the wishlist, maybe a flow sensor can be similar enough to a temp or endstop trigger to run a macro when a threshold or state change is sensed.
-
-
That is why I was recommending the WinCNC post processor from Fusion360 as a model to base the gcode after. That post processor not only makes compatible gcode for WinCNC controllers but the code is also compatible with Mach3 and UCCNC controllers and some others… why not add Duet to that same compatibilitty list?
I do have to admit some bais here, I use a UCCNC controller on my CNC machine, i selected it for the same reasons that i selected Duet for my 3d printers (both are great controllers) the wincnc post processor allows compatibility of gcode with it as well as several others.
I would love to be able to do both subtractive and additive manufacturing from a 3d printer build though.
-
Here you go:
NIST RS274/NGC standard: http://ws680.nist.gov/publication/get_pdf.cfm?pub_id=823374
That is the full documentation for the RS274 standard which all controllers are based off of, they just all add their "extras" which are controller specific and is why we see so many post processors in fusion.
So if you base Duet off of that documentation we can move forward.
-
Much of the rest could be implemented using these reprap gcodes:
-
M3: Spindle On, Clockwise (CNC specific)
-
M4: Spindle On, Counter-Clockwise (CNC specific)
-
M5: Spindle Off (CNC specific)
-
M6: Tool change
-
M7: Mist Coolant On (CNC specific)
-
M8: Flood Coolant On (CNC specific)
-
M9: Coolant Off (CNC specific)
-
M10: Vacuum On (CNC specific)
-
M11: Vacuum Off (CNC specific)
I think all that is needed to support most of these is a new gcode command to configure which logical pin numbers control spindle on, spindle direction, mist coolant on, flood coolant on, and vacuum on. The exception is M6. It seems that in CNC gcode, a T command doesn't actually change to the specified tool, it just selects a tool ready for when the M6 command is issued. So we need a "CNC mode" state flag to change the behaviour to do this.
-
-
I think all that is needed to support most of these is a new gcode command to configure which logical pin numbers control spindle on, spindle direction, mist coolant on, flood coolant on, and vacuum on.
That is, what I meant with a new module inside RRF, where users can adapt their machines to these M codes. It makes sense to base it on a "naked" RRF version where only the basic functions are set and I can reuse fan-, heater-, or thermistor connectors etc. for my own purposes.
The new gcode would have to be able to call a (C++) macro, which describes the way the machine should respond in different scenarios.
Code words like IF, AND, OR, etc would make it perfect for almost any usecase beyond gcode- CNC. ( eg. robotics ) -
The new gcode would have to be able to call a (C++) macro, which describes the way the machine should respond in different scenarios.
Code words like IF, AND, OR, etc would make it perfect for almost any usecase beyond gcode- CNC. ( eg. robotics )I am not sure making the macos C++ would be a great idea for most users. Gcode should be sufficient (with appropriate additions).
You point about a "naked RRF" makes sense, David has already implmented the ability to disassociate some pins from their original function, see the notes here: https://duet3d.com/wiki/Using_servos_and_controlling_unused_I/O_pins.
David:
@dc42:I think all that is needed to support most of these is a new gcode command to configure which logical pin numbers control spindle on, spindle direction, mist coolant on, flood coolant on, and vacuum on. The exception is M6. It seems that in CNC gcode, a T command doesn't actually change to the specified tool, it just selects a tool ready for when the M6 command is issued. So we need a "CNC mode" state flag to change the behaviour to do this.
Could we set the pin numbers as flags to the M commands?
I think extending the Roland Mill M580 to general CNC mode makes sense
Whitewolf:
I know that ReprAp gcode is based on the NIST standard, the issue is it has many extensions past the standard (as apparently do GRBL, UCCNC etc) so its not as simple as just implementing that, however it is a good starting point (and the M codes I listed earlier are a subset of it). more to follow. -
Ok so looking at the NIST standard GCodes (both G and M):
Implemented (minor additions might be required):
-
G0 rapid positioning
-
G1 linear interpolation
-
G2 circular/helical interpolation (clockwise)
-
G3 circular/helical interpolation (counterclockwise)
-
G4 dwell
-
G10 coordinate system origin setting
-
G20 inch system selection
-
G21 millimeter system selection
-
G28 return to home
-
G90 absolute distance mode
-
G91 incremental distance mode
-
G92 offset coordinate systems and set parameters
-
M0 program stop
-
M1 optional program stop
-
M3 turn spindle clockwise
Not implemented but something else is implemented instead that may or may not make up for it
-
G30 return to secondary home (It is a simple probe in RRF)
-
G38.2 straight probe (its G30 in RRF)
-
G43 tool length offset (plus) (covered by the Z offset in G10?)
-
G49 cancel tool length offset (covered by the Z offset in G10?)
-
G53 motion in machine coordinate system (Covered by G90, although G90 is modal)
-
G92.1 cancel offset coordinate systems and set parameters to zero (Not implemented but G92 gets most of the way there)
-
G94 units per minute feed rate mode (this is the way RRF deals with feedrate by default)
-
G98 initial level return in canned cycles (not implemented y the amount of Z movement or tool movement on a axis can be just another line in a macro)
-
G99 R-point level return in canned cycles (not implemented y the amount of Z movement or tool movement on a axis can be just another line in a macro)
-
M30 program end, pallet shuttle, and reset (Delete an SD card file!)
Not implemented at all yet
-
G17 XY-plane selection
-
G18 XZ-plane selection
-
G19 YZ-plane selection
-
G40 cancel cutter radius compensation
-
G41 start cutter radius compensation left
-
G42 start cutter radius compensation right
-
G54 - G59.2 use preset work coordinate system 1-9
-
G61 set path control mode: exact path
-
G61.1 set path control mode: exact stop
-
G64 set path control mode: continuous
-
G80 cancel motion mode (including any canned cycle)
-
G81-G89 canned cycles (use macros?)
-
G92.2 cancel offset coordinate systems but do not reset parameters
-
G92.3 apply parameters to offset coordinate systems
-
G93 inverse time feed rate mode
-
M2 program end
-
M4 turn spindle counterclockwise
-
M5 stop spindle turning
-
M6 tool change
-
M7 mist coolant on
-
M8 flood coolant on
-
M9 mist and flood coolant off
-
M48 enable speed and feed overrides
-
M49 disable speed and feed overrides
-
M60 pallet shuttle and program stop
-
Also the S switch for spindle speed
So quite a lot to do, some of which is relatively straight forward (switch on and off coolant, spindles), while other parts would need serious consideration ( XZ,YZ plane, various co-ordinate systems, path modes).
-
-
I agree it's probably a bit overkill to ask for full C++ support in macros, but from what I know, the "canned cycles" would require some loop structures, counters and boolean algebra. None of that is implemented in gcode.
Maybe we can post-process such a canned cycle in gcode compatible code?Re G17-G19: Do we need more than G17 in a 3 axis machine?
Re G43 & G49: AFAIK the tool length offset is based on the first tool length, so we'd need a default length to start with.
Because there are different WCS ( G54-G59 ), the offset would have to be adapted.
Re G40-G42: I've seen options in Fusion360 to do that and grbl for instance only allows G40 mode, so we might not need it.Anyway, I'm glad there is enough interest from yours side to get things started and get another notch in the belt.
Duet with RRF will be the most versatile controller one day! -
Regarding loops: gcode Macros can call themselves recursively. The issue is we don't have real branching.
We have up to 6 axis so it's probably something we want in the longer term.
There is definitely interest on this side however what would be helpful is to further group and prioritise each of the logical groupings of functions. Once we have that we can see where they for in the evergrowing wishlist!
-
How do you set the exit strategy in gcode for recursive macros?
If number_of_loops =>max_loops or Z<= Z_min then return
Also we don't have variables like [c] Z=Z-last_Z [/c]
-
Yep no exit strategy, just input changes. No variables either right now.
As I have said before, extending gcode in this way is akin to what happened to GPUs/shader language/ML (albeit on a smaller scale).
Have you a concrete example of where this is required? Arguably much of the higher level functionality should be the job of the slicer/gcode generator.
-
No, I haven't seen such canned cycle yet, but it made sense to me they would be something like parametric subroutines, like cutting threads or drilling standarized screw holes?
OTOH, the filesize on SD-card can be very huge nowadays, given the price/GB. So why would anyone care about compressing and simplifying the file by using subroutines? -
Yes, if the gcode generator just puts another chunck on gcode in for each threaded hole or whatever and the file size gets big that did not appear to be a problem.
On other CNC firmwares that implement these canned cycles, are they written in gcode or hard coded into the firmware? If in gcode then we can use a macro.
Let's parked extending gcode with branching and variables for now and look at the list of G/M codes. Does anyone want to have a go at grouping and prioritising them ?
-
Is the plan to implement these CNC commands into existing firmware making a single universal "do all" firmware or have a separate firmware exclusively for CNC machines? If it's the former, then I have a few concerns.
-
Ian
I don't think the decision has been made, the issue with a totally seperate version is that it increases the support requirements.
My preference would be to have one or more CNC modes (this already exists for the Roland Mill, but expand it to be more general). Ultimately a 3d printer is a subset of a larger family of CNC machine.
We already have Delta, Corexy and Cartesian modes so this could be an extension of that concept.
-
I believe the support will be much more difficult, when the user has to "undefine" thermistors, heaters, extruders a.s.o. to make a CNC machine out of a 3D printer firmware.
Not to mention PanelDue or DWC…
To ease up things, there should be a sample config on SD-card image for a cartesian mill with X, Y1, Y2, Z and U axis ( or 2nd Z-axis?).
What do you mean with grouping the G/M codes? Work out the differences between dialects? Then we should start with a list of dialects RRF will support.
For now we have grbl, mach3, wincnc, roland.
Is Linuxcnc an option? AFAIK, it runs on PC-internal controller cards? USB-support seems very limited.