Matthew Tagupa's ME 405 Labs and Term Project
main.py File Reference

Namespaces

 main
 

Variables

 main.user_input
 Initialization----------------------------------------------------------—. More...
 
 main.Kp = float(input('Please enter a positive value for Kp: '))
 
 main.pin_EN_A = pyb.Pin.cpu.A10
 
 main.pin_IN1_A = pyb.Pin.cpu.B4
 
 main.pin_IN2_A = pyb.Pin.cpu.B5
 
int main.timer_number_A = 3
 Create the timer object used for PWM generation.
 
int main.freq = 20000
 Designate the frequency.
 
 main.moeA = MotorDriver(pin_EN_A, pin_IN1_A, pin_IN2_A, timer_number_A, freq)
 Create a motor object passing in the pins and timer.
 
int main.Timer1 = 4
 Encoder. More...
 
int main.Timer2 = 8
 
int main.prescaler = 0
 
int main.period = 65535
 
 main.EncoderA1 = pyb.Pin.cpu.B6
 
 main.EncoderB1 = pyb.Pin.cpu.B7
 
 main.enco1 = Encoder(Timer1, EncoderA1, EncoderB1, prescaler, period)
 
int main.delta_sum = 0
 
 main.PropControl = CLPropControl(Kp)
 PropControl. More...
 
int main.Theta_ref = 1000
 
 main.Position_array = array.array('i', [])
 Create array for output. More...
 
 main.Time_array = array.array('i', [])
 
 main.delta_update = enco1.delta
 Main Program----------------------------------------------------------------------------------------—.
 
int main.Theta_Measured = delta_sum
 
 main.actuation = PropControl.actuation_value
 

Detailed Description

This is the main code that will combine the motor driver, encoder, and the proportional gain classes into a functioning step response for our motors. It will be the users responsibility to read the other codes to see what the input arguments are for each class and their methods.

Since this is the main code that will be running the step response, it will call the motor driver, encoder, and the poroportional controller to calculate and output the position and its associated time of measurement. As mentioned above it is the users responsibility to designate the pins, and the constants they would like to use for their motor, encoder, and proportional controller. It is highly recommended to view the classes MotorDriver, Encoder, and CLPropControl to understand what is occuring in each of the methods in those classes. This code already runs the template that each contains in the main portion of their respective code files, however, those portions of those files will not be run when calling on the class. The classes will only recognize this file for the inputs.

Author
Matthew Tagupa
Date
May 21, 2020