Notes on CNC Routing and Node


These are my notes from Elijah Insua's CNC/Node talk given July 3, 2012 at NodeConf. You can follow him on twitter at @tmpvar

Communicating with Hardware with Node, and how Node helps me build hardware

Earlier this year I built the tmpad r4 (see It's cheap, built of foam and wood, and pressure sensitivity based on infrared, using arduino and node-serialport. However, there will problems. There are a lot of alignment issues with infrared LEDs. The foam degrades, and recessed buttons and round buttons were a continuing source of friction. So the status was that it needed work!

The first thing I decided to do was to figure out how to cut square holes in wood. There are bits you can use but they're expensive; I found this whole community of people building CNC Routers, basically a woodworking router built on three axes of linear motion/actuation. I decided to build one, with basically zero experience.

This took me about 6 weeks, almost full time. I spent about $1500, mostly electronics. Build pics are at (600 pictures!)

There are problems with this. It's built out of wood, so it works but it's not very precise. I think we're precise down to 0.4mm. It's also slow. I can do 900mm/minute on each axis. The footprint is 4'x4', and the area that I actually use is about 1'x1' for big cuts.

This is usable! Let's dive into the software behind this. CNC machines use a line-based protocol called gcode. Some codes:

How do we get gcode to be processed? There is a project called grbl ( which runs on arduino. It's gcode interpreter that turns gcode into specific commands for the stepper motors. Originally, with this setup, I was writing gcode manually. That was a nightmare.

I built a project called gcode-simulator. This allows me to try gcode out. You can even throw in an SVG and it will generate gcode that allows you to create that SVG in gcode.

My workflow at this point is to edit svg in svgedit, convert it to gcode in gcode-simulator, copy/paste into grbl.gcode, home the machine with arduino app, and use python to push the gcode to arduino.

Issues: arduino app isn't a repl. It's hard to iterate, because if you're wrong you have to go back and re-do all that math. Error-prone and tedious! So, I've created a repl to communicate with grbl. It depends on ndoe-serialport,, optimist.

Another thing I wrote for fun is fingerpen. I used:

  • Google Canary
  • gamepad.js
  • node
  • node-serialport
  • grbl

I found these awesome Allegro A6281s, so all you need is 4 pins on your microcontroller because you can chain them. The pin layout matched up directly with the LED. The only problem is that these things are 3mmx3mm! Since they're QFN it's so difficult to debug. You also have to connect the center thermal pad... yeah. We failed a lot at this. Now, instead of trying to etch my own boards, I just send away.

This whole time as I'm prepping boards for manufacture I'm using eagle, and I'm noticing that I can just derive the cuts directly from the schematic for the circuit board. I can generate JSON from eagle using eaglepunch, and from there I can write node to generate the gcode that would perform an operation to do something in relation to where these elements are on the board. In this case, I go through all the LEDs and drill through the place where each LED is.

If I had my drill here, this would be destroying wood right now.

The new tpad4-mega is machined out of aluminum with 40mmx40mm uttons. atmega32u4.

1 Comment

Did you enjoy this post? Please spread the word.