ME405 Portfolio
The following documentation details each step of the ME 405 term project.
Lab_03_Back.py File Reference

Backend of lab 3 to be run on Nucleo and collect data. More...

Functions

def Lab_03_Back.UserInterrupt (pin)
 This is the callback function for the user button press. More...
 

Variables

 Lab_03_Back.myuart = UART(2)
 Defines serial input port.
 
 Lab_03_Back.ADCPin = pyb.Pin(pyb.Pin.board.PA0)
 Defines the pin for the user input button.
 
 Lab_03_Back.timer = pyb.Timer(2 , prescaler = 79 , period = int(100))
 Defines the timer to be used.
 
 Lab_03_Back.buffer = array.array('H' , (0 for index in range (101)))
 Defines memory buffer to be used in data collection.
 
 Lab_03_Back.adc = pyb.ADC(ADCPin)
 Variable defines the analog to digital converter pin.
 
int Lab_03_Back.state = 0
 Variable representing the current state of the program.
 
 Lab_03_Back.pinA5 = pyb.Pin(pyb.Pin.cpu.A5 , pyb.Pin.OUT_PP)
 Setting up Nucleo LED.
 
 Lab_03_Back.Interrupt_Button = pyb.ExtInt(pyb.Pin.board.PC13, pyb.ExtInt.IRQ_RISING, pyb.Pin.PULL_UP, UserInterrupt)
 Defining nucleo user input button as external interrupt.
 
float Lab_03_Back.voltage = int(buffer[n])*3.3/4095
 Variable representing adc data converted to voltage.
 

Detailed Description

Backend of lab 3 to be run on Nucleo and collect data.

This file will run on the Nucleo and collect voltage data to be sent via serial to spyder. This program will initially wait for input from spyder, after which it will again wait for user input through the blue button. The button press causes an interrupt which starts the data collection of the button pin voltage. This data is then converted to voltage and sent back to spyder.

Function Documentation

◆ UserInterrupt()

def Lab_03_Back.UserInterrupt (   pin)

This is the callback function for the user button press.

This function is called when the blue user button is pressed. The only thing this callback does is adjust the state to the data collection state in order to capture the pin voltage.

Parameters
pinThis fulfills the parameter requirement of the callback fcn.