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, dFlag, gFlag, position, delta, P, T)
 A generator to implement the UI task as an Finite State Machine. More...
 

Variables

 task_user.S0_INIT = micropython.const(0)
 State 0 - Initialize. More...
 
 task_user.S1_CMD = micropython.const(1)
 State 1 - Command. More...
 
 task_user.S2_ZERO = micropython.const(2)
 State 2 - Zero Encoder. More...
 
 task_user.S3_POS = micropython.const(3)
 State 3 - Position. More...
 
 task_user.S4_DEL = micropython.const(4)
 State 4 - Delta. More...
 
 task_user.S5_DATA = micropython.const(5)
 State 5 - Data Collection. More...
 
 task_user.S6_HELP = micropython.const(6)
 State 6 - Help. 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. These states are highlighted below:

S0-Initialization S1-Command S2-Zero S3-Position S4-Delta S5-Data S6-Help

The below image shows the state transition diagram employed for this task file:

Author
Ryan Dean
Zachary Hendrix
Date
2/1/2022

Function Documentation

◆ taskUser()

def task_user.taskUser (   taskname,
  period,
  zFlag,
  pFlag,
  dFlag,
  gFlag,
  position,
  delta,
  P,
  T 
)

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 zeroing command was called by the user to zero the current position of the encoder.
pFlagHolds True or False value to know when position command was called by the user to know the current position of the encoder.
dFlagHolds True or False value to know when delta command was called by the user to know the current delta (speed) of the encoder.
gFlagHolds True or False value to know when data collection command was called by the user to collect current time and position data.
positionStores current position of encoder to be read in task_user.py
deltaStores the delta (speed) of the encoder to be read in to task_user.py
PStores current position of encoder for data collection
TStores current time of encoder for data collection
Returns
yield None

Variable Documentation

◆ S0_INIT

task_user.S0_INIT = micropython.const(0)

State 0 - Initialize.

State that corresponds to initializing encoder 1 and printing out the initial help menu.

◆ S1_CMD

task_user.S1_CMD = micropython.const(1)

State 1 - Command.

State that waits for a user input and transfers the user to the correct state based on that input.

◆ S2_ZERO

task_user.S2_ZERO = micropython.const(2)

State 2 - Zero Encoder.

State that zeros out the encoder

◆ S3_POS

task_user.S3_POS = micropython.const(3)

State 3 - Position.

State that returns position to the user

◆ S4_DEL

task_user.S4_DEL = micropython.const(4)

State 4 - Delta.

State that returns the delta(speed) of the encoder to the user

◆ S5_DATA

task_user.S5_DATA = micropython.const(5)

State 5 - Data Collection.

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

◆ S6_HELP

task_user.S6_HELP = micropython.const(6)

State 6 - Help.

State that returns a help window to the user