Kyle Chuang | ME405 Mechatronics Portfolio
UI3.py File Reference

Lab0x03 Pushing the Right Buttons Front End. More...

Functions

def UI3.sendChar ()
 Function that prompts for user input. More...
 
def UI3.readChar ()
 Function that consolidates the data from the main.py file. More...
 

Variables

 UI3.ser = serial.Serial(port='COM3', baudrate=115273, timeout=1)
 
list UI3.t = []
 List for formatted time data.
 
list UI3.v = []
 List for formatted voltage data.
 

Detailed Description

Lab0x03 Pushing the Right Buttons Front End.

This is the front end code that the user interfaces with on Spyder. It consists of two methods: sendChar() and readChar().

*sendChar(): This method asks for the user to input "G", which prompts the Nucleo to be ready to accept inputs. If an invalid input is applied, an error message is printed and then asks for another input.

*readChar(): This method waits 5 seconds before waiting for a response from the backend code on the Nucleo. The data is parsed into the front end as strings which are then stripped and reappended into separate lists. These two lists are then used for plotting a Voltage vs. Time step response. Additionally, the data is stored in a .csv file titled "Button Step Response.csv".

Note
If you would like to return multiple plots, please run the front end fresh for each plot you would like to receive. The back end only needs to be started once to receive multiple plots.
Author
Kyle Chuang
Date
January 30, 2021

Function Documentation

◆ readChar()

def UI3.readChar ( )

Function that consolidates the data from the main.py file.

This method waits 5 seconds before waiting for a response from the backend code on the Nucleo. The data is parsed into the front end as strings which are then stripped and reappended into separate lists. These two lists are then used for plotting a Voltage vs. Time step response. Additionally, the data is stored in a .csv file titled "Button Step Response.csv".

◆ sendChar()

def UI3.sendChar ( )

Function that prompts for user input.

Prompts the user to input "G" in order to tell the Nucleo to begin accepting inputs. It then writes "G" in ascii, which is read by the code on the Nucleo. If an invalid input is applied, an error message is printed and then prompts another input.