ME 405 Pen Plotter
pc_plotter.py File Reference

This file contains a function for plotting the arm position and drawn shapes live on a PC to match the physical plotter. More...

Functions

def pc_plotter.revert_motor1_target (microsteps)
 Converts the motor1 target value for plotting. More...
 
def pc_plotter.revert_motor2_target (microsteps)
 Converts the motor2 target value for plotting. More...
 

Variables

int pc_plotter.W = 270
 
int pc_plotter.H = 90
 
int pc_plotter.D = 42
 
int pc_plotter.RD = 40
 
int pc_plotter.STEPS_PER_ROTATION = 200
 
int pc_plotter.MICROSTEPS = 8
 
int pc_plotter.MS_PER_RADIAN = 1 / (2 * math.pi) * STEPS_PER_ROTATION * MICROSTEPS
 
 pc_plotter.MOTOR1_HOMING_ANGLE = -int(68.27 / 360 * STEPS_PER_ROTATION * MICROSTEPS * 6)
 
int pc_plotter.MOTOR1_POLARITY = 1
 
 pc_plotter.MOTOR2_HOMING_ANGLE = -int((34.7/2 + 60.24 + 0.9) / 40 * STEPS_PER_ROTATION * MICROSTEPS)
 
int pc_plotter.MOTOR2_POLARITY = -1
 
bool pc_plotter.pen_down = False
 Whether or not the pen is currently down.
 
list pc_plotter.robot = [[0 for _ in range(3)] for _ in range(2)]
 2D list for the position of the points on the robot
 
list pc_plotter.shapes = []
 List of lists of (x,y) tuples, with 1 outer list for each shape.
 
int pc_plotter.curr_shape = -1
 Index of the current shape being drawn.
 
 pc_plotter.fig = plt.figure()
 
int pc_plotter.i = -1
 
bool pc_plotter.started = False
 
 pc_plotter.line = ser.readline().decode().strip('\r\n')
 
 pc_plotter.theta0 = float(line[0])
 
 pc_plotter.theta1 = float(line[1])
 
int pc_plotter.alpha = 1/6 * theta0
 
int pc_plotter.arm_radius = -RD * theta1 / (2 * math.pi)
 
list pc_plotter.x_list = []
 
list pc_plotter.y_list = []
 
 pc_plotter.axes = plt.gca()
 

Detailed Description

This file contains a function for plotting the arm position and drawn shapes live on a PC to match the physical plotter.

Author
Ryan Ghosh
Date
June 10, 2022

Function Documentation

◆ revert_motor1_target()

def pc_plotter.revert_motor1_target (   microsteps)

Converts the motor1 target value for plotting.

Takes in a target value for motor1 that was sent to the TMC4210 and converts it for plotting, undoing modifications that were made based on the direction of the motor and its angle when the limit switch is triggered.

Parameters
Targetposition in microsteps sent to the TMC4210.
Returns
Target position for motor1 in microsteps for plotting.

◆ revert_motor2_target()

def pc_plotter.revert_motor2_target (   microsteps)

Converts the motor2 target value for plotting.

Takes in a target value for motor2 that was sent to the TMC4210 and converts it for plotting, undoing modifications that were made based on the direction of the motor and its angle when the limit switch is triggered.

Parameters
Targetposition in microsteps sent to the TMC4210.
Returns
Target position for motor2 in microsteps for plotting.