Luisa Chiu Portfolio
Lab4_task_userinterface.Task_User Class Reference

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ __init__()

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.

Parameters
periodThe period, in microseconds, between runs of the task
enc_pos_1The encoder position that counts total movement for encoder 1
enc_pos_2The encoder position that counts total movement for encoder 2
z_flag_1A boolean flag used to reset encoder 1 position to 0
z_flag_2A boolean flag used to reset encoder 2 position to 0
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
enc_delta_1The change in time increments in timer count for encoder 1
enc_delta_2The change in time increments in timer count for encoder 2
gain_1Variable that defines gain value for motor 1
gain_2Variable that defines gain value for motor 2
inp_vel_1Variable that defines input velocity for motor 1
inp_vel_2Variable that defines input velocity for motor 2
step_flagA boolean flag used to start step response
meas_vel_1Variable that defines measured velocity for motor 1
meas_vel_2Variable that defines measured velocity for motor 2
L_1Variable used to define actuation level for motor 1
L_2Variable used to define actuation level for motor 2

Member Function Documentation

◆ run()

def Lab4_task_userinterface.Task_User.run (   self)

Runs one iteration of the FSM.

Implements a finite state machine

◆ transition_to()

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

Parameters
new_stateThe state to transition to

Member Data Documentation

◆ collect_time

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

◆ enable_flag

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

◆ enc_delta_1

Lab4_task_userinterface.Task_User.enc_delta_1

The change in encoder 1 position.

The difference between two recorded positions of the encoder

◆ enc_delta_2

Lab4_task_userinterface.Task_User.enc_delta_2

The change in encoder 2 position.

The difference between two recorded positions of the encoder

◆ enc_pos_1

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

◆ enc_pos_2

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

◆ fault_user_flag

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

◆ gain_1

Lab4_task_userinterface.Task_User.gain_1

Variable that defines gain value for motor 1.

Also known as Kp, or proportional gain

◆ gain_2

Lab4_task_userinterface.Task_User.gain_2

Variable that defines gain value for motor 2.

Also known as Kp, or proportional gain

◆ i

Lab4_task_userinterface.Task_User.i

A variable used for indexing.

This value helps index data points for time, position, and delta

◆ inp_vel_1

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

◆ inp_vel_2

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

◆ L_1

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

◆ L_2

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

◆ L_array

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

◆ list_3

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

◆ meas_vel_1

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

◆ meas_vel_2

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

◆ meas_vel_array

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

◆ next_time

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

◆ num_str_1

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

◆ num_str_2

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

◆ period

Lab4_task_userinterface.Task_User.period

The frequency of the task.

Defines variable that specifies timer frequency

◆ position_array

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

◆ runs

Lab4_task_userinterface.Task_User.runs

Sets the number of runs to 0.

Defines a variable to keep track of runs

◆ ser

Lab4_task_userinterface.Task_User.ser

A serial port to use for user I/O.

Creates a new USB_VCP object

◆ state

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

◆ step_flag

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

◆ time_array

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

◆ time_diff

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

◆ velocity_array

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

◆ z_flag_1

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

◆ z_flag_2

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


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