ME 305
Functions | Variables
task_user.py File Reference

Handles the user UI of our encoder system. More...

Functions

def task_user.taskUser (taskname, period, zFlag, pFlag, vFlag, position, T, Velo, mode, opmode, cFlag, calwrite, cal_byte, calread, bFlag, duty_1, duty_2, Tscreen, calFlag, readTouch, fFlag, ADCData)
 A generator to implement the UI task as an Finite State Machine. More...
 

Variables

 task_user.S4_VELOCITY = micropython.const(4)
 State 4 - Find Velocity. More...
 
 task_user.S8_Kp = micropython.const(8)
 State 8 - Set proportional gain.
 
 task_user.S9_Kd = micropython.const(9)
 State 9 - Define set point.
 
 task_user.S11_CAL = micropython.const(11)
 State 11 - For IMU calibration.
 
 task_user.S12_CALTouch = micropython.const(12)
 State 12 - Determines whether touch calibration file loaded.
 
 task_user.S13_TCAL = micropython.const(13)
 State 13 - Checks if touch calibration file present and correct.
 
 task_user.S14_BallBal = micropython.const(14)
 State 14 - Ball balancing state.
 
 task_user.S15_I = micropython.const(15)
 State 15 - Set integral gain.
 
 task_user.S16_HELP = micropython.const(16)
 State 16 - Displays possible program commands.
 
 task_user.S17_DATA = micropython.const(17)
 State 17 - Data Collection. More...
 

Detailed Description

Handles the user UI of our encoder system.

This file interacts directly with user keyboard inputs to then send the request to the task_encoder.py file. It uses six states that correspond to different key in puts to send the program into its appropriate settings based on the user input.

See Term Project for state transition diagrams, task diagrams, plots and video demonstrating the balancing of the ball on the platform along with how the UI was implemented.

Author
Ryan Dean
Zachary Hendrix
Date
2/1/2022

Function Documentation

◆ taskUser()

def task_user.taskUser (   taskname,
  period,
  zFlag,
  pFlag,
  vFlag,
  position,
  T,
  Velo,
  mode,
  opmode,
  cFlag,
  calwrite,
  cal_byte,
  calread,
  bFlag,
  duty_1,
  duty_2,
  Tscreen,
  calFlag,
  readTouch,
  fFlag,
  ADCData 
)

A generator to implement the UI task as an Finite State Machine.

The task runs as a generator function and requires a task name and interval to be specified. This task file receives flag values altered by the user. These flags are then shared with task_encoder.py where that task file can execute actions defined in encoder.py. Once the desired task is completed, the state is reset back to idle state (State 1).

Parameters
taskNameThe name of the task as a string.
periodSpecifies how long the task has to perform its function in microseconds. Specified as an integer.
zFlagHolds True or False value to know when to change IMU mode
pFlagHolds True or False value to know when position command was called by the user to know the current position of the encoder.
vFlagHolds True or False value to know when to collect velocity data
positionStores current position of IMU to be read from task_IMU.py
TStores time readig of task_touch.py for data collection
VeloStores angular velocity of platform
modeContains string to know whether in open or closed loop
opmodeStores user selected operating mode of IMU
cFlagHolds True or False to begin platform calibration
calwriteHolds True or False to begin writing calibration data to IMU
cal_byteStores byte data of the calibration status of IMU
calreadHolds True or False to begin reading IMU calibration data to later write to a text file
bFlagHolds True or False to begin recording platform position and velocity data
Returns
yield None

Variable Documentation

◆ S17_DATA

task_user.S17_DATA = micropython.const(17)

State 17 - Data Collection.

State that collects 10 seconds of data and outputs it to the user

◆ S4_VELOCITY

task_user.S4_VELOCITY = micropython.const(4)

State 4 - Find Velocity.

Calculates the velocity of motor 1