User interface task for data collection and interaction with encoder object. More...
Public Member Functions | |
| def | __init__ (self, period, enc_pos_1, enc_pos_2, z_flag_1, z_flag_2, fault_user_flag, enable_flag, enc_delta_1, enc_delta_2, dutycycle_1, dutycycle_2) |
| Constructs the user interface task. More... | |
| def | run (self) |
| Runs one iteration of the FSM. More... | |
| def | transition_to (self, new_state) |
| Transitions the FSM to a new state. More... | |
Public Attributes | |
| period | |
| The frequency of the task. More... | |
| enc_pos_1 | |
| The encoder 1 position that counts total movement. More... | |
| enc_pos_2 | |
| The encoder 2 position that counts total movement. More... | |
| enc_delta_1 | |
| The change in encoder 1 position. More... | |
| enc_delta_2 | |
| The change in encoder 2 position. More... | |
| z_flag_1 | |
| A boolean flag used to reset encoder 1 position to 0. More... | |
| z_flag_2 | |
| A boolean flag used to reset encoder 2 position to 0. More... | |
| state | |
| Sets initial state to State 0. 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... | |
| ser | |
| A serial port to use for user I/O. More... | |
| fault_user_flag | |
| A boolean flag used to alert user of fault for motors. More... | |
| enable_flag | |
| A boolean flag used to enable motor 1. More... | |
| dutycycle_1 | |
| A variable that defines duty cycle for motor 1. More... | |
| dutycycle_2 | |
| A variable that defines duty cycle for motor 2. More... | |
| num_str_1 | |
| A variable used to initialize the user input. More... | |
| num_str_2 | |
| A variable used to initialize the user input. More... | |
| i | |
| A variable used for indexing. More... | |
| time_array_1 | |
| A variable that is created in preparation for the time array for motor 1. More... | |
| time_array_2 | |
| A variable that is created in preparation for the time array for motor 2. More... | |
| position_array_1 | |
| A variable that is created in preparation for the position array for motor 1. More... | |
| position_array_2 | |
| A variable that is created in preparation for the position array for motor 2. More... | |
| velocity_array_1 | |
| A variable that is created in preparation for the velocity array for motor 1. More... | |
| velocity_array_2 | |
| A variable that is created in preparation for the velocity array for motor 2. More... | |
| collect_time | |
| Assigns an arbitrary reference point that begins when 'g' is pressed. More... | |
| measured_vel_1 | |
| Creates a variable that calculates velocity for motor 1. More... | |
| time_diff | |
| Creates a variable that calculates difference between time reference points. More... | |
| list_1 | |
| A variable that creates a list of the time, position, and velocity arrays for motor 1. More... | |
| measured_vel_2 | |
| Creates a variable that calculates velocity for motor 2. More... | |
| list_2 | |
| A variable that creates a list of the time, position, and velocity arrays for motor 2. More... | |
User interface task for data collection and interaction with encoder object.
Implements a finite state machine that runs a data collection interface to interact with the encoder object.
| def Lab3_task_userinterface.Task_User.__init__ | ( | self, | |
| period, | |||
| enc_pos_1, | |||
| enc_pos_2, | |||
| z_flag_1, | |||
| z_flag_2, | |||
| fault_user_flag, | |||
| enable_flag, | |||
| enc_delta_1, | |||
| enc_delta_2, | |||
| dutycycle_1, | |||
| dutycycle_2 | |||
| ) |
Constructs the user interface task.
The user task is implemented as a finite state machine that takes in character input from the user and obtains information from the encoder task to present to user.
| period | The period, in microseconds, between runs of the task |
| enc_pos_1 | The encoder position that counts total movement for encoder 1 |
| enc_pos_2 | The encoder position that counts total movement for encoder 2 |
| z_flag_1 | A boolean flag used to reset encoder 1 position to 0 |
| z_flag_2 | A boolean flag used to reset encoder 2 position to 0 |
| 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 |
| enc_delta_1 | The change in time increments in timer count for encoder 1 |
| enc_delta_2 | The change in time increments in timer count for encoder 2 |
| dutycycle_1 | A variable that defines duty cycle for motor 1 |
| dutycycle_2 | A variable that defines duty cycle for motor 2 |
| def Lab3_task_userinterface.Task_User.run | ( | self | ) |
Runs one iteration of the FSM.
Implements a finite state machine
| def Lab3_task_userinterface.Task_User.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_userinterface.Task_User.collect_time |
Assigns an arbitrary reference point that begins when 'g' is pressed.
Used to implement the timed data collection period
| Lab3_task_userinterface.Task_User.dutycycle_1 |
A variable that defines duty cycle for motor 1.
Duty cycle values control motor speed
| Lab3_task_userinterface.Task_User.dutycycle_2 |
A variable that defines duty cycle for motor 2.
Duty cycle values control motor speed
| Lab3_task_userinterface.Task_User.enable_flag |
A boolean flag used to enable motor 1.
Used to communicate enable function between driver, motor task, and user task
| Lab3_task_userinterface.Task_User.enc_delta_1 |
The change in encoder 1 position.
The difference between two recorded positions of the encoder
| Lab3_task_userinterface.Task_User.enc_delta_2 |
The change in encoder 2 position.
The difference between two recorded positions of the encoder
| Lab3_task_userinterface.Task_User.enc_pos_1 |
The encoder 1 position that counts total movement.
The total position moved is characterized by the total number of timer counts
| Lab3_task_userinterface.Task_User.enc_pos_2 |
The encoder 2 position that counts total movement.
The total position moved is characterized by the total number of timer counts
| Lab3_task_userinterface.Task_User.fault_user_flag |
A boolean flag used to alert user of fault for motors.
Used to indicate fault in user interface
| Lab3_task_userinterface.Task_User.i |
A variable used for indexing.
This value helps index data points for time, position, and delta
| Lab3_task_userinterface.Task_User.list_1 |
A variable that creates a list of the time, position, and velocity arrays for motor 1.
This list combines three individual arrays
| Lab3_task_userinterface.Task_User.list_2 |
A variable that creates a list of the time, position, and velocity arrays for motor 2.
This list combines three individual arrays
| Lab3_task_userinterface.Task_User.measured_vel_1 |
Creates a variable that calculates velocity for motor 1.
Calculates velocity using delta values, period, and unit conversions
| Lab3_task_userinterface.Task_User.measured_vel_2 |
Creates a variable that calculates velocity for motor 2.
Calculates velocity using delta values, period, and unit conversions
| Lab3_task_userinterface.Task_User.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_userinterface.Task_User.num_str_1 |
A variable used to initialize the user input.
Variable that turns string input into float for duty cycle 1.
This string is what the user sees for motor 1 input
This float value corresponds to motor 1
| Lab3_task_userinterface.Task_User.num_str_2 |
A variable used to initialize the user input.
Variable that turns string input into float for duty cycle 2.
This string is what the user sees for motor 2 input
This float value corresponds to motor 2
| Lab3_task_userinterface.Task_User.period |
The frequency of the task.
Defines variable that specifies timer frequency
| Lab3_task_userinterface.Task_User.position_array_1 |
A variable that is created in preparation for the position array for motor 1.
This variable creates an empty array of 1000 data points, which will be populated later with position data
| Lab3_task_userinterface.Task_User.position_array_2 |
A variable that is created in preparation for the position array for motor 2.
This variable creates an empty array of 1000 data points, which will be populated later with position data
| Lab3_task_userinterface.Task_User.runs |
Sets the number of runs to 0.
Defines a variable to keep track of runs
| Lab3_task_userinterface.Task_User.ser |
A serial port to use for user I/O.
Creates a new USB_VCP object
| Lab3_task_userinterface.Task_User.state |
Sets initial state to State 0.
Variable that defines encoder 2 position shared item.
Variable that defines encoder 1 position shared item.
Starts timer.
FSM starts at State 0, where user input is prompted for further action
An increasing microsecond counter with an arbitrary reference point
Allows encoder 1 position data to be accessed
Allows encoder 2 position data to be accessed
| Lab3_task_userinterface.Task_User.time_array_1 |
A variable that is created in preparation for the time array for motor 1.
This variable creates an empty array of 1000 data points, which will be populated later with time data
| Lab3_task_userinterface.Task_User.time_array_2 |
A variable that is created in preparation for the time array for motor 2.
This variable creates an empty array of 1000 data points, which will be populated later with time data
| Lab3_task_userinterface.Task_User.time_diff |
Creates a variable that calculates difference between time reference points.
Used to collect data for a maximum time of 30 seconds
| Lab3_task_userinterface.Task_User.velocity_array_1 |
A variable that is created in preparation for the velocity array for motor 1.
This variable creates an empty array of 1000 data points, which will be populated later with velocity data
| Lab3_task_userinterface.Task_User.velocity_array_2 |
A variable that is created in preparation for the velocity array for motor 2.
This variable creates an empty array of 1000 data points, which will be populated later with velocity data
| Lab3_task_userinterface.Task_User.z_flag_1 |
A boolean flag used to reset encoder 1 position to 0.
When character "z" is pressed on the keyboard, z-flag will be 'True' and reset encoder 1 position
| Lab3_task_userinterface.Task_User.z_flag_2 |
A boolean flag used to reset encoder 2 position to 0.
When character "z" is pressed on the keyboard, z-flag will be 'True' and reset encoder 2 position