Build a Simple 3D Printed CNC Plotter Machine

by MertArduino in Circuits > Microcontrollers

14575 Views, 176 Favorites, 0 Comments

Build a Simple 3D Printed CNC Plotter Machine

Build a simple 3D printed CNC plotter machine

Hi friends, do you remember this Mini CNC Plotter machine that uses hobby stepper motors and a few 3D mechanical components, now meet its big brother. This new machine includes two linear rails and two Nema 17 stepper motors for the X and Y axes. It also uses a mini servo motor for the Z axis to lift the pen. There is also a wheel with mini bearings to support the linear rail on the Y-axis. In the circuit part, I used an Atmega-based printed circuit board that I designed, which enables control of 3 axes, 3 limit switches, and a servo motor. Of course, all the mechanical parts are assembled with the help of designed 3D parts. Let's start the project by assembling the 3D parts and all the hardware step by step.

3D Parts and Hardware

Ekran Resmi 2024-11-02 23.22.33.png
Ekran Resmi 2024-11-02 23.21.43.png
Ekran Resmi 2024-11-05 09.49.18.png
Ekran Resmi 2024-11-02 23.22.03.png
Ekran Resmi 2024-11-02 23.16.40.png

First, let's examine the design of this CNC machine. The two main components are MGN15H linear rails with their corresponding sliding blocks. The motion for the X and Y axes is provided via two GT2 Belts and some GT2 pulleys. As for the Z axis, we have a simple reciprocating motion where the moving part slides up and down via two 6mm linear bars and appropriate springs. A small hobby servo provides this movement. A limit switch is used for each axis for homing and safe movement. The 3D models are attached, the models that need to be printed in two pieces are marked as ‘2x’.

Here is a list of components required for assembly. The list of electronic components can be found in the circuit diagram section of the article.

  1. MGN15H Linear Rail
  2. Linear Rod 6mm (Length approx. 150mm)
  3. Spring 8mm
  4. Stepper Motor (NEMA 17 or equivalent)
  5. GT2 Belt (Approx. 2 metres in length and 6mm in width)
  6. GT2 Tooth Pulley (20 teeth 5mm)
  7. Tension spring for belt
  8. GT2 Idler Pulley (20 Teeth 5mm)
  9. Bolts and Nuts set (Mixed length 2M/3M/4M/4M/5M)
  10. Bearing 605-ZZ (5x14x5mm)

Assembling the X-axis

Ekran Resmi 2024-11-05 09.51.35.png
Ekran Resmi 2024-11-05 09.51.44.png
Ekran Resmi 2024-11-05 09.51.52.png
Ekran Resmi 2024-11-05 09.52.07.png
Ekran Resmi 2024-11-05 09.52.21.png
Ekran Resmi 2024-11-05 09.52.50.png

We can start the first step of machine assembly. Secure the 2 base plates for the X-axis and the 2 linear rail brackets together using a few M3 bolts. Once the two sides are ready, insert the X-axis linear rail into the brackets on both sides and fix them with the help of M5 bolts. MGN15H rails are available in various variations in some markets. As the name suggests, the width of all types is standard 15mm, but some linear types may be different in height, hole widths, and distances between the holes. In this case, the linear rail specifications I use:

  1. Rail width (W): 15mm
  2. Rail thickness (H): 15mm (different type 10mm)
  3. Hole Pitch (P): 60mm (different type 40mm)
  4. Hole Width (d): 5mm (different type 3.5mm)

In summary, some linear rails may differ, so you may have to drill the 3D bracket part with a drill according to the ‘Hole Pitch (P)’ or you may have to update the 3D model. Other differences in dimensions should not be a problem.

Assembling the Y-axis

Ekran Resmi 2024-11-05 09.53.02.png
Ekran Resmi 2024-11-05 09.53.10.png
Ekran Resmi 2024-11-05 09.53.19.png
Ekran Resmi 2024-11-05 09.53.36.png
Ekran Resmi 2024-11-05 09.53.51.png
Ekran Resmi 2024-11-05 09.54.06.png
Ekran Resmi 2024-11-05 09.54.26.png
Ekran Resmi 2024-11-05 09.54.38.png
Ekran Resmi 2024-11-05 09.55.03.png
Ekran Resmi 2024-11-05 09.55.34.png
Ekran Resmi 2024-11-05 09.56.00.png
Ekran Resmi 2024-11-05 09.56.12.png
Ekran Resmi 2024-11-05 09.56.19.png
Ekran Resmi 2024-11-05 09.56.47.png
Ekran Resmi 2024-11-05 09.57.10.png
Ekran Resmi 2024-11-05 09.57.21.png
Ekran Resmi 2024-11-05 09.57.46.png
Ekran Resmi 2024-11-02 23.18.28.png

Now for the Y-axis linear rail assembly. The Y-axis must run above the X-axis linear block and a 3D part called a mounting plate is used to join both axes. First, we can mount the two NEMA 17 stepper motors. One is mounted on the top side of the plate and the other on the bottom side with M3 bolts. Then, two M5 bolts and nuts are fixed to the plate to install the GT2 pulleys in place. The two idler pulleys here are used to provide engagement for the X-axis GT2 belt and stepper motor pulley. It is recommended that the stepper motor gear pulley and the idler pulleys be almost flush. I used several nuts to align the idler pulleys.

Next, I placed the Y-axis linear rail on the plate and fixed it with two M5 bolts. The linear rail hole spacing in the X-axis applies to the Y-axis linear rail, if the hole widths and spacing are not compatible, you can create compatible holes with the help of a drill. After mounting the Y-axis linear rail, the two axes are connected to each other by fixing the mounting plate to the X-axis linear block using four M4 bolts.

Now that the machine has almost taken its main shape, we will add a pulley to the other side of the Y-axis linear rail, that is, to its idle end. This pulley will allow the belt for the Y axis to be installed in a cycle. You can choose this pulley as a toothed or idler pulley, I used a toothed pulley. For the assembly of the cycle pulley, I mounted the 3D part called ‘Y-axis Pulley’ to the linear rail with an M3 bolt. I also designed a support part due to the length of the Y-axis linear rail and the weight of the pen lifter part. In this way, I solved the wobble problem for this axis. I also designed a wheel with a bearing for smooth movement of the support part. I fixed the wheel with bearing to the support part with M5 bolt, and fixed the support part to the pulley part with M3 bolt. Now the Y axis linear block can reach any position in the workspace.

Assembling Pen Lifter and Belts

Ekran Resmi 2024-11-02 23.17.11.png
Ekran Resmi 2024-11-05 09.58.15.png
Ekran Resmi 2024-11-05 09.58.27.png
Ekran Resmi 2024-11-05 09.58.37.png
Ekran Resmi 2024-11-05 09.58.58.png
Ekran Resmi 2024-11-05 09.59.08.png
Ekran Resmi 2024-11-05 09.59.20.png
Ekran Resmi 2024-11-05 09.59.26.png
Ekran Resmi 2024-11-05 09.59.40.png
Ekran Resmi 2024-11-05 10.00.09.png
Ekran Resmi 2024-11-05 10.00.19.png
Ekran Resmi 2024-11-05 10.00.40.png
Ekran Resmi 2024-11-05 10.00.50.png
Ekran Resmi 2024-11-05 10.01.14.png
Ekran Resmi 2024-11-05 10.02.18.png
Ekran Resmi 2024-11-05 10.03.32.png

Now, before the pen lifter, let's assemble the X-axis belt. The X-axis belt is passed between the stepper motor pulley and idler pulleys to provide tension, connectors are connected to each end of the belt and these connectors are fixed to the base side plates with an M3 bolt. If you need more tension, you can choose a tension spring.

Now we can proceed to assemble the pen lifter part. This mechanism consists of two models; one model to be fixed to the Y axis linear block and the other model to move the pen up and down. Firstly, I set the servo motor to 180 degrees angle, and mounted it to the fixed model using the screws that come with the servo motor. Then I placed the pen holder moving model with two springs and two 6 mm rods to the fixed model. When the servo motor is at 180 degrees angle, the pen will stay in the down position, and when the servo motor is at 150 degrees angle, the pen will stay in the up position. The springs will provide tension to push the pen mechanism down.

After assembling the pen lifter model to the Y axis linear block using M4 bolts, we can proceed to connect the Y axis belt. Connect the connectors to both ends of the belt and then secure the belt to the pen lifter using M3 bolts by passing the belt through the stepper motor pulley and the other end of the linear rail. You can use the bolt sliding slots to adjust the belt tension during fixing. You can also increase the tension level by including a tension spring.

Actually this is all in the hardware part, finally I placed the X and Y limit switches in their locations using 2M bolts.

Circuit and Connections

Ekran Resmi 2024-11-02 23.18.46.png
Ekran Resmi 2024-11-05 10.05.08.png
Ekran Resmi 2024-11-05 10.05.52.png
Ekran Resmi 2024-11-05 10.06.22.png
Ekran Resmi 2024-11-05 10.06.40.png
Ekran Resmi 2024-11-05 10.06.59.png
Ekran Resmi 2024-11-05 10.07.09.png
Ekran Resmi 2024-11-05 10.07.40.png
Ekran Resmi 2024-11-05 10.07.50.png
Ekran Resmi 2024-11-05 10.08.12.png
Ekran Resmi 2024-11-05 10.08.39.png
Ekran Resmi 2024-11-05 10.08.54.png

You can optionally use Arduino UNO board and CNC shield in the circuit section, but I designed a printed circuit board with all components together, I use PCBWay for circuit board printing service. You can choose PCBWay for low-budget and high-quality PCBs. You can access the following details and files about the circuit for free from https://www.pcbway.com/project/shareproject/Build_a_simple_3D_printed_CNC_plotter_machine_dfd8b2d7.html.

  1. Circuit diagram
  2. PCB Gerber File
  3. Bill of Materials
  4. Input-Output PINs to which the components are connected

Only the CH340 USB communication chip on the board is SMD type, you may need to be a little careful when soldering. Contact between the legs may cause a short circuit. All other components are easy to solder. If you do not have soldering experience, you can get this board assembled from PCBWay, all you need to do is to select the ‘PCB+Assembly’ option on the PCB page.

Note: The circuit is in 1/16 micro-stepping mode. That is, in full-step mode. So, Motors 17HS4401 Nema 17 rotates 1.8° per step, i.e. 200 steps per full revolution (360° / 1.8° = 200 steps). 1/16 Microstepping: 200 full steps × 16 = 3200 micro-steps/revolution

The circuit board is Atmega328P based and provides control of 3 axes, 3 limit switches, and a servo motor. The project includes two stepper motor axes and it is sufficient to install two standard A4988 stepper motor drivers. Based on the datasheet of the stepper motors used, the required current value should be set with the current screw on the driver. When measuring, you must provide 5-volt power to the card via USB.

If the card is ready, let's make the connections. Connect the X-axis, Y-axis, and servo motor. Then connect two limit switches. Finally, connect a 12-volt and approximately 3-amp power supply. Now let's move on to the software part.

Installation of GRBL

Ekran Resmi 2024-11-05 22.45.38.png
Ekran Resmi 2024-11-02 23.26.55.png
Ekran Resmi 2024-11-02 23.27.08.png
Ekran Resmi 2024-11-02 23.28.09.png

First, we need to add and use a library called ‘grbl-mi’, which is specialized for servo motors. You can access the library from this GitHub link - https://github.com/DIY-Machines/CNC-DrawingMachine

After the library installation is complete, find grbl-mi from the Examples and upload the grblUpload code to the board. After uploading this code to the board, switch on the serial monitor, select the baud rate of 115200, then enter the $$ command to list the grbl parameters. The parameters listed are specific to this machine. But don't worry, many parameters are standard and a brief description of each parameter is provided. The important point here is to make sure you enter the correct values for ‘stepper motor steps in millimeters’ and ‘device dimensions’.

A brief information about the step:

  1. 17HS4401 Nema 17 rotates 1.8° per step, i.e. 200 steps per full revolution (360° / 1.8° = 200 steps).
  2. 1/16 Microstepping: 200 full steps × 16 = 3200 micro-steps/revolution
  3. Each tooth of the GT2 belt used provides a distance of 2 mm (tooth pitch is 2 mm).
  4. Using a GT2 pulley with 20 teeth. This means that when the pulley makes one full revolution, the belt travels 20 teeth x 2 mm/tooth = 40 mm.

In this case, I have set it to 80 steps/mm, which means that for 1.0 mm of movement, the motor has to take 80 steps, which will give exactly 1 mm of movement.

GRBL Parameters:

  1. $0=10 (step pulse, usec)
  2. $1=25 (step idle delay, msec)
  3. $2=0 (step port invert mask:00000000)
  4. $3=0 (dir port invert mask:00000000)
  5. $4=0 (step enable invert, bool)
  6. $5=0 (limit pins invert, bool)
  7. $6=0 (probe pin invert, bool)
  8. $10=2 (status report mask:00000010)
  9. $11=0.010 (junction deviation, mm)
  10. $12=0.002 (arc tolerance, mm)
  11. $13=0 (report inches, bool)
  12. $20=0 (soft limits, bool)
  13. $21=1 (hard limits, bool)
  14. $22=1 (homing cycle, bool)
  15. $23=0 (homing dir invert mask:00000000)
  16. $24=25.000 (homing feed, mm/min)
  17. $25=750.000 (homing seek, mm/min)
  18. $26=250 (homing debounce, msec)
  19. $27=5.000 (homing pull-off, mm)
  20. $100=80.000 (x, step/mm)
  21. $101=80.000 (y, step/mm)
  22. $102=250.000 (z, step/mm)
  23. $110=4000.000 (x max rate, mm/min)
  24. $111=4000.000 (y max rate, mm/min)
  25. $112=4000.000 (z max rate, mm/min)
  26. $120=30.000 (x accel, mm/sec^2)
  27. $121=30.000 (y accel, mm/sec^2)
  28. $122=30.000 (z accel, mm/sec^2)
  29. $130=300.000 (x max travel, mm)
  30. $131=250.000 (y max travel, mm)
  31. $132=200.000 (z max travel, mm)

Universal G-Code Sender

Ekran Resmi 2024-11-02 23.28.43.png
Ekran Resmi 2024-11-02 23.29.24.png
Ekran Resmi 2024-11-02 23.29.57.png
Ekran Resmi 2024-11-02 23.30.30.png
Ekran Resmi 2024-11-02 23.30.49.png
Ekran Resmi 2024-11-02 23.31.05.png
Ekran Resmi 2024-11-02 23.31.32.png
Ekran Resmi 2024-11-02 23.31.56.png
Ekran Resmi 2024-11-02 23.33.45.png
Ekran Resmi 2024-11-02 23.34.47.png
Ekran Resmi 2024-11-02 23.35.05.png

After uploading the code to the board, download and install the Universal G-Code Sender (https://winder.github.io/ugs_website/) software for machine control. You can think of this software as an interface for machine control.

After opening the software, select the USB port to which the board is connected, after the connection with the board is established, you will see the machine parameters on the console screen again. Every change you make in the software will update these parameters. Also, when connected to the machine, the software switches to alarm mode and locks the machine for security purposes. You can switch to normal mode by clicking Unlock.

Then open the ‘Setup Wizard’ section of the software. In the Motor Wiring section, check whether your motors rotate in the correct directions by making small movements and use the reverse motion option if you want. Step Calibration section, you can define the zero point of the machine by moving the machine axes. It would be better to manually bring the machine to zero point every time you run it and click ‘reset to zero. Remember, when moving it manually you have to cut the motor power. If you want, you can check the limit switches in this section and trigger them in the opposite direction. In the limit switch tests, the software will activate the alarm mode and stop the machine.

Then let's do ‘Homing’, the important point here is to make sure that the motors are moving in the right direction before starting the homing process and be prepared to cut the power to the motors just in case. When the homing process is complete, cut the motor power and manually bring the machine to zero point. Now the machine is ready, every time you open the software, bring the machine to zero and click the ‘reset to zero’ button.

Creating G-Code

Ekran Resmi 2024-11-02 23.36.06.png
Ekran Resmi 2024-11-02 23.36.29.png
Ekran Resmi 2024-11-02 23.37.03.png
Ekran Resmi 2024-11-02 23.37.58.png
Ekran Resmi 2024-11-02 23.38.20.png
Ekran Resmi 2024-11-02 23.39.00.png
Ekran Resmi 2024-11-02 23.39.19.png
Ekran Resmi 2024-11-02 23.39.40.png
Ekran Resmi 2024-11-02 23.40.04.png
Ekran Resmi 2024-11-02 23.40.56.png
Ekran Resmi 2024-11-02 23.41.49.png
Ekran Resmi 2024-11-02 23.43.10.png

To use the software we need a G-Code and for this, we will use Inkscape. Firstly download this version of Inkscape and complete the installation. Then download a popular extension ‘4-xi Draw’ extension developed for Inkscape (I could not add the ZIP extension file here, ZIP extension file uploading is not supported. You can access the extension file by going to the link where PCB files are shared), then export the ZIP files and copy all the files in the folder. Paste the copied files into Inkscape's extensions folder.

Open Inkscape and go to Page settings where you set the aspect ratio to close to the machine dimensions in millimeters. Then import any image you want and place it on the page. Select the image and then open Trace Bitmap. In this section, you only need to press the ‘OK’ button and then delete the first imported image. From the Extensions section, go to 4-xi Draw and open the ‘Create Pen’ tool. In this section update the servomotor up and down position angles, define the file name, and click on the ‘Apply’ button. In a few seconds, the image will be created with G-Code and transferred to the specified directory. Now go back to the Universal G-Code Sender software, manually move the machine to zero, select the port to which the machine is connected, select "reset to zero" and then import the G-Code. Press the Run button and the drawing will be started. That's all, we've come to the end of another project. Thank you for reading.