2-D CNC Pen Plotter

Alex Jaus, Will Voge, Patrick Murray

Introduction

The 2-D CNC Pen Plotter is a device that takes in a human input and draws it on a piece of paper.

The plotter takes in human commands and produces an image based on the commands. The computer processes and sends the commands to the microcontroller. The microcontroller then parses the commands and creates movement commands for the motors. These movement commands direct the motors to the proper locations to create the desired image.

High-Level Design

The basic idea for this project comes from two things: a printer and a cnc machine. The device will serve a similar frunction to a printer, while operating under a control scheme very similar to a cnc.

There are a few limitations to the design. The first is the resolution. We are using a felt-tipped marker. There will be somee accuracy lost due to the large are covered by the marker tip compared to a pen or pencil. The felt-tipped marker was chosen because it gives the most consistent line when drawing in our design.
Another limitaiton is print area. Since we are unable to have the marker rightn next to the feed in our current design, we cannot cover an entire page without losing the feed, and therefore the ability to move the paper. In future iterations, we could slightly extend the distance between the feed and the carriage, allowing for the marker to be placed on the other side of the carriage and therefore closer to the edge of the feed, however there will still be at least a 1" margin.

Program Design

The programming is split into two segments, the embedded software and the python software that is run on a computer. The embedded software interfaces with the stepper motors and the servo, taking instructions from the computer. The computer creates the instruction list and sends that over via serial to the microcontroller.

The embedded software has 5 threads: One to move the y stepper motor, one to move the x stepper motor, one to move the servo, one to read in the serial data, and one to parse the serial data and run the commands.
The UART data is read in on its thread to a buffer that is ended with a carriage return byte (\r). Once the read is complete, the buffer contains the entire packet and signals the parse function to start.
The parse funciton runs a state machine to iterate over the received packet and split it up into the command string and two argument strings. Once the state machine finishes putting the command and any arguments into their own strings, the parse thread decides which command it is, and then passes the arguments accordingly and runs the functions associated with that command. The commands are as follows:

PING This command is to synchronize the computer with the microcontroller. When the PIC receives PING, it will respond with PONG
M [X Movement] [Y Movement] This is the relative move command, that takes in two arguments, the amount to move in both axes in inches. These values are floats and will run both stepper motors to move the pen the given amount of inches.
G [X Position] [Y Position] This is the absolute move command, it will run both stepper motors to put the pen on the given coordinate, with the home position being (0,0)
A [1 or 2] This command moves the pen off the paper (2) or on the paper (1)
S [X Speed] [Y Speed] This is the speed set command. It sets the speeds of each stepper motor. The speed arguments are integers, with 1 being the fastest and higher numbers being slower. The units are in 500*Steps/second.

The device communicates with the stepper motors by first converting the float value in inches to number of steps, using experimentally derived conversion factors. Once it has the number of steps, it sends that many pulses to the motor, delaying by S milliseconds between each transition, where S is the speed supplied by the S command.
When any of the above commands are done executing, they will respond via serial with "ACK" to let the computer know to send the next instruction. For the M and G commands, the "ACK" will only be sent when both motors are finished moving.
When the motors are not in use, they are slept, to conserve power and limit thermal output.

The computer python script takes a series of instructions and sends them over serial to the PIC. The script first pings the device, and when a "pong" is received it issues the first instruction. The script then waits for an "ACK" from the device, then issues the next instruction.

Hardware Design

For the hardware, we had 2 stepper motors plus controllers and couplers for 5/16" rods, 1 servo motor, and a frame. For the frame, we used a 1"x3"x8' pine board, a 20" smooth 5/16" hardened steel rod, a 12" threaded 5/16" steel rod, 3 bushings and 2 ball bearings for the rods, and 10 1 1/4" #8 screws. Finally, we used a Sharpie™ Marker to draw with.
We had many specifications for the hardware design. The most important was that we have a space greater than 8.5" wide in orde to fit a sheet of paper. We also wanted to minimize the margins on each edge of the page.
We started with the wooden frame design. We decided on two L-shaped blocks connected by a top support bar. The two L-shaped blocks had a horizontal piece that was 7" long and a vertical piece that was 5 1/2" long. The length for the horizontal piece was chosed to provide stability, and the height was chosen to allow for a sharpie to fit under the top support bar. We chose to put the horizontal pieces outside of the veritcal pieces to shorten the top support bar. The top support bar was then chosen to be 10.25" long, since the 1"x3" board is 3/4" thick, leaving an 8 3/4" space for the paper. The pieces were then cut with a skill saw and aligned with a t-square and clamps before screwing the boards together.
After the frame was completed, holes were drilled on each side of the frame to accomodate the couplers, bearings, and bushings for the steel rods. 3/8" holes were required for the bushings, 5/8" for the couplers, and 7/8" for the bearings. The holes were measured again with a t-square to ensure they were aligned properly. We had a hole in the bottom middle of each vertical board to provide the lower support for the servo motor carriage. Then, another hole was drilled 1 1/2" above to provide the upper support for the carriage. Then, holes were drilled in the horizontal piece for the feed roller. After the holes were drilled, we also had to drill holes for the motor mounts. The motor was a 1 7/8" square with the 4 mounting holes in 7/32" from each edge. We drilled a small hole all the way through each position for the motor mount and then drilled a larger hole with a 3/32" left to provide an attachment point for the mounting screws.
The wheels for the feed roller were made using a bandsaw to cut rough circles from the pine, 5/16" holes drilled into the center, and then a lathe to smooth down the wheels. Rubber bands were then placed around the wheels to ensure that each could grip the paper and touch the ground evenly. The carriage for the servo motor was made by cutting a 1"x3"x2" block and drilling 3/8" holes into the face of it centered and 1 1/2" apart for the two rods to pass through. Then a hole was drilled into top to mount the motor with a screw. The rods for the feed roll and to move the carriage were cut on a chop saw with a metal grinding blade to 10".
After this, we attached all of the components to the frame. For the motors, we used M3 mountind screws. For the wooden connections, we used 1 1/4" #8 screws. For every other part, we used super glue to hold the pieces together.
We used three motors, two stepper motors and a servo motor. The stepper motors also had motor controllers that prevented overcurrent and overheat protection. The controllers generated a signal to send to the stepper motors based on the information received from the PIC32. The servo motor was supplied with a PWM signal to turn it. The two steooer motors had couplers that attached them to the rods. The motor for the feed roller was attached to a smooth rod. The other motor was attached to the threaded rod. The servo motor was attached to the carriage using one of the 1 1/4" #8 screws. The marker was attached to the front disc on the servo motor with super glue and tape. Both were used because neither provided enough stability alone when we were testing.
We tried a few other approaches for the design. The original design was to have two vertical boards next to each other and hold them together with the top support bar. This plan did not work because we were unable to have a base with enough stability and enough room to hold both the feed roll and the carriage. We also tried the horizontal blocks on the inside, but then the distance was too long for the top support rodeo and the last word offered.


The black wire running next to the roller is not part of the project and is not there when the printer is running.
Also, the paper currently in the printer is currently not in position. The correct position will have the paper centered between the two vertical posts.

Results

The pen plotter was not entirely functional at the end of the work period due to a few reasons. The feeding mechanism was inconsistent and this was the root of the many issues we struggled with. Both axes of the plotter need to be reliable in order to plot letters or designs on the paper. The carriage axis was relatively reliable and was able to return to the same spot on its axis. The feed mechanism would twist and turn the paper as it attempted to move the paper along its axis. This would cause lines to look curved and would make curved lines almost impossible to produce. With many hours of trial and error and meticulous calibration of the machine we were able to produce reasonable quality rectangles and letters. Another issue was that we used a rotational servo for placing the pen on the drawing surface. This caused two issues. The pen height was difficult to calibrate and when miss calibrated the pen would easily be too high above the drawing surface or would drag along the drawing surface, creating unwanted streaks and shorter than desired lines.
The software on the other worked rather reliably. The firmware that the PIC32 was running would consistently attempt to produce the correct outputs for the inputs it was given. When data was sent over an RS232 connection the UART would receive the data and a thread would parse it and convert the action into digital outputs or a change in internal state. Commands sent to the PIC32 were always interpreted correctly and would not produce incorrect control information or change internal state of the controller. The electronics that were connected to the PIC32 would also correctly respond by driving the stepper motors or setting the state of the servo.
The python script(s) used to assist in automating the plotter also worked reliably. The script would first initiate a handshake to determine that the machine was ready to receive information. On completion of this initialization it would begin to send print commands from a plotter program file to the PIC32 microcontroller. The script would display and results from the PIC32 as well as wait for acknowledgment that the previous command was completed before proceeding to the next one. The script and microcontroller never fell out of being synchronized except in cases were a hard reset was required due to mechanical failure. In general the design was limited by the mechanical hardware's limitations.


Conclusions

Overall, the printer worked very well. We only had two major issues. The first was the marker would leave a small streak when it lifted. This could be fixed by Using a different way to lift the marker, or maybe using a pen or pencil instead of a marker. Also, we had difficulty with the paper feeding straight. This came down to construction materials and the feed roller. Next time, we could build the frame with laser cut plexiglass and use a solid roller. Also, we could add a plate underneath the pressure feed roller. This would prevent the need to keep the device stationary on a table, since the feed roller would not make contact with anything not fastened to the device. Another thing to add would be guides for the paper. Since the rollers were made of wood, they were not perfectly round. Since they were not round, the paper would not always feed straight.
Overall, the project covered all of the applicable standards, relying on the microcontroller as an interface between the computer and the mehanical parts of the printer. Many concepts in this design are not new though, so other than possibly the instruction set, there are no intellectual property considerations.
In terms of ethics standards, our device makes modest attempts to provide safety to operators. In order to operate this device the operator can remotely transmit the image program over a serial link. This allows the operator to be safe if the mechanical structure may cause harm. The choice to use a stepper motor driver with thermal and current limiting drastically decreases the chance that the motors or computer boards could overheat and cause direct hard to the operator. The device does not protect a user from pinching from the carriage or turning up the speed of the roller which would cause the device to project itself forward. In terms of bribery, this device makes no attempt to extort others for money or intentionally cause any harm.
As far as we know, there are no copyright or patent infringements, and there are no other applicable laws that we know of.

Appendices

Bill of Materials

Python Serial Code

Main PIC32 Code

Zipped Main PIC32 Code