CNC machine emulator for GRBL
2016-07-11 | By Jim Williams
License: None
I don’t have a CNC machine at home, but several times I’ve wanted to do some kind of testing to watch the movement. So I built a simple CNC emulator with LEDs to indicate gantry movement and buttons for limit switches etc. It’s an Arduino shield that expects grbl running on its host.
Pairs of LEDs (red ovals) show X, Y, Z motion by decoding the step and direction pins from grbl. Cranking the step pulse width up from 10 to 50 μsec improves the brightness. Just as with the real W88 Shapeoko machine, there are limit switches for X, Y, and Z – implemented as small buttons at the ends of their axes. There’s also a button on the A5 line, which is used by grbl 0.9 for the G38.2 probe command, plus one Arduino reset button, since the one on the board is covered up. Two more LEDs – for Stepper Disable and Spindle complete the board. Since grbl 0.9 supports spindle speed control via PWM – at the expense of pin compatibility with 0.8 – there’s what amounts to a DPDT switch of header pins to support either pin configuration.
There are traces hard wiring it for the 0.8 assignments that would need to be cut if I ever populate the jumpers.
It was an interesting challenge to figure a simple way to decode step/direction for the LEDs, but I think the 3 transistors are about as simple as it gets. Yeah, if I’d used MOSFETs I could have saved 3 resistors, but I didn’t have any on hand. The first application of the emulator was to hack grbl to add the very slick “smart clamp” Z-axis auto-touch-off switch, like Carvey machines use. It performed admirably for that task. The implementation was a surprise: I expected to implement it in code in grbl, maybe triggered by a private M-code. But it ended up just being some G-Code in the $N “startup blocks” grbl supports. The hack was just to support more blocks (I needed 5 instead of grbl’s normal 2) and ensure that they were not executed after a reset.
I even put the code in the W88's github, thanks to gentle browbeating from couple of other members. Check out the video.
Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.