![]() |
Pen Plotter Project
|
Main file for pen plotter robot which is run by the user. More...
Functions | |
def | main.task_data_collect () |
Collects X/Y data from HPGL drawing and converts into readable commands for rotational/radial/servo motors. More... | |
def | main.stop_motors () |
Stops rotational and radial motors; used at the end of main.py program. | |
def | main.task_rot_motor () |
Rotational motor task drives the motor to specified setpoint and repeats the process with new setpoints until there are none left. More... | |
def | main.task_rad_motor () |
Radial motor task drives the motor to specified setpoint and repeats the process with new setpoints until there are none left. More... | |
def | main.task_servo () |
Sends a PWM signal to the servo to make the pen go up or down based on whether the converted HPGL command is a 1 or 0. | |
Variables | |
int | main.ticks_per_rev = 256*2*16 |
Ticks. | |
float | main.r = 0.375/2 |
int | main.S0_DATA_INIT = 0 |
int | main.S1_COLLECT_DATA = 1 |
int | main.S2_CONVERT_DATA = 2 |
int | main.S0_INIT = 0 |
int | main.S1_START = 1 |
int | main.S2_DRIVE_MOTOR = 2 |
int | main.S3_CHANGE_SETPOINT = 3 |
int | main.S4_STOP = 4 |
int | main.S0_SERVO_INIT = 0 |
int | main.S1_PEN_UP = 1 |
int | main.S2_PEN_DOWN = 2 |
main.q_theta_rad | |
main.q_theta_rot | |
main.q_servo | |
main.file_name = input('Enter HPGL filename: ') | |
main.task_rot | |
main.task_rad | |
main.task_srvo | |
Main file for pen plotter robot which is run by the user.
The program begins by creating state variables, queues, and asking the user for HPGL filename. Once the user inputs the filename, our data collection task is run to put all the setpoint values for respective radial/angular/and servo motor into queues. The task functions for each motor are then created as objects using cotask and appended to a list. This list is then continuously run until there are no setpoint values left in each queue. Finally, the motors are turned off and a print statement lets the user know the program is over.
def main.task_data_collect | ( | ) |
Collects X/Y data from HPGL drawing and converts into readable commands for rotational/radial/servo motors.
Opens file specified by the user and converts HPGL standard commands to readable code to be put in a queue and read by other tasks as setpoint values for motor control. X/Y coordinates are converted to polar coordinates in revolutions for respective motors to spin. Finally, the setpoints in revolutions for DC motors and up or down commands for pen are put into their resepctive queues.
def main.task_rad_motor | ( | ) |
Radial motor task drives the motor to specified setpoint and repeats the process with new setpoints until there are none left.
First the radial motor/encoder pins are initialized and created as objects along with a controller. Next, the encoder is zeroed and a timer is started for which a motor will be driven to a setpoint by a controller which constantly updates and sends duties to the motor based on position control. After 1 second another setpoint value is given to the controller for which the motor is driven again. This is repeated until there are no setpoint values left in the queue and the motor is stopped.
def main.task_rot_motor | ( | ) |
Rotational motor task drives the motor to specified setpoint and repeats the process with new setpoints until there are none left.
First the rotational motor/encoder pins are initialized and created as objects along with a controller. Next, the encoder is zeroed and a timer is started for which a motor will be driven to a setpoint by a controller which constantly updates and sends duties to the motor based on position control. After 1 second another setpoint value is given to the controller for which the motor is driven again. This is repeated until there are no setpoint values left in the queue and the motor is stopped.
main.q_servo |
main.q_theta_rad |
main.q_theta_rot |
main.task_rad |
main.task_rot |
main.task_srvo |