R2R
|
control source code More...
#include "r2r.h"
#include "PositionControl.h"
#include "CurrentControl.h"
#include "Utilities.h"
#include "Encoder.h"
#include "Motor.h"
#include <math.h>
Functions | |
void | MotorTimerInit (void) |
This function sets up the timer interrupt for position control. More... | |
void | get_position_gains (void) |
Gets position gains on the Tiva microcontroller by reading to UART. More... | |
void | set_position_gains (void) |
Sets position gains on the Tiva microcontroller by reading from UART. More... | |
void | set_desired_angle (int angle, int motor) |
Sets desired angle for a given motor. More... | |
int | get_desired_angle (int motor) |
Gets desired angle for a given motor. More... | |
void | load_position_trajectory (int motor) |
Loads position trajectory for a given motor over UART. More... | |
void | Timer1IntHandler (void) |
The interrupt handler for position control. More... | |
void | PID_Controller (int reference, int actual, int motor) |
Calculates pwm to send to the motor drivr. More... | |
void | reset_controller_error (void) |
Resets controller error on both controllers to be zero. More... | |
int | decog_motor (int x, int motor) |
Motor decogging to smooth output of motor. More... | |
void | setDecogging (void) |
Turn on/off decogging by setting global variable. More... | |
control source code
This file contains the pwm functions
int decog_motor | ( | int | x, |
int | motor | ||
) |
Motor decogging to smooth output of motor.
Motor decogging function that smoothes out the output from the motor by adding a term to the control signal to compensate for the cogging in the BLDC motor. Equations are fit using PositionDataAnalyze.m MATLAB script.
Example:
u = u + decog_motor(current_Angle_Radians, MOTOR_1);
x | current angle in counts |
motor | the motor to decog |
int get_desired_angle | ( | int | motor | ) |
Gets desired angle for a given motor.
motor | reads the desired angle for the given motor |
void get_position_gains | ( | void | ) |
Gets position gains on the Tiva microcontroller by reading to UART.
Void |
void load_position_trajectory | ( | int | motor | ) |
Loads position trajectory for a given motor over UART.
motor | specifies the trajectory that is being assigned from UART |
void MotorTimerInit | ( | void | ) |
This function sets up the timer interrupt for position control.
Void |
void PID_Controller | ( | int | reference, |
int | actual, | ||
int | motor | ||
) |
Calculates pwm to send to the motor drivr.
reference | the reference angle |
actual | the commanded angle |
motor | the specified motor |
void reset_controller_error | ( | void | ) |
Resets controller error on both controllers to be zero.
Void |
void set_desired_angle | ( | int | angle, |
int | motor | ||
) |
Sets desired angle for a given motor.
motor | specifies the desired angle for the given motor |
void set_position_gains | ( | void | ) |
Sets position gains on the Tiva microcontroller by reading from UART.
Void |
void setDecogging | ( | void | ) |
Turn on/off decogging by setting global variable.
void |
void Timer1IntHandler | ( | void | ) |
The interrupt handler for position control.
Void |