ME305Lab
Functions | Variables
taskMotor.py File Reference

Task responsible for driving motor. More...

Functions

def taskMotor.taskMotorFcn (taskName, period, ENABLE, KEYFLAG, TASKFIN, KPSHARE, KDSHARE, BALLPOS, BALLVEL, rollShare, pitchShare, rollvShare, pitchvShare)
 Motor task function. More...
 

Variables

 taskMotor.S0_INIT = micropython.const(0)
 
 taskMotor.S1_STAY = micropython.const(1)
 S1_STAY. More...
 

Detailed Description

Task responsible for driving motor.

Runs closed loop driver and motor driver. Reads data from touch panel and IMU, and runs through controllers to calculate duty cycles for motors. Outer loop control uses ball position from touchpad to create theta_ref values. These are passed into inner loop controllers, which output the motor duty cycles. If no ball is detected, theta_ref is zero, and the platform will balance upright.

Author
Theo Philliber
Ruodolf Rumbaoa
Date
03/18/2022

Function Documentation

◆ taskMotorFcn()

def taskMotor.taskMotorFcn (   taskName,
  period,
  ENABLE,
  KEYFLAG,
  TASKFIN,
  KPSHARE,
  KDSHARE,
  BALLPOS,
  BALLVEL,
  rollShare,
  pitchShare,
  rollvShare,
  pitchvShare 
)

Motor task function.

Generator function that runs through states. Instances motor drivers (x and y), and creates controllers (x/y - inner/outer). Outer loop control uses ball position from touchpad to create theta_ref values. These are passed into inner loop controllers, which output the motor duty cycles. If no ball is detected, theta_ref is zero, and the platform will balance upright.

Parameters
taskNameName of task
periodMinimum period of time between subsequent runs of function.
ENABLEMotor control is enabled/disabled.
KEYFLAGShare containing value of key pressed by user.
TASKFINBoolean share acknowledging if an action has been completed. Used to verify synchronicity between tasks.
KPSHAREShare containing Kp value, proportional gain.
KDSHAREShare containing Kd value, derivative gain.
BALLPOSShare containing tuple of ball position (x, y, contact). x and y are in mm; contact == 1 if ball is present, 0 if not.
BALLVELShare containing tuple of ball velocity (xdot, ydot).
rollShareContains value of roll angle from IMU.
pitchShareContains value of pitch angle from IMU.
rollvShareContains value of roll angular velocity from IMU.
pitchvShareContains value of pitch angular velocity from IMU.

Variable Documentation

◆ S1_STAY

taskMotor.S1_STAY = micropython.const(1)

S1_STAY.

Keeps platform and ball upright. Reads IMU and touchpad data, and passes into controller classes. Uses output to set duty cycles to drive motors.