Ryan Ghosh and Ryan Flaherty (mecha18)
ME 405-03
For our ME 405 term project, we designed, built, and programmed a polar pen plotter. A Nucleo board on the plotter reads an hpgl file, converts the commands to motor positions, and controls the stepper drivers to make the plotter draw. Meanwhile, a PC receives the commands over UART to draw the same shapes on the screen in sync with the plotter.
The following videos show the plotter in action:
SolidWorks files for the pen plotter can be found here.
All custom parts for the plotter are either 3D-printed or laser-cut.
All stl files can be found in the STLs folder.
In each filename, _x#
indicates the quantity required, and _rev#
indicates the revision number.
The base for the plotter should be laser-cut from 3mm or 0.125" thick material. The dxf file can be found in the DXFs folder.
The following table contains all the parts you need for the pen plotter that are not either 3D-printed or laser-cut:
Item # | Description | Quantity | Source |
---|---|---|---|
1 | 1515 Extrusion (300mm long) | 3 | Amazon |
2 | MGN12C Rail (240mm long) | 1 | RobotDigg |
3 | NEMA17 Stepper Motor | 2 | Printed Solid |
4 | 2GT 20T Toothed Idler (for 9mm belt) | 1 | Printed Solid |
5 | 2GT 20T Pulley (for 9mm belt) | 2 | Printed Solid |
7 | 6201 Bearing | 2 | AliExpress |
8 | 5x25mm Shaft | 1 | AliExpress |
9 | 3x20mm Shaft | 3 | Misumi |
10 | 5x7x0.5mm Shim | 2 | AliExpress |
11 | Omron D2F-L Microswitch | 3 | Digikey |
12 | M3 Square Nut (DIN 562) | 36 | McMaster-Carr |
13 | M3 x 8mm Socket Head Cap Screw | 59 | McMaster-Carr |
14 | M3 x 10mm Socket Head Cap Screw | 5 | McMaster-Carr |
15 | M3 x 12mm Socket Head Cap Screw | 12 | McMaster-Carr |
16 | M3 x 20mm Socket Head Cap Screw | 2 | McMaster-Carr |
17 | M3 Heat-Set Insert (M3 x D5.0 x L4.0) | 27 | AliExpress |
18 | M3 Washer (narrow) | 8 | McMaster-Carr |
19 | M3 Washer (large) | 4 | McMaster-Carr |
20 | 36mm Round NEMA14 Stepper | 1 | Printed Solid |
21 | M5 x 45mm Socket Head Cap Screw | 1 | McMaster-Carr |
22 | M2 x 12mm Pan Head Self Tapping Screw | 6 | AliExpress |
23 | M5 Locknut | 1 | McMaster-Carr |
24 | Unthreaded Bumper | 4 | McMaster-Carr |
25 | Nucleo-L476RG | 1 | Digikey |
26 | TMC2208 Stepstick | 3 | Amazon |
27 | Stepper Driver Board | 2 |
Signal | Nucleo Pin | Color |
---|---|---|
EN1 | C2 | red |
EN2 | C3 | green |
GND | GND | black |
3V3 | 3V3 | gray |
CLK | PB6 | brown |
CS1 | PB8 | yellow |
CS2 | PB9 | orange |
SCK | PB13 (SPI2_SCLK) | blue |
MOSI | PB15 (SPI2_MOSI) | white |
MISO | PB14 (SPI2_MISO) | purple |
Signal | Nucleo Pin | Color |
---|---|---|
EN1 | C6 | blue |
GND | GND | green |
3V3 | 3V3 | yellow |
CLK | PB6 | brown |
CS1 | C7 | orange |
CS2 | 3V3 | white |
SCK | PB13 (SPI2_SCLK) | blue |
MOSI | PB15 (SPI2_MOSI) | white |
MISO | PB14 (SPI2_MISO) | purple |
The wires should be soldered to the outermost legs on the limit switches so that they are normally closed.
Endstop | Stepper Board # | Pin |
---|---|---|
theta | 1 | REFL1 |
radius | 1 | REFL2 |
pen up/down | 2 | REFL1 |
To set the TMC2208 drivers to use 8 microsteps, jumpers should be placed on the JP6 and JP7 headers to short MS1 and MS2 to GND.
To calculate the VREF values to set on the TMC2208 drivers, the desired RMS current should be multiplied by 1.41 ohm.
The following table shows the VREF values we used:
Motor | Target RMS Current (A) | VREF (V) |
---|---|---|
theta | 1.13 | 1.59 |
radius | 1.13 | 1.59 |
pen up/down | 0.35 | 0.49 |
Since our pen plotter uses one motor for controlling the angle of the arm and another to control the radius, we had to use inverse kinematics to determine the motor angles needed to get the pen to the target x and y coordinates. We used the Newtom-Raphson algorithm to find the required motor angles to reach the target position. The following images show the steps we took to find the matrices and equations we would use in the algorithm:
- Simplified schematic of the robot with links and pivots
- Forward kinematics: determine
x = f(theta)
, where theta is the motor angles and x is the pen position - Find the Jacobian matrix for the system
- Differentiate
x = f(theta)
with respect to time to find velocity - Find g(theta), where
g(theta) = x - f(theta)
and x is a constant target position. Then differentiate g with respect to theta.
We then used these equations in the NewtonRaphson function in tasks.py to convert pen positions read from the hpgl file into motor angles.
tasks.py contains the main function that runs on the Nucleo. The program proceeds in the following steps:
- Read an hpgl file and split it into separate commands
- convert target positions into millimeters
- Interpolate between points so that the minimum distnance between any two points is less than or equal to
MAX_MM_DIST
(which we set to 0.5mm) - Use Newton-Raphson to convert the positions to theta angles for the motors
- Convert theta angles to numbers in units of microsteps that can be sent to the TMC4210s as the X_TARGET
- Configure the TMC4210 and TMC2208 chips
- Home all three steppers
- Wait for a button press
- Start the two tasks:
- task_cmds: reads through the commands and sends them to the TMC4210s
- task_comms: sends the current command to the PC via UART to be plotted on the screen
- Disable the motors once the end of the command list has been reached
More details on the individual functions can be found in the documentation for the python files.