-
Notifications
You must be signed in to change notification settings - Fork 538
Tutorials: Tool Change with bCNC, FreeCAD & grbl
grbl does not understand the tool change code M6 and will error if it receives one. Consequently bCNC was originally written to ignore M6 lines and not pass them to grbl. Also FreeCAD grbl post processor was written to comment out tool change lines. However the current release (0.9.14) of bCNC has tool change capability added.
Tests here are based upon -
- FreeCAD version 0.18 running on Linux Mint 19
- bCNC version 0.9.14 running on Raspberry Pi model 3b - Raspbian GNU/Linux 8 (jessie)
- grbl version 1.1f.20170131 on an Oozenet Ox CNC Router
Information here is heavily plagiarised from the bCNC GitHub wiki page on Tool Change
To use Tool Change it is necessary to have a touch plate connected to the probe input on the controller and some means to clip an earth connection to the tool. Here is my setup
The copper disc is a 2p piece (UK currency, pre 1998, they were solid bronze then) faced to make it flat and inset flush to the base board. There is a wire soldered to the underside and connected to the probe connection on the controller. I have also fitted a couple of banana plug sockets for probe and earth so that I can easily clip an earth to the tool.
On the ‘Probe’ tab click the ‘Tool’ button.
Fast Probe Feed – sets the speed at which the tool comes down to the start of the probe operation Probe Feed – sets the speed at which the tool comes down whilst probing TLO – not used in WCS mode – see below
Policy There are 5 options
- Send M6 commands
- Ignore M6 commands
- Manual Tool Change (WCS)
- Manual Tool Change (TLO)
- Manual Tool Change (NoProbe)
The first option will cause an error if there happens to be an M6 command in your g-code
The second option will continue with the original tool to the end. This is potentially dangerous if there are multiple tools in your g-code.
WCS (workpiece co-ordinate system) is the one to use. It sets Z zero at the point where the tip of the tool just touches the workpiece, then resets it on a tool change so that the new tool just touches the workpiece even if the new tool is a different length.
TLO (Tool Length Offset) modifies the machine co-ordinates rather than the work co-ordinates. This can result in unexpected hard limit trips.
NoProbe – This option misses out the probe operation, so will only work if all tools are exactly the same length and fitted in exactly the same position in the collet.
There are 2 options
- BEFORE & AFTER probing
- ONLY before probing
Using the second option means that the job will restart without intervention, so the spindle will start potentially before you have removed the earth clip. Option one is recommended therefore.
Currently if the grbl post processor is selected in FreeCAD Path workbench, any g-code generated will have the M6 tool change lines commented out by starting the line with a semicolon. e.g. a tool change to tool 2 would read
; M6 T2.0
It is a fairy simple operation with a text editor to search/replace ‘; M6’ with ‘M6’. The downside to this approach is that you need to do it every time you generate g-code, and also if you forget then the code will be executed without any tool change, which would probably not be good for the work and/or cutting tool.
The other (better) option is to create a new version of the grbl post processor code. Sounds difficult but it really isn’t. The code can be downloaded from https://github.com/FreeCAD/FreeCAD/tree/master/src/Mod/Path/PathScripts/post All of the post processors are there, the grbl processor is grbl_post.py. Take a copy and with a text editor (proper word processors sometimes add special characters so better to use Text Edit, Notepad or similar) find the line OUTPUT_TOOL_CHANGE = False change this to OUTPUT_TOOL_CHANGE = True and save with a new name, e.g. grbl_toolchange_post.py Note that the name MUST end _post.py. Put this file into the Macro directory under your FreeCAD installation directory. Restart FreeCAD and there will be a new option grbl_toolchange in the post processor selection list.
The general operation is to define 2 positions, one where you will change the tool and a second where you will probe for Z reference, note that this is not the work Z zero but a reference point to allow the system to compare tool lengths. Neither of these need to be on the work piece, better to have as much clearance as possible. When the M6 tool change is encountered bCNC will invoke a macro which drives the gantry to the tool change position, stops the spindle and displays a message Tool Change TXX, where XX is the tool number passed by the g-code. The operator then changes the tool and presses Resume (button, screen or pendant). The gantry then drives to the probe position and commences the probe operation to the touch plate reference in order to reset the Z zero.
Run a home cycle. Jog gantry to desired tool change position (X, Y and Z) and click Change ‘get’. This sets the change co-ordinates. Makes sense to set Z high to give max clearance for the tool change.
Jog gantry to desired probe position, the touch plate line up X and Y then move Z to the appropriate height and click Probe ‘get’. This sets the probe co-ordinates. Important note – Z must be set high enough to clear the touch plate with the longest tool to be used, otherwise it will crash into the touch plate and create an error when it probes and then the job must then be re-started, but the higher it is set the longer it will take to probe.
Note that both ‘change’ and ‘probe’ positions are recorded as machine positions (MPos)
Set a value for Distance. This is the distance that Z will move down when probing, from the Z setting in probe position, so this must be great enough for the shortest tool to reach the touch plate from the Z probe setting entered on the previous step. If it doesn’t touch within that distance it will error, so make it plenty big enough. The change and probe settings are remembered so you don’t need to repeat these operations, but if you need to change them, start using longer bit or whatever, you can run through this setup again.
When you start your job fit a tool and set your work X, Y and Z zeros by whatever means you like.
Fit an earth clip to the tool.
Press Calibrate. The gantry moves to the probe position and performs a probe, then records the calibration machine Z co-ordinate in the Calibration field. Gantry moves to ‘change’ position.
Remove earth clip
Start the job FreeCAD generated g-code starts with a tool change, so the gantry moves to the tool change position.
- Fit the required tool AND the earth clip. Press ‘Resume’ and the gantry moves to the probe position then performs a probe.
When the probe has completed the gantry moves to the change position
Remove the earth clip.
Press ‘Resume’ and the spindle starts and the job starts
At the next tool change repeat from * above
- Sometimes an error cannot be cleared by Reset/Unlock. It is then necessary to use File > Close connection and then Open it again. You can then use Reset/Unlock.
- If an error occurs you need to clear the error and start the job again. Potentially a time consuming business so better to get it right first time.
- A possible problem area is forgetting to attach or remove the earth clip at the appropriate point. Beware!
- Reference to ‘Resume’ means a hard wired button or clicking ‘Start’ on the screen. Presumably this could also be done from a pendant but this has not been tested.
Mick Sulley - 20th Aug 2018