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

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

Functions

def Lab0x05_taskMotor.taskMotorFcn (taskName, period, faultFlag, duty_y, duty_x, K_p, K_d, setpoint_x, setpoint_y, wFlag, posDATA, speedDATA)
 A generator to implement the motor task as an FSM. More...
 

Variables

 Lab0x05_taskMotor.S0_INIT = micropython.const(0)
 Creates object S0_INIT set to constant 0. More...
 
 Lab0x05_taskMotor.S1_RUN = micropython.const(1)
 Creates object S1_RUN set to constant 1. More...
 
 Lab0x05_taskMotor.S2_CL = micropython.const(2)
 Creates object S3_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

Function Documentation

◆ taskMotorFcn()

def Lab0x05_taskMotor.taskMotorFcn (   taskName,
  period,
  faultFlag,
  duty_y,
  duty_x,
  K_p,
  K_d,
  setpoint_x,
  setpoint_y,
  wFlag,
  posDATA,
  speedDATA 
)

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.
faultFlagShared flag variable created so it can be passed to taskUser; this prompts the user to clear the fault before operation of the motors can be continued.
duty1Shared data for control of the duty cycle for the motor 1 object. This effectively controls the speed of motor 1 because PMDC motors act as low pass filters.
duty2Shared data for control of the duty cycle for the motor 2 object. This effectively controls the speed of motor 2 because PMDC motors act as low pass filters.
K_pShared data for control of the duty cycle by means of closed-loop controller. This data is the closed-loop gain factor.
setpointShared data for control of the duty cycle by means of closed-loop controller. This data is used as the setpoint velocity desired by the user, which the closed loop controller uses to compute the difference between the setpoint and measured velocity of the motor.
speedDATAShared data for control of the duty cycle by means of closed-loop controler. This data is used as the measured velocity which the closed loop controller uses to compute the difference between the setpoint and measured velocity of the motor.

Variable Documentation

◆ S0_INIT

Lab0x05_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

Lab0x05_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 objects instantiated by the DRV8847 class. The motors will run at the set duty cycle until a new duty cycle is selected, or a fault indication is detected.

◆ S2_CL

Lab0x05_taskMotor.S2_CL = micropython.const(2)

Creates object S3_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. Instead, this state will use user inputs for the closed-loop control gain value and a reference/setpoint value to indirectly control the motor speed.