Lucas Murray ME 305 Portfolio
Functions | Variables
taskMotor_F.py File Reference

Runs tasks sent by the taskUser file and performs ball balancing. More...

Functions

def taskMotor_F.taskMotorFcn (taskName, period, wFlag, kFlag, hFlag, cFlag, duty, Eang, Vang, Poxy, Voxy, Cart, Cast, controlParameters)
 Runs the relevant motor tasks as determined by taskUser and runs closed loop control. More...
 

Variables

 taskMotor_F.S0_INIT = micropython.const(0)
 Defines the State 0 Initiate variable as the constant 0.
 
 taskMotor_F.S1_WAIT = micropython.const(1)
 Defines the State 1 Wait variable as the constant 1.
 
 taskMotor_F.S2_GAIN = micropython.const(2)
 Defines the State 2 Gain variable as the constant 2.
 
 taskMotor_F.S3_BALANCE = micropython.const(3)
 Defines the State 3 Balance variable as the constant 3.
 
 taskMotor_F.S4_HAPTIC = micropython.const(4)
 Defines the state 4 Haptic Feedback variable as the constant 4.
 

Detailed Description

Runs tasks sent by the taskUser file and performs ball balancing.

Acts as a background function file controlling the platform motors for the primary user interface so that the user interface does not have to motor actuation and closed loop control by itself. When closed loop control is activated by the taskUser, it will actively perform closed loop control to balance the ball and board. When there is no contact with the touch panel on the platform, it will only run the inner loop control and solely balance the platform, but when there is contact, the outer loop and inner loop will run sequentially, attempting to balance the ball in response to the touch panel position data.


The State Transition Diagram for taskMotor_F can be seen here.


Source Code: https://bitbucket.org/lmurray03/me305_lucas_murray/src/master/Term%20Project/taskMotor_F.py

Author
Lucas Murray
Max Cassady
Date
March 17, 2022

Function Documentation

◆ taskMotorFcn()

def taskMotor_F.taskMotorFcn (   taskName,
  period,
  wFlag,
  kFlag,
  hFlag,
  cFlag,
  duty,
  Eang,
  Vang,
  Poxy,
  Voxy,
  Cart,
  Cast,
  controlParameters 
)

Runs the relevant motor tasks as determined by taskUser and runs closed loop control.

Interfaces with the taskUser file through the use of the shared flag parameters and shared tuples, being able to change the gain coefficients of either closed loop controller as well as toggling and updating each closed loop controller actively depending on whether there is contact with the board.

Parameters
taskNameThe name of the task a string
periodThe period of the task in microseconds as an integer
wFlagBoolean variable shared between taskUser and taskMotor for the closed loop control toggle command
kFlagTuple variable shared between taskUser and taskMotor for the change gains command
hFlagBoolean variable shared between taskPanel and taskMotor for the haptic feedback command
cFlagBoolean variable shared between taskUser and taskIMU for the IMU calibration command
EangTuple shared between taskIMU, taskUser, taskData, and taskMotor that stores euler angle values
VangTuple shared between taskIMU, taskUser, taskData, and taskMotor that stores angular velocity values
PoxyTuple shared between taskMotor and taskPanel that stores the touch panel xy position values
VoxyTuple shared between taskMotor and taskPanel that stores the touch panel xy velocity values
CartTuple shared between taskData and taskPanel that contains the touch panel position and velocity data values
CastTuple shared between taskUser and taskEncoder that would have allowed for the automated calibration of the IMU
controlParametersTuple shared between taskUser and taskMotor that stores the input reference velocity and proportional gain