Back in school, there was an HP plotter well hidden in a closet in the science department. I got to play with it for a while and always wanted to have one of my own. Fast forward many, many years. Stepper motors are easily available, I am back into doing stuff with electronics and micro-controllers, and I recently saw someone creating displays with engraved acrylic. This triggered me to finally build my own plotter.
As an old-school 5V guy, I really like the original Arduino Uno. Here’s a list of the other components I used (fyi, I am not affiliated with any of these companies):
As you can see here, I started out much too large. This plotter can’t comfortably sit on my desk, but it’s okay, as I did it for learning purposes (and, as I have to re-do some things, next time I’ll use smaller beams).
I’ve stacked several components on top of the Arduino. The Arduino is on the bottom, above that is the FabScan shield, next is a StepStick protector on motor slots 1+2, and the SilentStepStick is on top. Note that the SCK and SDI pins are not connected.
Be careful to correctly attach the wires to the motor. When in doubt, look at the data sheet or an ohmmeter to figure out which wires belong together.
Software setup
While software like grbl can interpret so-called G-codes for tool movement and other things, and I could have just flashed it to the Arduino, I am curious and wanted to better understand things. (My X-Y plotter software is available at GitHub and comes without any warranty.)
To drive a stepper motor with the StepStick (or compatible) driver, you basically need to send a high and then a low signal to the respective pin. Or in Arduino terms:
Where stepPin
is the pin number for the stepper: 3 for motor 1 and 6 for motor 2.
Before the stepper does any work, it must be enabled.
digitalWrite(enPin, LOW);
Actually, the StepStick knows three states for the pin:
When a motor is enabled, its coils are powered and it keeps its position. It is almost impossible to manually turn its axis. This is good for precision purposes, but it also means that both motors and driver chips are “flooded” with power and will warm up.
And last, but not least, we need a way to determine the plotter’s direction:
digitalWrite(dirPin, direction);
The following table lists the functions and the pins
Function | Motor1 | Motor2 |
---|---|---|
Enable | 2 | 5 |
Direction | 4 | 7 |
Step | 3 | 6 |
Before we can use the pins, we need to set them to OUTPUT
mode in the setup()
section of the code
With this knowledge, we can easily get the stepper to move around:
This will make the slider move left and right. This code deals with one stepper, but for an X-Y plotter, we have two axes to consider.
I started to implement a simple command interpreter to use path specifications, such as:
"X30|Y30|X-30 Y-30|X-20|Y-20|X20|Y20|X-40|Y-25|X40 Y25
to describe relative movements in millimeters (1mm equals 80 steps).
The plotter software implements a continuous mode, which allows a PC to feed large paths (in chunks) to the plotter. (This how I plotted the Hilbert curve in this video.)
In the first image above, the pen was tied to the Y-axis with some metal string. This was not precise and also did not enable the software to raise and lower the hand (this explains the big black dots).
I have since created a better, more precise pen holder that uses a servo to raise and lower the pen. This new, improved holder can be seen in this picture and in the Hilbert curve video linked above.
The pen is attached with a little clamp (the one shown is a size 8 clamp typically used to attach cables to walls). The servo arm can raise the pen; when the arm goes down, gravity will lower the pen.
Driving the servo is relatively straightforward: Just provide the position and the servo does all the work.
// Servo pin
#define servoData PIN_A1
// Positions
#define PEN_UP 10
#define PEN_DOWN 50
Servo penServo;
void setup() {
// Attach to servo and raise pen
penServo.attach(servoData);
penServo.write(PEN_UP);
}
I am using the servo headers on the Motor 4 place of the FabScan shield, so I’ve used analog pin 1.
Lowering the pen is as easy as:
penServo.write(PEN_DOWN);
One of my next steps will be to add some end detectors, but I may skip them and use the StallGuard mode of the TMC2130 instead. Those detectors can also be used to implement a home
command.
And perhaps in the future I’ll add a real Z-axis that can hold an engraver to do wood milling, or PCB drilling, or acrylic engraving, or … (a laser comes to mind as well).
What is the Main Cause of a Heart Attack? What is its Solution? A heart attack is the blockage of… Read More
In the vast economic arena, one term that often takes center stage, inciting extensive debates and discussions, is the "debt… Read More
De-Dollarization: The Changing Face of Global Finance The financial landscape is in a state of flux, with an intriguing economic… Read More
The curtains closed on a dramatic Bundesliga season with Bayern Munich standing tall once again, clinching their 11th straight title.… Read More
The Unfolding Story of Celine Dion's Health In recent news that has left fans across the globe stunned, iconic singer… Read More
As the echoes of the recent NBA season start to fade, the attention of enthusiasts is firmly glued to one… Read More