Luisa Chiu Portfolio
Lab3_task_userinterface.Task_User Class Reference

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

Detailed Description

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.

Constructor & Destructor Documentation

◆ __init__()

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.

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
dutycycle_1A variable that defines duty cycle for motor 1
dutycycle_2A variable that defines duty cycle for motor 2

Member Function Documentation

◆ run()

def Lab3_task_userinterface.Task_User.run (   self)

Runs one iteration of the FSM.

Implements a finite state machine

◆ transition_to()

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

Parameters
new_stateThe state to transition to

Member Data Documentation

◆ collect_time

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

◆ dutycycle_1

Lab3_task_userinterface.Task_User.dutycycle_1

A variable that defines duty cycle for motor 1.

Duty cycle values control motor speed

◆ dutycycle_2

Lab3_task_userinterface.Task_User.dutycycle_2

A variable that defines duty cycle for motor 2.

Duty cycle values control motor speed

◆ enable_flag

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

◆ enc_delta_1

Lab3_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

Lab3_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

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

◆ enc_pos_2

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

◆ fault_user_flag

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

◆ i

Lab3_task_userinterface.Task_User.i

A variable used for indexing.

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

◆ list_1

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

◆ list_2

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

◆ measured_vel_1

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

◆ measured_vel_2

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

◆ next_time

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

◆ num_str_1

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

◆ num_str_2

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

◆ period

Lab3_task_userinterface.Task_User.period

The frequency of the task.

Defines variable that specifies timer frequency

◆ position_array_1

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

◆ position_array_2

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

◆ runs

Lab3_task_userinterface.Task_User.runs

Sets the number of runs to 0.

Defines a variable to keep track of runs

◆ ser

Lab3_task_userinterface.Task_User.ser

A serial port to use for user I/O.

Creates a new USB_VCP object

◆ state

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

◆ time_array_1

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

◆ time_array_2

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

◆ time_diff

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

◆ velocity_array_1

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

◆ velocity_array_2

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

◆ z_flag_1

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

◆ z_flag_2

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


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