Mechatronics Portfolio
Logan Williamson's Mechatronics Portfolio and Documentation Repository
Functions | Variables
taskMotor.py File Reference

Implementation of motor control as an FSM. More...

Functions

def taskMotor.taskMotorFcn (taskName, period, faultFlag, duty_y, duty_x, K_pi, K_di, K_po, K_do, setpoint_x, setpoint_y, wFlag, posDATA, speedDATA, DATA)
 A generator to implement the motor task as an FSM. More...
 

Variables

 taskMotor.S0_INIT = micropython.const(0)
 Creates object S0_INIT set to constant 0. More...
 
 taskMotor.S1_RUN = micropython.const(1)
 Creates object S1_RUN set to constant 1. More...
 
 taskMotor.S2_CL = micropython.const(2)
 Creates object S2_CL set to constant 2. More...
 

Detailed Description

Implementation of motor control as an FSM.

This task instantiates and controls the behavior of a DRV8847 motor driver and its subordinate motor drivers. It does so by operating as a finite state machine in coordiantion with the taskUser.py user interface.

Author
Logan Williamson
Brianna Roberts
Date
02/10/2022

This task instantiates and controls the behavior of two motor.Motor objects. It does so by operating as a finite state machine. This task file runs cooperatively with the taskUser.py user interface, taskPanel.py touchpanel task file, and taskIMU.py inertial measurement unit task file.

Author
Logan Williamson
Brianna Roberts
Date
03/17/2022

Function Documentation

◆ taskMotorFcn()

def taskMotor.taskMotorFcn (   taskName,
  period,
  faultFlag,
  duty_y,
  duty_x,
  K_pi,
  K_di,
  K_po,
  K_do,
  setpoint_x,
  setpoint_y,
  wFlag,
  posDATA,
  speedDATA,
  DATA 
)

A generator to implement the motor task as an FSM.

The task runs as a generator function and requires a task name and interval to be specified.

Parameters
taskNameThe name of the task as a string.
periodThe task interval or period specified as an integer number of microseconds.
faultFlagFlag variable shared with taskPanel. If the touchpanel.touchpanel object controlled by the taskPanel state machine does not detect contact, faultFlag is set True and the closedLoop.ClosedLoop objects controlling the motors will return the platform to the 'home' (level) position.
duty_yShared data for control of the duty cycle for the motor_y object. This effectively controls the speed of motor_y because PMDC motors act as low pass filters.
duty_xShared data for control of the duty cycle for the motor_x object. This effectively controls the speed of motor_x because PMDC motors act as low pass filters.
K_piShared data used in a closedLoop.ClosedLoop controller object. This data is the closed-loop proportional gain factor for the inner loop of a cascading closed-loop controller.
K_diShared data used in a closedLoop.ClosedLoop controller object. This data is the closed-loop derivative gain factor for the inner loop of a cascading closed-loop controller.
K_poShared data used in a closedLoop.ClosedLoop controller object. This data is the closed-loop proportional gain factor for the outer loop of a cascading closed-loop controller.
K_doShared data used in a closedLoop.ClosedLoop controller object. This data is the closed-loop derivative gain factor for the outer loop of a cascading closed-loop controller.
setpoint_xShared data used in a closedLoop.ClosedLoop controller object. This data is used as the setpoint position desired by the user, which the closed loop controller uses to compute the difference between the setpoint and measured position readout from a touchpanel.touchpanel object.
setpoint_yShared data used in a closedLoop.ClosedLoop controller object. This data is used as the setpoint position desired by the user, which the closed loop controller uses to compute the difference between the setpoint and measured position readout from a touchpanel.touchpanel object.
wFlagShared flag variable with taskUser. Allows the user to toggle the operating state of taskMotor between manual to closed-loop operation.
posDATAShared data used in a closedLoop.ClosedLoop controller object. This data represents the angular position readout from a BNO055.BNO055 object in degrees.
speedDATAShared data used in a closedLoop.ClosedLoop controller object. This data is used as the measured angular velocity of a BNO055.BNO055 object which the closed loop controller uses to damp the motion generated by the controller.
DATAShared data for control of the duty cycle by means of closed-loop controller. This data contains the measured x- and y-position readouts from a touchpanel.touchpanel object.

Variable Documentation

◆ S0_INIT

taskMotor.S0_INIT = micropython.const(0)

Creates object S0_INIT set to constant 0.

S0_INIT is used to initialize the FSM. Simply transitions from S0 to S1.

◆ S1_RUN

taskMotor.S1_RUN = micropython.const(1)

Creates object S1_RUN set to constant 1.

S1_INIT is the running state of the FSM. In this state, the user will be able to set the duty cycle for the motor object(s). The motor(s) will run at the set duty cycle until a new duty cycle is selected.

◆ S2_CL

taskMotor.S2_CL = micropython.const(2)

Creates object S2_CL set to constant 2.

S2_CL is the closed loop control state for the motor(s). In this state, the user will be unable to control the duty cycle (and associated speed) of the motor directly. Instead, this state will use closedLoop.ClosedLoop object(s) to control the motors.