User interface task for data collection and interaction with task encoder, task motor, and task motor driver. 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, gain_1, gain_2, inp_vel_1, inp_vel_2, step_flag, meas_vel_1, meas_vel_2, L_1, L_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... | |
| gain_1 | |
| Variable that defines gain value for motor 1. More... | |
| gain_2 | |
| Variable that defines gain value for motor 2. More... | |
| inp_vel_1 | |
| Variable that defines input velocity for motor 1. More... | |
| inp_vel_2 | |
| Variable that defines input velocity for motor 2. More... | |
| meas_vel_1 | |
| Variable that defines measured velocity for motor 1. More... | |
| meas_vel_2 | |
| Variable that defines measured velocity for motor 2. More... | |
| L_1 | |
| Variable used to define actuation level for motor 1. More... | |
| L_2 | |
| Variable used to define actuation level 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 | |
| An array that is created to store time elapsed. More... | |
| position_array | |
| An array that is created to store measured positions of the motors. More... | |
| velocity_array | |
| An array that is created to store measured velocites of the motors. More... | |
| L_array | |
| An array that is created to store actuation level of the motors. More... | |
| meas_vel_array | |
| An array that is created to store measured velocites of the motors. More... | |
| step_flag | |
| A boolean flag used to start step response. More... | |
| collect_time | |
| Assigns an arbitrary reference point that begins after user inputs are defined. More... | |
| time_diff | |
| Creates a variable that calculates difference between time reference points. More... | |
| list_3 | |
| A variable that creates a list of the time, angular velocity, and actuation level arrays. More... | |
User interface task for data collection and interaction with task encoder, task motor, and task motor driver.
Implements a finite state machine that runs a data collection interface.
| def Lab4_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, | |||
| gain_1, | |||
| gain_2, | |||
| inp_vel_1, | |||
| inp_vel_2, | |||
| step_flag, | |||
| meas_vel_1, | |||
| meas_vel_2, | |||
| L_1, | |||
| L_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 |
| gain_1 | Variable that defines gain value for motor 1 |
| gain_2 | Variable that defines gain value for motor 2 |
| inp_vel_1 | Variable that defines input velocity for motor 1 |
| inp_vel_2 | Variable that defines input velocity for motor 2 |
| step_flag | A boolean flag used to start step response |
| meas_vel_1 | Variable that defines measured velocity for motor 1 |
| meas_vel_2 | Variable that defines measured velocity for motor 2 |
| L_1 | Variable used to define actuation level for motor 1 |
| L_2 | Variable used to define actuation level for motor 2 |
| def Lab4_task_userinterface.Task_User.run | ( | self | ) |
Runs one iteration of the FSM.
Implements a finite state machine
| def Lab4_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 |
| Lab4_task_userinterface.Task_User.collect_time |
Assigns an arbitrary reference point that begins after user inputs are defined.
Used to implement the timed data collection period
| Lab4_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
| Lab4_task_userinterface.Task_User.enc_delta_1 |
The change in encoder 1 position.
The difference between two recorded positions of the encoder
| Lab4_task_userinterface.Task_User.enc_delta_2 |
The change in encoder 2 position.
The difference between two recorded positions of the encoder
| Lab4_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
| Lab4_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
| Lab4_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
| Lab4_task_userinterface.Task_User.gain_1 |
Variable that defines gain value for motor 1.
Also known as Kp, or proportional gain
| Lab4_task_userinterface.Task_User.gain_2 |
Variable that defines gain value for motor 2.
Also known as Kp, or proportional gain
| Lab4_task_userinterface.Task_User.i |
A variable used for indexing.
This value helps index data points for time, position, and delta
| Lab4_task_userinterface.Task_User.inp_vel_1 |
Variable that defines input velocity for motor 1.
This is the reference velocity inputted by the user
| Lab4_task_userinterface.Task_User.inp_vel_2 |
Variable that defines input velocity for motor 2.
This is the reference velocity inputted by the user
| Lab4_task_userinterface.Task_User.L_1 |
Variable used to define actuation level for motor 1.
This value is calculated using gain, measured angular velocity, and reference angular velocity
| Lab4_task_userinterface.Task_User.L_2 |
Variable used to define actuation level for motor 2.
This value is calculated using gain, measured angular velocity, and reference angular velocity
| Lab4_task_userinterface.Task_User.L_array |
An array that is created to store actuation level of the motors.
This variable creates an empty array of 1000 data points, which will be populated later with actuation level data
| Lab4_task_userinterface.Task_User.list_3 |
A variable that creates a list of the time, angular velocity, and actuation level arrays.
This list combines three individual arrays
| Lab4_task_userinterface.Task_User.meas_vel_1 |
Variable that defines measured velocity for motor 1.
Takes the measured delta values from the encoder and divides by the period to obtain measured velocity
| Lab4_task_userinterface.Task_User.meas_vel_2 |
Variable that defines measured velocity for motor 2.
Takes the measured delta values from the encoder and divides by the period to obtain measured velocity
| Lab4_task_userinterface.Task_User.meas_vel_array |
An array that is created to store measured velocites of the motors.
This variable creates an empty array of 1000 data points, which will be populated later with velocity data
| Lab4_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
| Lab4_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
| Lab4_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 1.
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
This float value corresponds to motor 1
| Lab4_task_userinterface.Task_User.period |
The frequency of the task.
Defines variable that specifies timer frequency
| Lab4_task_userinterface.Task_User.position_array |
An array that is created to store measured positions of the motors.
This variable creates an empty array of 1000 data points, which will be populated later with position data
| Lab4_task_userinterface.Task_User.runs |
Sets the number of runs to 0.
Defines a variable to keep track of runs
| Lab4_task_userinterface.Task_User.ser |
A serial port to use for user I/O.
Creates a new USB_VCP object
| Lab4_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
| Lab4_task_userinterface.Task_User.step_flag |
A boolean flag used to start step response.
Works with the motor task and user interface to communicate step function performance
| Lab4_task_userinterface.Task_User.time_array |
An array that is created to store time elapsed.
This variable creates an empty array of 1000 data points, which will be populated later with time data
| Lab4_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 10 seconds
| Lab4_task_userinterface.Task_User.velocity_array |
An array that is created to store measured velocites of the motors.
This variable creates an empty array of 1000 data points, which will be populated later with velocity data
| Lab4_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
| Lab4_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