The other pins that were connected to the drivers are power in (v and gnd) and the 3 pins in the bottom right corner (GND, Step, Direction). The step and direction pins are how the arduino can control the motor. with every signal recieved the motor moves a step in the direction indicated by the step pin.
It's important to note here that the picture above shows 3 motors, but we only used the X and Y motors in our project as there was no Z axis to control. It's also important to connect the step and direction pins to the correct pins on the arduino as they will later be used by the grbl controller (see part 3). the pins should be connected as follows:
D2, D3, D4 = X, Y, Z step
D5, D6, D7 = X, Y, Z direction
I continued by soldering the pins on the easy driver board
Finally, to power the motors, we used a 12v DC power outlet that powered both drivers in parallel.
Part 3 - Software
This is the part where the automation comes in. We used GRBL to control our machine. GRBL is an open-source g-code parser and CNC-milling controller. Its runs on Arduino or any other board supporting Atmega 328.
first we download grbl library from https://github.com/grbl/grbl.
Then we install grbl library to Arduino IDE:
The grble code is included as an example in the library. we opened the example and uploaded the code on the arduino.
Now that the arduino is ready to receive our gcode and control the machine, we need to send the gcode to the arduino/grbl.
This is done via serial connection and we chose to use UGS (universal gcode sender). There other options available but this one seemed easy to use and suitable for our assignment.
by going to https://winder.github.io/ugs_website/download/ we downloaded UGS platform. There are 2 versions of UGS which have the same function. We decided to use UGS Platform.
After downloading UGS, we had to connect it to our machine (arduino). The easiest way to do this is to use the setup wizard.
The setup wizard takes care of connecting the arduino to the laptop and also helps calibrating the motors. It's important to specify the platform and the baud rate of the arduino. The next step is very cruicial and it'll help the machine "obey" the instruction as intended. We need to calibrate the machine steps to specify the steps for every mm moved. Thankfully UGS has an easy way to do this:
To explain this step: click on each axis to move the machine a certain distance. Measure the distance physically moved by the machine. This should calculate a new steps/millimeter number. type this number and update the machine.
Once this is done, the UGS is now ready to take your G-code. In previous projects, many machines we used had their own g-code generators. We also explored tool paths generated by CAD software like Fusion 360. However, when it comes to 2D drawins, I couldn't find many options. The most popular way (although not ideal) was using Inkscape. Inkscape has an extension that generates gcodes from 2D drawings.
Here is an example on the drawing converted to Gcode:
1- open drawing/pic in Inkscape
2- trace bitmap (Path > Trace Bitmap)
3- create offset (Path > Dyamic offset)
4- Delete original photo and keep the offset
5- Open Gcode Extension
6- set name and directory of Gcode
7- go to Path to Code tab and click Apply
The software will then calculate a G code and send it to the specified directory under the specified name. Note that the tool size was not specified. The software has a default tool that it uses. If you have a different tool and would like to specify it, you can do this under the Gcode extension.
Next we can open the gCode in UGS:
UGS platform has a visualizer that helps visualize the tool and the path. By manually homing the machine and then clicking on Reset Zero in UGS we retered the machine to it's datum.
Then finally we can send the code the arduino/grbl and have the motors follow the code.
Here is another sketch made by our machine:
Making any kind of machine, requires effort and planning on advance. In our case we are planing to improve our machine and fix its stetics and calibration to obtain better results.
Etch a sketch is a toy and it has a some hysteresis. This can be felt even when controlling the machine by hand.