Friday, August 1, 2014

Build Log: Shapeoko 2 inspired CNC Router - Part 1 Testing Electronics


I started working on a CNC Router project inspired by the Shapeoko 2.  Why inspired?  As an electronics hobbyist I have amassed a decent amount of electronics and hardware of which I am going to be using as much as I can in order to cut costs over buying the complete Shapeoko kit.  Why Shapeoko?  After some research I feel that the Shapeoko Wiki is an incredibly thorough guide for building a low cost desktop CNC router.  The wiki includes guides for electronics, hardware, and software, which coming from a single source means that everything will play nice together.  My goal is to keep the total cost below the Shapeoko 2 Full Kit AND provide a larger cutting area by scaling the X-Y axis linear motion from 500mm (19.6 inches) to 610mm (24 inches).  I am hoping for a cutting area of 18 x 18 inches.

Electronics
I wanted to get the electronics hammered out first for a couple reasons:
  1. Large portion of the cost is the controller boards, stepper motors and power supply.  Getting large costs out of the way is nice for projects.
  2. If electronics do not work, and the project is a failure, I am not stuck with custom cut hardware to build a CNC, which could be resold at a loss, it would be easier to flip stepper motors and reuse the Arduino for a different project.
Following the Shapeoko recommendations I purchased a Arduino Uno ($25) and a Synthetos gShield v5 ($49.99).  The Arduino is a micro-controller that takes G-Code (more on that later) and converts it to the individual movements that the motors need to make.  The gShield is a stepper motors driver which processes the movements and applies the proper voltages to the stepper motors so they can move.

Stepper Motors: I needed something that will mill wood, acrylic, and any type of plastic sheet.  After some research I decided on Nema 23, because even the smallest Nema 23 motors are 2-3 times stronger than Nema 17 motors.  This will be enough strength to mill hardwoods and in the future possibly aluminum.  The Shapeoko 2 uses something called Dual Drive Y which means the Y axis has two stepper motors, one for each side of the gantry.  The X axis uses a single stepper motor, and the Z axis uses a motor for moving the milling rotary tool up and down.  I already have a smaller stepper motor I am going to use for the Z axis.

Power Supply: Shapeoko recommends a 90-120 Watt 24V power supply.  I have a much smaller 24v power supply I am going to be using for testing the electronics, it should push the small Z motor fine.


Software
Disclaimer: I am using a PC, follow the links for instructions on the platform you are using.  Once I had my electronics purchased it was time to test the steppers motors out.  First you will need to install the Arduino development suite which includes the USB driver so you can flash/program your Arduino.  Download and install the Arduino IDE 1.0.5 and make sure USB driver is selected during the install.  Plug your Arduino into your computer using a USB Type A to B cable and it should show up under Device Manager:


Note that my Arduino is connected to COM3, you will need to know your port.  Next download and extract XLoader.  This tool allows you to flash the Arduino with the GRBL interpreter.  GRBL is what takes the g-code and turns it into "steps" that control the stepper motors.  Retrieve the GRBL hex file from the github.  Scroll down to Downloads and right click save-as to save the .hex file.  Open up Xloader, select the com port your arduino is hooked up to, select 115200 baud rate, browse to the GRBL .hex file you downloaded and click upload to flash the Arduino:


The TX and RX LED's on the Arduino will blink.  Once completed Xloader will say how many bytes have been written to the Arduino.  We will now finish preparing the electronics for testing:

Unplug the Arduino's USB and connect the gShield (you can flash the Arduino with the gShield installed), then connect a stepper motor to one of the axis'.  I read to always connect the stepper motors with the gShield and Arduino unplugged in order to potentially prevent any hot wires from touching anything.  Next connect the USB back into the Arduino and connect the 24v power supply to the gShield.  Red (positive) hooks to the Vmot side and black (negative) connects to the GND side.  An LED will turn on:

The power supply alligator clips are actually farther apart that what the picture implies.
I did not have instructions for wiring this motor, I just paired the wires together and connected them to the axis keeping the wires in order, at this point I am not worried about polarity.

We can now send g-code commands to it using Universal G-Code Sender (UGS).  Download the latest version and extract (I have a CNC folder on the desktop to keep all of these tools in).  Browse to the UGS folder and edit the start-windows.bat, changing the 'x' in the jar file name to the version you downloaded, in my case 64 bit:
 java -jar -Xmx256m UniversalGcodeSender-all64.jar  
Save and close.  Open Command Prompt, browse to the UGS folder, and run start-windows.bat:


The jar will launch and open up the UGS gui.  If your Arduino is plugged in it should show up under the correct COM port, leave the baud rate at 9600 and click Open.  UGS is now connected to your Arduino:


Whichever axis you plug your stepper motor(s) into, Z in my case, you can send movement command(s) by using the controls under the Manual Control tab.  Do not send commands to an axis that does not have a motor connected to it, you can overload your gShield.


Your stepper motor should be rotating and your electronics testing is completed.  Next up I will be shopping out the Nema 23 motors, power supply and parts to build the Y and X axis.