ME 305 Website by Cole Sheedy
userInterfaceFrontW4.py File Reference

User interface script for data collection and reception from Nucleo. More...

Functions

def userInterfaceFrontW4.gCallback (key)
 Callback function for the 'g' key release. More...
 
def userInterfaceFrontW4.sCallback (key)
 Callback function for the 's' key press. More...
 
def userInterfaceFrontW4.pCallback (key)
 Callback function for the 'p' key press. More...
 
def userInterfaceFrontW4.dCallback (key)
 Callback function for the 'd' key press. More...
 
def userInterfaceFrontW4.zCallback (key)
 Callback function for the 'z' key press. More...
 
def userInterfaceFrontW4.aCallback (key)
 Callback function for the 'a' key press. More...
 
def userInterfaceFrontW4.iCallback (key)
 Callback function for the 'i' key press. More...
 
def userInterfaceFrontW4.kCallback (key)
 Callback function for the 'k' key press. More...
 
def userInterfaceFrontW4.fCallback (key)
 Callback function for the 'f' key press. More...
 
def userInterfaceFrontW4.oCallback (key)
 Callback function for the 'o' key press. More...
 
def userInterfaceFrontW4.bCallback (key)
 Callback function for the 'b' key press. More...
 
def userInterfaceFrontW4.readCSV (csvFile='cleanedReference67Hz.csv')
 Function to read 3 columns of data from .csv file. More...
 
def userInterfaceFrontW4.jMetric (refOmega, actOmega, refPos, actPos)
 Function to calculate the metric J. More...
 

Variables

 userInterfaceFrontW4.last_key = None
 Keeping track of last key actuated.
 
int userInterfaceFrontW4.n = 0
 Counting variable.
 
list userInterfaceFrontW4.dataSet = []
 Housing for data before it is cleaned.
 
 userInterfaceFrontW4.actualTime = array('f', [])
 Actual time data that is read in through serial.
 
 userInterfaceFrontW4.position = array('f', [])
 Position values that are read in through serial.
 
 userInterfaceFrontW4.omega = array('f', [])
 Omega values that are read in through serial.
 
 userInterfaceFrontW4.Kp = array('f', [])
 Kp values that are read in through serial.
 
 userInterfaceFrontW4.desOmega = array('f', [])
 Desired Omega values that are read in through serial.
 
 userInterfaceFrontW4.refTime = array('f', [])
 Array of time from reference data.
 
 userInterfaceFrontW4.refOmega = array('f', [])
 Array of omegas from reference data.
 
 userInterfaceFrontW4.refPosition = array('f', [])
 Array of positions from reference data.
 
 userInterfaceFrontW4.ser = serial.Serial(port='COM9',baudrate=115273,timeout=.25)
 Serial object to communicate through VCP port.
 
 userInterfaceFrontW4.gCallback
 
 userInterfaceFrontW4.sCallback
 
 userInterfaceFrontW4.pCallback
 
 userInterfaceFrontW4.dCallback
 
 userInterfaceFrontW4.zCallback
 
 userInterfaceFrontW4.aCallback
 
 userInterfaceFrontW4.iCallback
 
 userInterfaceFrontW4.kCallback
 
 userInterfaceFrontW4.fCallback
 
 userInterfaceFrontW4.oCallback
 
 userInterfaceFrontW4.bCallback
 
 userInterfaceFrontW4.value = ser.readline().decode()
 Individual line read from Nucleo containing a variety of entries.
 
 userInterfaceFrontW4.POSITIONVALUE = value
 Position value recieved from Nucleo.
 
 userInterfaceFrontW4.DELTAVALUE = value
 Delta value recieved from Nucleo.
 
 userInterfaceFrontW4.ZEROTEXT = value
 Message saying the encoder has been zeroed.
 
 userInterfaceFrontW4.KPVALUE = value
 Kp value recieved from Nucleo.
 
 userInterfaceFrontW4.KIVALUE = value
 Ki value recieved from Nucleo.
 
 userInterfaceFrontW4.TIMEDELTA = value
 Time delta value recieved from Nucleo.
 
 userInterfaceFrontW4.OMEGA = value
 Omega value recieved from Nucleo.
 
def userInterfaceFrontW4.J = jMetric(refOmega, omega, refPosition, position)
 Calculated J metric.
 
 userInterfaceFrontW4.newline
 Assists in writing new line to .csv.
 
 userInterfaceFrontW4.writer = csv.writer(csvfile)
 

Detailed Description

Function Documentation

◆ aCallback()

def userInterfaceFrontW4.aCallback (   key)

Callback function for the 'a' key press.

If user presses the 'a' key down, the keyboard function will be enabled. We will use this callback function to send the letter 'a' and then send a Kp value for tuning. This can only be done before motor starts. If done after the default Kp will be 0.1

◆ bCallback()

def userInterfaceFrontW4.bCallback (   key)

Callback function for the 'b' key press.

If user presses the 'b' key down, the keyboard function will be enabled. We will use this callback function to send the letter 'b' to the Nucleo to retrieve the current Ki value.

◆ dCallback()

def userInterfaceFrontW4.dCallback (   key)

Callback function for the 'd' key press.

If user presses the 'd' key down, the keyboard function will be enabled. We will use this callback function to send the letter 'd' to the Nucleo to print the corrected delta value of the encoder.

◆ fCallback()

def userInterfaceFrontW4.fCallback (   key)

Callback function for the 'f' key press.

If user presses the 'f' key down, the keyboard function will be enabled. We will use this callback function to send the letter 'f' to the Nucleo to retrieve the most recent time delta.

◆ gCallback()

def userInterfaceFrontW4.gCallback (   key)

Callback function for the 'g' key release.

If user presses the 'g' key down, the keyboard function will be enabled. We will use this callback function to send the letter 'g' to the Nucleo to start data collection when the user decides to.

◆ iCallback()

def userInterfaceFrontW4.iCallback (   key)

Callback function for the 'i' key press.

If user presses the 'i' key down, the keyboard function will be enabled. We will use this callback function to send the letter 'i' and then send a Ki value for tuning. This can only be done before motor starts. If done after the default Ki will be 1.0.

◆ jMetric()

def userInterfaceFrontW4.jMetric (   refOmega,
  actOmega,
  refPos,
  actPos 
)

Function to calculate the metric J.

This function sums the squares of the omega and position errors, then divides by the total count of samples.

Parameters
refOmegaList of reference omega.
actOmegaList of actual omega values.
refPosList of reference positions.
actPosList of actual positions.
Returns
Jmetric The PI-Controller performance metric.

◆ kCallback()

def userInterfaceFrontW4.kCallback (   key)

Callback function for the 'k' key press.

If user presses the 'k' key down, the keyboard function will be enabled. We will use this callback function to send the letter 'k' to the Nucleo to retrieve the current Kp value.

◆ oCallback()

def userInterfaceFrontW4.oCallback (   key)

Callback function for the 'o' key press.

If user presses the 'o' key down, the keyboard function will be enabled. We will use this callback function to send the letter 'o' to the Nucleo to retrieve the most recent omega value.

◆ pCallback()

def userInterfaceFrontW4.pCallback (   key)

Callback function for the 'p' key press.

If user presses the 'p' key down, the keyboard function will be enabled. We will use this callback function to send the letter '' to the Nucleo to print the position of the encoder.

◆ readCSV()

def userInterfaceFrontW4.readCSV (   csvFile = 'cleanedReference67Hz.csv')

Function to read 3 columns of data from .csv file.

Parameters
csvFileName of .csv file.

◆ sCallback()

def userInterfaceFrontW4.sCallback (   key)

Callback function for the 's' key press.

If user presses the 's' key down, the keyboard function will be enabled. We will use this callback function to send the letter 's' to the Nucleo to start data collection when the user decides to.

◆ zCallback()

def userInterfaceFrontW4.zCallback (   key)

Callback function for the 'z' key press.

If user presses the 'z' key down, the keyboard function will be enabled. We will use this callback function to send the letter 'z' to the Nucleo to zero the position of the encoder.