Luisa Chiu Portfolio
Lab3_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, dutycycle)
 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...
 
 dutycycle
 A variable that defines duty cycle for 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...
 
 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...
 

Detailed Description

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

Implements a finite state machine for lab 3

Constructor & Destructor Documentation

◆ __init__()

def Lab3_task_motor.Task_Motor.__init__ (   self,
  period,
  motor_obj,
  motor_drv,
  fault_user_flag,
  enable_flag,
  dutycycle 
)

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
dutycycleA variable that defines duty cycle for a corresponding motor

Member Function Documentation

◆ transition_to()

def Lab3_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

◆ dutycycle

Lab3_task_motor.Task_Motor.dutycycle

A variable that defines duty cycle for a corresponding motor.

Duty cycle values control motor speed

◆ enable_flag

Lab3_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

Lab3_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

◆ motor_drv

Lab3_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

Lab3_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

Lab3_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

Lab3_task_motor.Task_Motor.period

The frequency of the task.

Defines variable that specifies timer frequency

◆ runs

Lab3_task_motor.Task_Motor.runs

Sets the number of runs to 0.

Defines a variable to keep track of runs

◆ state

Lab3_task_motor.Task_Motor.state

Initializes starting state to be state 2.

Motors begin in the stop state


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