ME305Lab
|
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... | |
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.
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.
taskName | Name of task |
period | Minimum period of time between subsequent runs of function. |
ENABLE | Motor control is enabled/disabled. |
KEYFLAG | Share containing value of key pressed by user. |
TASKFIN | Boolean share acknowledging if an action has been completed. Used to verify synchronicity between tasks. |
KPSHARE | Share containing Kp value, proportional gain. |
KDSHARE | Share containing Kd value, derivative gain. |
BALLPOS | Share containing tuple of ball position (x, y, contact). x and y are in mm; contact == 1 if ball is present, 0 if not. |
BALLVEL | Share containing tuple of ball velocity (xdot, ydot). |
rollShare | Contains value of roll angle from IMU. |
pitchShare | Contains value of pitch angle from IMU. |
rollvShare | Contains value of roll angular velocity from IMU. |
pitchvShare | Contains value of pitch angular velocity from IMU. |
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.