Set up UI between Spyder and Nucleo to collect and plot data. More...
Functions | |
def | PCFrontEnd.writeToCSV (data, filename) |
Strip and split the data into a csv file from the Nucleo. More... | |
def | PCFrontEnd.clearFiles (fileNames) |
Method for deleting files. More... | |
def | PCFrontEnd.plotData (csvName, figNameX, figNameY) |
Plot the position and speed data from the encoders. More... | |
Variables | |
PCFrontEnd.ser = serial.Serial(port='COM5', baudrate=115200, timeout=1) | |
Set up serial communication through serial command. | |
string | PCFrontEnd.pngFileNameX = "Lab0xFF_MotXData.png" |
File name for initial plot. | |
string | PCFrontEnd.pngFileNameY = "Lab0xFF_MotYData.png" |
File name for initial plot. | |
string | PCFrontEnd.csvFileName = "Lab0xFF_allData.csv" |
File name of the exported data. | |
bool | PCFrontEnd.debugFlag = False |
Debugging flag to hide certain print statements. | |
PCFrontEnd.dataFromDataTask = None | |
The outputted data from the serial port. More... | |
PCFrontEnd.dataToSave = input('Please input either an x or a y depending on which data is being plotted: ') | |
String that sets whether x or y data is being collected. | |
PCFrontEnd.currentFromNucleo = dataFromDataTask | |
Non empty line from Nucleo serial communication. | |
Set up UI between Spyder and Nucleo to collect and plot data.
Data recorded by various sensors connected to the Nucleo is collected and sent through serial to the front end for plotting and writing to a .csv file. See source code here:
def PCFrontEnd.clearFiles | ( | fileNames | ) |
Method for deleting files.
Since the csv writer is set to append to a certain file, the file to be written to must be removed each time the PC collects new data. If it was desired, this could be replaced by a method to rename the next file to write to a new file each time. For this, the os
module is used.
fileNames | is a list of strings containing the various files written each time the frontEnd is run |
def PCFrontEnd.plotData | ( | csvName, | |
figNameX, | |||
figNameY | |||
) |
Plot the position and speed data from the encoders.
The subplot feature within matlibplot will be utilized to visualize the position and speed of the motors along with the reference data to see the difference in position and speed at all points in time.
csvName | Specifies the file to grab the data from. |
figNameX | Specifies the name of the x-data figure |
figNameY | Specifies the name of the y-data figure |
def PCFrontEnd.writeToCSV | ( | data, | |
filename | |||
) |
Strip and split the data into a csv file from the Nucleo.
After data collection is finished, the data must be stripped and split in order to write to a csv file.
data | The data from the serial port that needs to be saved into the CSV. |
filename | The specific file to save the data to. |
PCFrontEnd.dataFromDataTask = None |
The outputted data from the serial port.
Most recent data from serial communciation between PC and dataTask.