R2R
Classes | Functions
PositionControl.h File Reference

control header More...

Go to the source code of this file.

Classes

struct  control_error
 

Functions

void MotorTimerInit (void)
 This function sets up the timer interrupt for position control. More...
 
void Timer1IntHandler (void)
 The interrupt handler for position control. More...
 
void set_position_gains (void)
 Sets position gains on the Tiva microcontroller by reading from UART. More...
 
void get_position_gains (void)
 Gets position gains on the Tiva microcontroller by reading to UART. More...
 
int get_desired_angle (int motor)
 Gets desired angle for a given motor. More...
 
void set_desired_angle (int angle, int motor)
 Sets desired angle for a given motor. More...
 
void reset_pos (void)
 Resets desired position to 0 counts. More...
 
void reset_controller_error (void)
 Resets controller error on both controllers to be zero. More...
 
void load_position_trajectory (int motor)
 Loads position trajectory for a given motor over UART. More...
 
void PID_Controller (int reference, int actual, int motor)
 Calculates pwm to send to the motor drivr. 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...
 

Detailed Description

control header

This file contains the pwm functions

Author
Benjamen Lim
Huan Weng
Blake Strebel

Function Documentation

◆ decog_motor()

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);
Parameters
xcurrent angle in counts
motorthe motor to decog
Returns
control signal modifier based on position

◆ get_desired_angle()

int get_desired_angle ( int  motor)

Gets desired angle for a given motor.

Parameters
motorreads the desired angle for the given motor
Returns
Void

◆ get_position_gains()

void get_position_gains ( void  )

Gets position gains on the Tiva microcontroller by reading to UART.

Parameters
Void
Returns
Void

◆ load_position_trajectory()

void load_position_trajectory ( int  motor)

Loads position trajectory for a given motor over UART.

Parameters
motorspecifies the trajectory that is being assigned from UART
Returns
Void

◆ MotorTimerInit()

void MotorTimerInit ( void  )

This function sets up the timer interrupt for position control.

Parameters
Void
Returns
Void

◆ PID_Controller()

void PID_Controller ( int  reference,
int  actual,
int  motor 
)

Calculates pwm to send to the motor drivr.

Parameters
referencethe reference angle
actualthe commanded angle
motorthe specified motor
Returns
Void

◆ reset_controller_error()

void reset_controller_error ( void  )

Resets controller error on both controllers to be zero.

Parameters
Void
Returns
Void

◆ reset_pos()

void reset_pos ( void  )

Resets desired position to 0 counts.

Parameters
Void
Returns
Void

◆ set_desired_angle()

void set_desired_angle ( int  angle,
int  motor 
)

Sets desired angle for a given motor.

Parameters
motorspecifies the desired angle for the given motor
Returns
Void

◆ set_position_gains()

void set_position_gains ( void  )

Sets position gains on the Tiva microcontroller by reading from UART.

Parameters
Void
Returns
Void

◆ setDecogging()

void setDecogging ( void  )

Turn on/off decogging by setting global variable.

Parameters
void
Returns
Void

◆ Timer1IntHandler()

void Timer1IntHandler ( void  )

The interrupt handler for position control.

Parameters
Void
Returns
Void