Ball Balancer Project
Functions | Variables
taskUser.py File Reference

The task that will run the user interface. More...

Functions

def taskUser.printHelp ()
 This function outputs the GUI of encoder. More...
 
def taskUser.InputDutyFCN (char_In, DUTY_str, dFlag)
 This function reads numeric data. More...
 
def taskUser.InputNumberFCN (char_In, Num_str, eFlag)
 This function reads numeric data. More...
 
def taskUser.taskUserFcn (taskName, period, Data, Velocity, Duty1, Duty2, clFlag, Kp, Ki, Kd, Position, Contact)
 This function serves as the main user interface. More...
 

Variables

 taskUser.S0_INIT = micropython.const(0)
 
 taskUser.S1_CMD = micropython.const(1)
 
 taskUser.S2_ZERO = micropython.const(2)
 
 taskUser.S3_POSITION = micropython.const(3)
 
 taskUser.S4_DELTA = micropython.const(4)
 
 taskUser.S5_GET = micropython.const(5)
 
 taskUser.S6_STOP = micropython.const(6)
 
 taskUser.S7_DATA = micropython.const(7)
 
 taskUser.S8_VEL = micropython.const(8)
 
 taskUser.S9_DUTY1 = micropython.const(9)
 
 taskUser.S10_DUTY2 = micropython.const(10)
 
 taskUser.S11_CLRF = micropython.const(11)
 
 taskUser.S12_THELP = micropython.const(12)
 
 taskUser.S13_TEST = micropython.const(13)
 
 taskUser.S14_SETOMEGA = micropython.const(14)
 
 taskUser.S15_SETGAIN = micropython.const(15)
 
 taskUser.S16_TOGGLELOOP = micropython.const(16)
 
 taskUser.S17_STEP = micropython.const(17)
 
 taskUser.S18_DATA = micropython.const(18)
 
 taskUser.S19_Inner_Outer_Gains = micropython.const(19)
 

Detailed Description

The task that will run the user interface.

This task takes in keyboard commands from the user to perform certain tasks. This allows for the user to interact with the Encoder and motor tasks to determine instanenous data or to collect data for a period of time. This is done by defining various states that perform different tasks.

@author     Jake Lesher
@author     Daniel Xu
@date       02/16/2022

Function Documentation

◆ InputDutyFCN()

def taskUser.InputDutyFCN (   char_In,
  DUTY_str,
  dFlag 
)

This function reads numeric data.

Based off of the inputs of the user, this function determines if the input is valid. It ignores all non-numerical inputs, except for the negative sign (-), the enter key (\r,
), the period key (.), and the backspace key (, '\x08', \x7F). It also limits the duty cycle to be between -100% and 100%.

Parameters
char_Inis the user input from the user
Duty_stris the existing duty string that is constantly changing
dFlagis boolean to signal if enter has been pressed

◆ InputNumberFCN()

def taskUser.InputNumberFCN (   char_In,
  Num_str,
  eFlag 
)

This function reads numeric data.

Based off of the inputs of the user, this function determines if the input is valid. It ignores all non-numerical inputs, except for the negative sign (-), the enter key (\r,
), the period key (.), and the backspace key (, '\x08', \x7F). It also limits the duty cycle to be between -100% and 100%.

Parameters
char_Inis the user input from the user
Duty_stris the existing duty string that is constantly changing
dFlagis boolean to signal if enter has been pressed

◆ printHelp()

def taskUser.printHelp ( )

This function outputs the GUI of encoder.

The different commands of the user interface is outputted here.

◆ taskUserFcn()

def taskUser.taskUserFcn (   taskName,
  period,
  Data,
  Velocity,
  Duty1,
  Duty2,
  clFlag,
  Kp,
  Ki,
  Kd,
  Position,
  Contact 
)

This function serves as the main user interface.

This functions allows for the user to communicate with the backend using shared data and queues. It allows for the user to input different commands to perform different actions like zeroing the position of the encoder, determing the instantaneous position of the encoder, the change of position from the most immediate last position to the current position, and collect data.

Parameters
taskNameis the name associated the with the taskUser in main.
periodis the frequency of which the taskUser is to be run.
zFlagis the shared variable that communicates the taskEncoder to determine whether the encoder should be zeroed or not.
Datais the share of positional data with taskEncoder.py.
Deltais the share of the delta value with taskEncoder.py.
Velocityis the share of the velocity value with taskEncoder.py
Duty1is the shared queue containing the requested duty cycle percentage for motor 1.
Duty2is the shared queue containing the requested duty cycle percentage for motor 2.
cFlagis a boolean to signal the clearing of fault conditions