Luisa Chiu Portfolio
Lab4_task_motor.Task_Motor Class Reference

Motor task that creates variables for motor driver functions and parameters. More...

Public Member Functions

def __init__ (self, period, motor_obj, motor_drv, fault_user_flag, enable_flag, step_flag, gain, L, inp_vel, meas_vel)
 Constructs a motor task. More...
 
def run (self)
 Runs one iteration of the FSM.
 
def transition_to (self, new_state)
 Transitions the FSM to a new state. More...
 

Public Attributes

 fault_user_flag
 A boolean flag used to alert user of fault for a corresponding motor. More...
 
 enable_flag
 A boolean flag used to enable a corresponding motor. More...
 
 motor_obj
 The motor object that calls motors 1 or 2. More...
 
 motor_drv
 The motor driver object that calls DRV8847. More...
 
 gain
 Variable that defines gain value. More...
 
 L
 Variable used to define actuation level. More...
 
 inp_vel
 Variable that defines input velocity. More...
 
 meas_vel
 Variable that defines measured velocity. More...
 
 step_flag
 A boolean flag used to start step response. More...
 
 period
 The frequency of the task. More...
 
 state
 Initializes starting state to be state 2. More...
 
 runs
 Sets the number of runs to 0. More...
 
 next_time
 The utime.ticks_us() value associated with the next run of the FSM. More...
 
 controller
 The controller object that refers to closedloop.py. More...
 

Detailed Description

Motor task that creates variables for motor driver functions and parameters.

Implements a finite state machine for the motor driver

Constructor & Destructor Documentation

◆ __init__()

def Lab4_task_motor.Task_Motor.__init__ (   self,
  period,
  motor_obj,
  motor_drv,
  fault_user_flag,
  enable_flag,
  step_flag,
  gain,
  L,
  inp_vel,
  meas_vel 
)

Constructs a motor task.

The motor task is implemented as a finite state machine.

Parameters
periodThe period, in microseconds, between runs of the task
motor_objThe motor object that calls motors 1 or 2
motor_drvThe motor driver object that calls DRV8847
fault_user_flagA boolean flag used to alert user of fault for a corresponding motor
enable_flagA boolean flag used to enable a corresponding motor
step_flagA boolean flag used to start step response
gainVariable that defines gain value
LVariable used to define actuation level
inp_velVariable that defines input velocity
meas_velVariable that defines measured velocity

Member Function Documentation

◆ transition_to()

def Lab4_task_motor.Task_Motor.transition_to (   self,
  new_state 
)

Transitions the FSM to a new state.

A function that transitions the FSM to a new state

Parameters
new_stateThe state to transition to

Member Data Documentation

◆ controller

Lab4_task_motor.Task_Motor.controller

The controller object that refers to closedloop.py.

Creates the controller object used to perform closed loop speed control of the motors

◆ enable_flag

Lab4_task_motor.Task_Motor.enable_flag

A boolean flag used to enable a corresponding motor.

Used to communicate enable function between driver, motor task, and user task

◆ fault_user_flag

Lab4_task_motor.Task_Motor.fault_user_flag

A boolean flag used to alert user of fault for a corresponding motor.

Used to indicate fault in user interface

◆ gain

Lab4_task_motor.Task_Motor.gain

Variable that defines gain value.

Also known as Kp, or proportional gain

◆ inp_vel

Lab4_task_motor.Task_Motor.inp_vel

Variable that defines input velocity.

This is the reference velocity inputted by the user

◆ L

Lab4_task_motor.Task_Motor.L

Variable used to define actuation level.

This value is calculated using gain, measured angular velocity, and reference angular velocity

◆ meas_vel

Lab4_task_motor.Task_Motor.meas_vel

Variable that defines measured velocity.

Takes the measured delta values from the encoder and divides by the period to obtain measured velocity

◆ motor_drv

Lab4_task_motor.Task_Motor.motor_drv

The motor driver object that calls DRV8847.

This motor driver was defined in the main.py file

◆ motor_obj

Lab4_task_motor.Task_Motor.motor_obj

The motor object that calls motors 1 or 2.

Motors 1 or 2 were defined in the main.py file

◆ next_time

Lab4_task_motor.Task_Motor.next_time

The utime.ticks_us() value associated with the next run of the FSM.

Defines a variable that adds the period to the ongoing timer

◆ period

Lab4_task_motor.Task_Motor.period

The frequency of the task.

Defines variable that specifies timer frequency

◆ runs

Lab4_task_motor.Task_Motor.runs

Sets the number of runs to 0.

Defines a variable to keep track of runs

◆ state

Lab4_task_motor.Task_Motor.state

Initializes starting state to be state 2.

Starts timer.

Motors begin in the stop state

An increasing microsecond counter with an arbitrary reference point

◆ step_flag

Lab4_task_motor.Task_Motor.step_flag

A boolean flag used to start step response.

Works with the motor task and user interface to communicate step function performance


The documentation for this class was generated from the following file: