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... | |
Motor task that creates variables for motor driver functions and parameters.
Implements a finite state machine for the motor driver
| 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.
| period | The period, in microseconds, between runs of the task |
| motor_obj | The motor object that calls motors 1 or 2 |
| motor_drv | The motor driver object that calls DRV8847 |
| fault_user_flag | A boolean flag used to alert user of fault for a corresponding motor |
| enable_flag | A boolean flag used to enable a corresponding motor |
| step_flag | A boolean flag used to start step response |
| gain | Variable that defines gain value |
| L | Variable used to define actuation level |
| inp_vel | Variable that defines input velocity |
| meas_vel | Variable that defines measured velocity |
| 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
| new_state | The state to transition to |
| 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
| 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
| 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
| Lab4_task_motor.Task_Motor.gain |
Variable that defines gain value.
Also known as Kp, or proportional gain
| Lab4_task_motor.Task_Motor.inp_vel |
Variable that defines input velocity.
This is the reference velocity inputted by the user
| 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
| 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
| Lab4_task_motor.Task_Motor.motor_drv |
The motor driver object that calls DRV8847.
This motor driver was defined in the main.py file
| 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
| 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
| Lab4_task_motor.Task_Motor.period |
The frequency of the task.
Defines variable that specifies timer frequency
| Lab4_task_motor.Task_Motor.runs |
Sets the number of runs to 0.
Defines a variable to keep track of runs
| 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
| 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