A 3-axis pen plotter is a machine that uses three independent axes (X, Y, and Z) to control the horizontal, vertical, and up-and-down movement of a pen. It creates drawings or patterns on flat surfaces by precisely interpreting digital vectors and graphics to position the pen and draw lines.
I chose this project because I want to create something similar for my Fab Academy project, also a 3-axis pen plotter. Building this as my prototype would help me gain a foundational understanding of the machine's design, components, and functionality. This initial version allows me to identify areas that need improvement and refine my approach for the next iteration. Having completed this, I can experiment with key components and workflows, ensuring a smoother and more informed development process for my final Fab Academy project. This project would also incorporate concepts and components I newly learned in EE: stepper motors, microcontrollers, inputs and outputs, etc.
A successful machine would reliably and precisely execute its intended tasks, maintaining performance without errors or interruptions. It would integrate hardware and software components to achieve the desired output effectively.
Created by Dejan from How To Mechatronics
↪ The YouTube tutorial for my project made by How To Mechatronics
Their webpage documentation of their process ←
My project differs from the original tutorial in several key adjustments, such as to the microcontroller code and software settings to accommodate different linear rail sizes. These changes required recalibrating movement parameters such as stepper motor steps and limits to ensure precise operation.
Gantt Chart:
On the outset, I expected to get started sooner, a plan that was foiled due to some materials and components that arrived later than expected. The amount of time I allocated for building the body of the machine was less than it actually took me. Once I started, I expected it would only take 3-4 days, but it ended up taking 5. There were many intermediate setbacks that came up (like some minor missing screws and some parts that had to be reassembled). Overall, I was able to reach my project completion deadline.
Bill of Materials:
There were many materials that we did not need to order, like the Arduino Uno, Servo motors, two of the stepper motors, all of the nuts and bolts, the DC power supply, and the linear rails.
Other Tools and Files used:
Tools: 3D Printer, Hot Glue Gun, Soldering Iron, Slotted Screwdriver, Philips Screwdriver, Hand-held Drill, 3/32 Hex Key, 6/64 Hex Key, Allen Wrench, Tweezers
Files: Arduino IDE, Grbl Plotter Setup, BambuStudio
I simulated the stepper motor on Wokwi:
Directions:
1. Unzip the STL files
2. Load the ones you want to print into Bambu (through the Add cube)
3. After you load everything you need and are satisfied with the orientation, click Slice Plate
4. If there are no warnings about the print, proceed and hit "Print Plate"
My Process:
Print 1:
When I clicked Slice Plate, this warning showed up. I figured out that the floating cantilever was the 90 angle that hovered over the plate
So I flipped it 180 degrees because that would remove the floating issue
But the warning still showed up, so I next tried to solve it using supports. I simply checked the box "enable supports." When I tried slicing the plate again, it did not give me the warning, so I considered it fixed.
Timelapse of the 3D print
The base plates 1 and 2 came out fine and clean
But the Arduino holder was problematic. It came out deformed, and I assumed it was because I did not do the supports properly. I was not familiar with the Bambu software and how to edit the supports there, so I decided to work on other prints I could be confident in performing and come back to this issue later.
Print 2:
Incidentally, on the second printing round, I figured out what the “warning: floating cantilever” issue was: the base of the object was not even and there was a portion that was hanging in the air while another portion was flush, basically tilted.
I found out by “submerging” it into the plate by adjusting the x axis location.
The Solution:
This happened in the first place because when I loaded it in it was perpendicular to the plate. The way I originally rotated it was by manually dragging my cursor until it seemed parallel and flush with the plate. This was, of course, prone to error. What I should have done was go into the bar where it provides angular editing and changed the X degree of rotation to 90 degrees.
This worked, and the print went smoothly
Print 3:
On the third print, I re-attempted the Arduino holder using the newfound method from the second print. It worked.
Print 5:
Print 4:
Print 3 went smoothly, but print 4 was not without roadbumps
Some of the pen holder pieces were too large, so I had to rotate them to fit the work plate
Tools: Slotted Screwdriver, Hot Glue Gun, Philips Screwdriver, Hand-held Drill, 3/32 Hex Key, 6/64 Hex Key, Allen Wrench, Tweezers
Attached the x-axis rail bracket to the base side plate 2
I screwed the x-axis linear rail to the two base side plates, which is also when I noticed one of the bigger problems that will prevail into future parts of the process: my linear rails are shorter than those of the tutorial, which means a lot of the holes did not line up with the printed 3D designs (and the code's operating dimensions would not match those of the shortened rail)
I screwed the y-axis Linear rail to the plate, having the same issue as before
I realized I forgot to print the pen lifter fixed plate
Attached the x-axis rail bracket to the base side plate 1
I screwed the stepper motors onto the central mounting plate
I secured the two y-axis idler pulleys with nuts
In printing it, I figured out that the automated supports that I needed work
I screwed the pen lifter fixed plate to the y-axis linear rail
I screwed the z-axis stepper motor to the plate, attached the stepper lifter
I pushed the Arduino Shield over the Arduino Uno
For the moving plate, I had slight issues with getting the bearings to fit
But for the moving plate, it was too tight and I needed to use a hand drill
I attached a spring into the bottom half, allowing for the needed tension
I screwed on the z-axis limit switches to the fixed plate
I screwed on the y-axis limit switch
I finished the y-axis GT2 belt system with the other belt end connector
I screwed on the x-axis limit switches
I lost my servo motor micro 9g horn and had to reprint one
I found another servo horn in the lab and attached it to the servo and then attached my 3D printed horn to it by screwing it on
I screwed the y-axis idler pulley to the y-axis linear rail
Going back to the base side plate 1, I screwed the Arduino Uno onto it
Going back to the pen lifter, I screwed on the pen holder and servo motor
I was able to use a sharp knife and carve out the plastic to push it through
Then, it finally fit and I could fit the linear rod through, attaching the two
I pulled the servo motor's cord through a small opening in the fixed plate
Video of it making the clicking sound to check for defectiveness
I attached the GT2 belt to belt end connector
I did the same for the x-axis and assembled the pen holder
Going back to the issue of the linear rail sizes, I found that they would often slide around because they lacked many of the other screws necessary to secure it. To temporarily solve it, I used hot glue to make it slide less
I found that it would not attach securely to the servo, it was loose
Circuit diagram provided by How To Mechatronics
My wiring (it is flipped from the original circuit diagram)
The wiring for the stepper motors was one of my concerns. I was missing a cord for one of them and for the other, there was constantly one blue wire that would slip out. Luckily, I was able to find a spare cord from the fab lab (the black one in the picture) that connected to the stepper motor and the Arduino shield. The How To Mechatronics video did not offer a clear view of the circuitry, so I had to assume based on the provided circuit diagram that the tan colored line was power. It was also made confusing by the fact that it was rotated 180 degrees from the board I was using, which made things more complicated. I had to constantly double-check the orientation of my wires, whether I had it in the correct pin or not.
I connected wires to the DC power supply
I connected those wires to the Arduino power supply as well, securing them
I connected wires to the z-axis limit switch power
I connected wires to the y-axis limit switch
I connected wires to the z-axis limit switch ground
I connected wires to the x-axis limit switch
Tools: Soldering iron
Z-axis limit switch wires soldered on
Y-axis limit switch wires soldered on
X-axis limit switch wires soldered on
Files: Arduino IDE, Grbl Plotter Setup
For controlling the motion of the CNC Machine
Files: Arduino IDE
1. Downloaded the open source grbl code used for DIY cnc machines. Specifically, a modified version that can control the servo motor, grbl-servo
Code --> Download Zip
2. Move it into your Arduino IDE library (should be found under Documents-> Arduino-> library)
3. Modify the config.h file to allow for 3-axis homing instead of its default 2-axis homing
4. Open grbl->grblUpload under Examples for any board
These three steps were where I started having a few issues. I was able to get the file into libraries, but I did not know how to open the config.h files to edit them. As seen to the right, when I tried to open it using Arduino, it gave me a "Bad file selected" error. After asking some peers, I realized that I needed to open the code with an app that allowed me to edit text, like Notes, pages, or TextEdit, which I opted for.
Through TextEdit, I made the necessary changes and tried opening the grbl board on Arduino
To find the board, I needed to go under File-> Examples-> Examples for any board
However, grbl did not show up. When I went back into my Files, I saw that my downloaded file had a warning about iCloud Storage issues, so I thought that might be the culprit.
In response, I switched from my Mac to a Windows PC, where there would not be any storage issues connected to my iCloud.
I copied my entire process the exact same way, but I faced the same issue with grbl not showing up on Arduino on the PC. Then, I tried using another file editing software to edit the config.h and I found that Visual Studio Code worked better and would allow me to save my code. I downloaded it to my Mac to see if it would solve my Arduino library problem.
Visual Studio Code itself did not solve the problem, but I ended up finding my solution by looking more closely at the tutorial video.
Rather than moving the entire grbl-servo-eggbot file to the Arduino library, the original tutorial copied the individual grbl file to it.
Like so on PC
And then the grblUpload option finally appeared. I also made the change of opening it in Arduino IDE rather than just Arduino (even though the library is technically under Arduino) which I inconveniently had downloaded as well.
5. With grblUpload selected and a new code window opened, upload it into the Arduino Uno
Since I got the grblUpload to open on my Mac first and was not sure if the same approach would work for the PC, I tried to connect my Arduino to my Mac through an adapter.
Trying to use an adapter
Using the PC's COM
I tried testing both of my laptop's left-side ports. I also checked that my board was an Arduino Uno and that it wasnt on COM 1.
That plan did not work, so I ended up switching back to PC, opening it in VSC then Arduino IDE. Through the PC, I was able to successfully upload it.
For sending G-codes to tell the machine what to do
Files: Grbl Plotter Setup
1. Download --; go to "grbl-plotter.de"-> click on the github.com/svenhb/GRBL-Plotter-> GRBL-Plotter_Setup.exe
2. Connect your Arduino Board to the software through the suitable COM port
3. Press "Kill Alarm" and see the list of the current grbl parameters on the Serial Monitor (this alone did not work for me and I had to click "Check GRBL" too)
These parameters need to be changed according to your machine:
Travel resolution (steps per millimeter value): indicate hoe many steps the motor should take in order to move one millimeter; depends on the type of stepper motor you have, step resolution, and motion transmission (GT2 belt and pulley)
There are also other changes to make, such as where the limit switches are located, setting the maximum feed rate, maximum acceleration, maximum travel speed, parameter number (to 255 enables the stepper motor to be active all the time), etc.
4. Adjust the controller setup under Files-> Setup
Pen up/pen down translation controls the Z-axis boundaries
Tool table allows you to change the colors and the positions of the pens (here it is by 21.7)
Tool Change allows you to change and upload the code that will control the machine. It tells the machine how to get to the right pen, take it, and returning it to the pen holder as needed. We need to change the first two to pen2_remove and _select.
1. Find an image you want to draw and convert it into a filetype the software accepts (I found that PNG always works)
2. Load your image under G-Code Creation->Create G-Code from Image-> Load Picture
3. Play around with the colors (it can help you choose colors based on the ones in your tool table from earlier) to suit your vision
4. Select "Create G-Code" when you have finalized your image, color choices and all the other settings
5. With the G-Code Image created, you can make even more edits about the printing and machine processes
To the left you have the G-Code code for the plotting. In the center canvas, you can edit the size of your drawing and orientation. You can also change the origin, home, zero axes, etc.
I originally tried to print the apple, but I had a lot of issues with that.
The first time I tried to start the plotter, the machine turned on, the servos were spinning, but the belts and pulleys were not moving
Close-up video of the servos spinning without pulling the belts with it
At this point, it was clear that the issue was because the idler pulleys were loose. This was because I did not know to tighten them earlier on. However, with the idler pulleys already connected to the stepper motor passing through the plastic, there was no way for me to be able to tighten the screws. So I had to unscrew both of my stepper motors x and y to tighten them and re-screw them in.
After the whole tightening process, I first used a finger to check if turning the idler pulley would turn the stepper motor with it, which it did
That gave me more confidence to try it by playing the apple g-code, which is also worked for.
After a few more trials, the apple was a bit too challenging, so I opted for something more simple: a rectangle
Even so, I had a lot of technical issues with plotting. Here, the pen plotter would go beyond the dimensions it is capable of, which is why I think it emitted a grinding noise
I remembered that my linear rail sizes are different, so I went to serial monitor and changed the maximum travel distances from 200 to 100
With this change, I found that it created more of the correct shape, and more in the correct direction. Instead of going towards the pen holders, it went towards the center of the canvas. But it was unable to complete the rectangle.
I decided to simplify it further: down to a line
Inputs:
1. G-code commands: the g-code generated by the software that specify the coordinates, tool changes, and actions for the plotter
2. Limit Switches: detect the end stops of the axes, so that the plotter does not exceed its operational range
3. Power Supply: Electrical input powering the Arduino, motors, and other components
4. User commands: A connected computer to start, pause, or stop the machine
Outputs:
1. Stepper motor movement: Outputs from the Arduino to drive the X and Y stepper motors for precise pen movement
2. Servo motor movement: Output to control the servo motor for pen lifting/lowering and tool changing
3. Pen movement: The physical output of the pen drawing on the surface as dictated by the G-code
Inputs: G-code commands, limit switches, power supply, user commands; Outputs: stepper/servo motor movement, pen movement working
Drawing a line with the pen plotter is an effective way to demonstrate that inputs and outputs are functioning correctly. The G-code commands provide the coordinates for the actions required to draw the line, proving the software interface is properly integrated with the hardware. As the line is drawn, the stepper motors must move the X and Y axes, validating the output signals from the Arduino and the motors’ operation. The pen plotter stopped when it hit the x-axis limit switch, confirming their functionality. Additionally, the power supply powers all components. My user command of starting the machine from a computer interface, shows that input to work. However, I found that the output for the z-axis stepper motor movement did not work and the pen would not properly lift.
Throughout the process of building my 3-axis CNC pen plotter, I encountered numerous trivial challenges, but there are a few notable ones that are worth analyzing. One notable issue arose during the 3D printing phase when a warning about a floating cantilever indicated instability in the design. Initially, I attempted to fix it by enabling supports, but that did not solve the root issue. The reason it arise was because I rotated the object by hand, causing misalignment with the print surface. I resolved this by using the rotation tool in the 3D printing software, ensuring the base aligned perfectly with the plate, which eliminated the cantilever issue.
Another significant challenge was adapting the design to accommodate linear rails of different lengths than those specified in the tutorial. This problem would arise in various stages of the project. Since the rails determined the machine's dimensions, I needed to modify the software settings to reflect the new measurements. This required a deep dive into the setup and some trial-and-error to ensure the software recognized and correctly adapted to the adjusted dimensions. On a mechanical level, I had to prevent the rails from sliding too much by temporarily securing them with hot glue.
A smaller, yet crucial, issue was with the size of the holes in the 3D-printed pen lifters. The holes were too small to fit the linear rod, so I overcame this by carefully widening the holes with a drill, allowing for a functional fit for the rod without compromising the integrity of the 3D-printed part.
On the software side, I struggled to get the GRBL code properly loaded into the Arduino library. Following the tutorial’s original instructions, I initially moved the entire GRBL-servo-eggbot folder to the library, which caused errors. After properly looking at the tutorial, I realized the correct approach was to copy only the individual GRBL files to the Arduino library. This allowed the code to compile and function as intended.
Finally, troubleshooting the machine’s G-code functionality was an ongoing challenge. Every time I ran a G-code, the plotter failed to produce the expected results. After persistent adjustments and testing, I managed to resolve the issue to the extent that the machine could successfully draw a single line. While there is still room for improvement, this milestone marks progress in understanding the machine's behavior and its software intricacies. These experiences highlighted the importance of precision, adaptability, and patience in tackling a complex engineering project.
Working on the pen plotter project taught me a great deal about integrating hardware and software to create a functional machine. Up until now, I have never tackled any engineering project as close to this "advanced." I learned how each component—stepper motors, servo motors, limit switches, and the Arduino—works in a specific role in the system with a specific purpose. From my struggles, I learned how precise coordination between them is essential for success. Debugging issues, such as tedious trial and error and inconsistent pen movement, highlighted the importance of patience and attention to detail in engineering projects. This project also taught me the value of careful planning and iterative testing to ensure that each step builds on the last, leading to a cohesive final product.
Completing a large project like this also helped me better understand the complex nature of project management and problem-solving. Breaking the project into smaller milestones made the process more manageable, while unexpected challenges, like editing the setup for slightly different linear rail sizes, required creative adjustments. I learned how crucial documentation is for troubleshooting and for future improvements, as clear records of settings and configurations made testing much easier. This process also reinforced the importance of adaptability and perseverance when working through setbacks.
Through this project, I discovered a lot about my strengths and areas for growth. I found that I enjoy the hands-on, problem solving aspect of projects like this, especially when the machine started inching towards productive results. However, I realized that there were some software issues that were beyond my understanding and capacity to fix under such a tight schedule. This made me realize that I should grow in my software skills to be better equipped to handle similar complex challenges in future projects. I also realized the need to improve my time management and organization when balancing multiple aspects of a project. For this one, there was the mechanical aspect, the software one, and the troubleshooting process that I never expected to be so extensive and frustrating. Notwithstanding, this experience gave me greater confidence in my ability to tackle technical challenges and motivated me to continue exploring mechatronics and engineering.
Looking ahead, I would focus on making the pen plotter capable of handling larger, more complex images. This would involve working my way up to a successful rectangle and then back to the apple where I started. The future of this project lies in addressing the software issues that currently limit its functionality, as resolving these challenges will unlock its full potential. While the pen plotter is capable of drawing a line, troubleshooting the underlying problems related to the stepper motors and the g-code. This project is meant to be something of a prototype for my Fab Academy project, so the issues I am facing now will be prevalent for the future. Finding a solution along the way will greatly benefit me. This process will not only improve the functionality of the project but also provide me with valuable experience in diagnosing and overcoming technical barriers, a skill that will serve me well in future engineering endeavors, such as Fab Academy.