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... | |
Motor task that creates variables for motor driver functions and parameters.
Implements a finite state machine for lab 3
| 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.
| 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 |
| dutycycle | A variable that defines duty cycle for a corresponding motor |
| 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
| new_state | The state to transition to |
| Lab3_task_motor.Task_Motor.dutycycle |
A variable that defines duty cycle for a corresponding motor.
Duty cycle values control motor speed
| 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
| 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
| Lab3_task_motor.Task_Motor.motor_drv |
The motor driver object that calls DRV8847.
This motor driver was defined in the main.py file
| 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
| 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
| Lab3_task_motor.Task_Motor.period |
The frequency of the task.
Defines variable that specifies timer frequency
| Lab3_task_motor.Task_Motor.runs |
Sets the number of runs to 0.
Defines a variable to keep track of runs
| Lab3_task_motor.Task_Motor.state |
Initializes starting state to be state 2.
Motors begin in the stop state