Kyle Chuang | ME405 Mechatronics Portfolio
Lab3_main.py File Reference

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

Functions

def Lab3_main.myCallback (IQR_source)
 Callback function. More...
 

Variables

list Lab3_main.volts = [0]
 List that stores voltage data.
 
list Lab3_main.time = [0]
 List that stores time data.
 
int Lab3_main.n = 0
 Counter variable used to iterate through data.
 
int Lab3_main.switch = 0
 Switch vairable used to not when the button is pushed.
 
int Lab3_main.frequency = 20000
 Frequency to record data.
 
int Lab3_main.period = 1/frequency
 
int Lab3_main.t = 0
 
 Lab3_main.myuart = UART(2)
 
 Lab3_main.tim = pyb.Timer(6, freq=frequency)
 Creates an emergency buffer to store errors that are thrown inside ISR. More...
 
 Lab3_main.pinC13 = pyb.Pin(pyb.Pin.board.PC13, mode=pyb.Pin.IN)
 Intializes the BLUE user button.
 
 Lab3_main.pinC0 = pyb.Pin(pyb.Pin.board.PC0, mode=pyb.Pin.IN)
 Initializes the ADC pin.
 
 Lab3_main.adc = pyb.ADC(pinC0)
 Initializes the ADC object.
 
 Lab3_main.buf = array.array('H', (0 for index in range (10000)))
 Creates a blank array which will be populated with data.
 
 Lab3_main.extint = pyb.ExtInt (pinC13, pyb.ExtInt.IRQ_FALLING, pyb.Pin.PULL_NONE, myCallback)
 Detects when the USER button is pressed and the callback function is called.
 

Detailed Description

Lab0x03 Pushing the Right Buttons Back End.

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.

Author
Kyle Chuang
Date
January 30, 2021

Function Documentation

◆ myCallback()

def Lab3_main.myCallback (   IQR_source)

Callback function.

This is the callback function that is used when the user clicks the blue USER button. This will overrite the code in the while True statement and will populate the buffer with voltage readings from the Nucleo. If the buffer populates before the step response is recorded, the buffer resets.

Variable Documentation

◆ tim

Lab3_main.tim = pyb.Timer(6, freq=frequency)

Creates an emergency buffer to store errors that are thrown inside ISR.

Creates a timer object