ME 305 Website by Cole Sheedy
controllerTaskW4.controllerTask Class Reference

Runs the UI backend for the encoder reading and UI file. More...

Public Member Functions

def __init__ (self, period=15000)
 Constructor of controllerTask. More...
 
def readCSV (self, csvFile='cleanedReference67Hz.csv')
 Reads in the reference position and velocity values. More...
 
def run (self)
 Runs the finite state machine of the controllerTask. More...
 

Public Attributes

 myuart
 UART port object.
 
 n
 Counting variable.
 
 state
 State tracking variable.
 
 iteration
 Iteration variable for prompting.
 
 period
 Time between data point collections in microseconds.
 
 size
 Total number of data points collected.
 
 KpPrime
 Initializing to the default Kp stored in the shares file.
 
 KiPrime
 Initializing to the default Ki stored in the shares file.
 
 mot_1
 Motor object.
 
 enc_1
 Encoder object.
 
 cont_1
 Controller object.
 
 refPosition
 Reference position data in array read in from .csv.
 
 refOmega
 Reference omega data in array read in from .csv.
 
 nextTime
 Timer to determine when in the future data can be collected.
 
 startTime
 Timer that starts once the controller task starts.
 
 thisTime
 Timer to track current time and compare to nextTime, which is in the future.
 
 duty
 

Detailed Description

Runs the UI backend for the encoder reading and UI file.

Constructor & Destructor Documentation

◆ __init__()

def controllerTaskW4.controllerTask.__init__ (   self,
  period = 15000 
)

Constructor of controllerTask.

This constructor takes one attribute called period. The period how many microseconds desired in between collecting data points. Example: 20000us = .02s. It is important to run this task simulataneously in frequency to the UITask to prevent latency.

Parameters
periodTime between data point collection in microseconds. Could be interpretted as the period in microseconds.

Member Function Documentation

◆ readCSV()

def controllerTaskW4.controllerTask.readCSV (   self,
  csvFile = 'cleanedReference67Hz.csv' 
)

Reads in the reference position and velocity values.

This function reads in column 2 and 3 of data from a .csv file. When we extract the second and third column from the reference data, we get the reference position and velocity.

Parameters
csvFileName of .csv file with reference data.

◆ run()

def controllerTaskW4.controllerTask.run (   self)

Runs the finite state machine of the controllerTask.

This finite state machine has approximately 4 states. The first state waits for a 'g' keystroke from the user to start data collection and an 'a' or 'i' keystroke in case of the need to update to a new KpPrime or KiPrime value for the controller. The second state waits for other commands from the user like 'p', 's', 'd', 'f', 'o', 'b', 'k' and 'z'. Once done collecting data, the third state send the data collected, which is waiting in a queue in share.py, via the UART port to the front end.


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