Kyle Chuang | ME405 Mechatronics Portfolio
Lab0x03: Pushing the Right Buttons Documentation

Summary

I wrote this code to test the voltage step response of the blue USER button on the Nucleo when pressed. This lab consists of two files:

  1. Lab3_main.py: This is the back end code that runs on the Nucleo for the button-press step response. This code waits for the user to input G to begin waiting for data collection. Once the blue USER button is pressed on the Nucleo it triggers an interrupt. This function will populate a premade buffer using voltage readings from the USER button pin to track the step response. Once done, the buffer is filtered down to only include the relevant data and then it is sent to the front end.
  2. UI3.py: 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.

Task Diagram

Here's my task diagram which shows how UI3.py and Lab3_main.py communicate.

Author
Kyle Chuang
Date
February 2,2021