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) | |
User interface script for data collection and reception from Nucleo.
This is the main script the user will use while simultaneously running encoder and UI backend task files on the Nucleo. This script will read the data that the Nucleo sends us, clean it up, plot time vs. value, then write all the data to empty dataCollection.csv or user can easily change to write to their desired file.
Source code files and related ones:
mainW4.py https://bitbucket.org/ColeSheedy/me-305-work-repository/src/master/LabWork/Lab5.3/mainW4.py
userInterfaceFrontW4.py https://bitbucket.org/ColeSheedy/me-305-work-repository/src/master/LabWork/Lab5.3/userInterfaceFrontW4.py
UITaskW4.py https://bitbucket.org/ColeSheedy/me-305-work-repository/src/master/LabWork/Lab5.3/UITaskW4.py
controllerTaskW4.py https://bitbucket.org/ColeSheedy/me-305-work-repository/src/master/LabWork/Lab5.3/controllerTaskW4.py
shareW4.py https://bitbucket.org/ColeSheedy/me-305-work-repository/src/master/LabWork/Lab5.3/shareW4.py
controllerDriverW4.py https://bitbucket.org/ColeSheedy/me-305-work-repository/src/master/LabWork/Lab5.3/controllerDriverW4.py
encoderDriverW4.py https://bitbucket.org/ColeSheedy/me-305-work-repository/src/master/LabWork/Lab5.3/encoderDriverW4.py
motorDriverW4.py https://bitbucket.org/ColeSheedy/me-305-work-repository/src/master/LabWork/Lab5.3/motorDriverW4.py
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
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.
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.
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.
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.
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.
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.
refOmega | List of reference omega. |
actOmega | List of actual omega values. |
refPos | List of reference positions. |
actPos | List of actual positions. |
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.
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.
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.
def userInterfaceFrontW4.readCSV | ( | csvFile = 'cleanedReference67Hz.csv' | ) |
Function to read 3 columns of data from .csv file.
csvFile | Name of .csv file. |
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.
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.