Matthew Tagupa's ME 405 Labs and Term Project
main Namespace Reference

Variables

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

Variable Documentation

◆ Position_array

main.Position_array = array.array('i', [])

Create array for output.

These array setups will be used for the step response for the different proportional gains. Our graph to show the response behavior will be position measured in encoder ticks vs time measured in milliseconds

◆ PropControl

main.PropControl = CLPropControl(Kp)

PropControl.

We need to pass in the Kp value to initialize the proportional controller. This is also where we are going to define the setpoint.

◆ Timer1

int main.Timer1 = 4

Encoder.

Designate encoder timer number (4 or 8)

◆ user_input

main.user_input
Initial value:
1 = input('Would you like to find response curves?'
2  '(y)es or (n)o: ')

Initialization----------------------------------------------------------—.

Ask for the user to input whether they want to run this code