CNC Machine Electronics Upgrade

13th March 2018 (6 years ago)

I decided my CNC machine (based on Shapeoko2 designs), that I originally built in 2014, could do with some love.

  1. The wiring was messy, getting in the way and proved unreliable due to insecure connections.
  2. Setup to use the machine took several steps with multiple mains power plugs for parts like spindle, motor drivers and controller. I wanted to just be able to plug in one thing a know it would be ready-to-use.
  3. I didn't want to have to have my laptop tethered to it via USB, streaming GCode. It's a loud machine so I often want to run it in a different room. Whilst I have been using an old laptop for this, it's still not very convenient.


These are a few photos of what I did with the wiring. I've had issues in the past where I've suspected stepper motor signals have interfered with one another and caused coordinate movement errors through inductance. Also, because the wires are going to be a lot closer together now, I grouped each stepper motor's wires together and spiral-wrapped them with copper tape. This should also mean the stepper motors are shielded from the main spindle motor wires that are also close by. A black plastic spiral cable wrap (in two different sizes) finishes it all quite neatly. Once the loom enters the case it goes through some clip-on choke inductors to limit noise going to the stepper control circuitry.


Once I knew all the electronic boards that would have to fit, I designed a case to CNC cut out of OSB. The bottom of the case is just the PSU, screwed in place from the side panels. There are slots for air flow, motor cables and IEC power socket on the back. On the front, holes are created for power rocker switch, emergency stop button (E-Stop), spindle speed controller potentiometer and status LED optic fiber.

I was able to use the CNC machine to create bevelled edges on the insides so that it became neat once glued together. MDF would have probably made for a neater finish as the OSB lost a few strands at the edges. I'm pretty sure OSB creates less hazardous dust and I like the look of it too.


Everything is now powered from the single PSU with a couple of buck convertor boards to get down to the voltages required for the grblShield Gcode interpreter/stepper controller, Raspberry Pi and custom microcontroller board.

The Raspberry Pi runs Serial Port JSON Server which allows Gcode to be sent over the network to it via it's Wifi USB adapter. A ChiliPeppr workspace is then used from a web browser on any networked computer. The Raspberry Pi's onboard serial RS-232 pins are used to communicate with the GRBL shield. A simple voltage divider was made to bring the RPi's TX pin from 5V down to 3.3V.

Finally, a custom circuit board was created to control front panel indicator and handle E-stop pause/resume button presses. The board comprises of an ATMEGA 328 microcontroller, RGB LED with optical fiber to front panel and some other passive components. These are the inputs and outputs:

  • Digital IN: E-stop push button
  • Digital OUT: grblShield FEED_HOLD pin (A1)
  • Digital OUT: grblShield CYCLE_START pin (A2)
  • Serial RX: Listening in to grblShield status messages to display as changing LED status colours

Code for the microcontroller is here and should run on any Arduino-compatible device.