R2R
Functions
CurrentControl.h File Reference

The header for the current control file. More...

Go to the source code of this file.

Functions

void CurrentControlIntHandler (void)
 The interrupt handler for the current control loop. More...
 
void PI_controller (int motor, int reference, int actual)
 Simple PI controller that uses motorxControlPWM to control the motor output. More...
 
void setCurrent (int motor, int u)
 Sets the reference current for a given motor. More...
 
void get_mA (void)
 Print the current in mA to UART. More...
 
void get_counts (void)
 Print the current counts to UART. More...
 
void get_current_gains (void)
 Print the current gains to UART. More...
 
void set_current_gains (void)
 Sets the current gains by reading the UART buffer. More...
 
int getCurrent (int motor)
 Gets the motor current in counts (12 bit signed) More...
 
void reset_current_error (void)
 Sets the current gains by reading the UART buffer. More...
 
void counts_read (void)
 Reads the counts of the current to UART from an array. More...
 
void AD0_read (int mux)
 Triggers the ADC reading and saves it to the TEMP array. More...
 
void currentControlInit (void)
 Init ADC. More...
 
void setADCMux (int motor, int number)
 Sets the ADC MUX to read from either the current sense resistor 1, 2 or 3 from motor 1 or 2. More...
 

Detailed Description

The header for the current control file.

This file contains the functions for current sensing and control.

Author
Benjamen Lim
Huan Weng
Blake Strebel

Function Documentation

◆ AD0_read()

void AD0_read ( int  mux)

Triggers the ADC reading and saves it to the TEMP array.

On the PCB you have to specify either 1 or 2 to read the phase. For the breadboard prototype the number does not matter

Parameters
intthe muxed pins, specify 1 for phase A and 2 for phase B
Returns
Void

◆ counts_read()

void counts_read ( void  )

Reads the counts of the current to UART from an array.

Parameters
Void
Returns
Void

◆ currentControlInit()

void currentControlInit ( void  )

Init ADC.

Initialises ADC with Sequence 0, capturing 8 samples and a FIFO depth of 8 32-bit words, with last 12 bits containing the conversion result

Parameters
Void
Returns
Void

◆ CurrentControlIntHandler()

void CurrentControlIntHandler ( void  )

The interrupt handler for the current control loop.

Parameters
Void
Returns
Void

◆ get_counts()

void get_counts ( void  )

Print the current counts to UART.

Parameters
Void
Returns
Void

◆ get_current_gains()

void get_current_gains ( void  )

Print the current gains to UART.

Parameters
Void
Returns
Void

◆ get_mA()

void get_mA ( void  )

Print the current in mA to UART.

Parameters
Void
Returns
Void

◆ getCurrent()

int getCurrent ( int  motor)

Gets the motor current in counts (12 bit signed)

Parameters
intmotor
Returns
int motor current in counts (12 bit signed)

◆ PI_controller()

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

Simple PI controller that uses motorxControlPWM to control the motor output.

Parameters
intmotor
intreference value
intactual value
Returns
Void

◆ reset_current_error()

void reset_current_error ( void  )

Sets the current gains by reading the UART buffer.

Parameters
Void
Returns
Void

◆ set_current_gains()

void set_current_gains ( void  )

Sets the current gains by reading the UART buffer.

Parameters
Void
Returns
Void

◆ setADCMux()

void setADCMux ( int  motor,
int  number 
)

Sets the ADC MUX to read from either the current sense resistor 1, 2 or 3 from motor 1 or 2.

Parameters
Void
Returns
Void

◆ setCurrent()

void setCurrent ( int  motor,
int  u 
)

Sets the reference current for a given motor.

Parameters
intmotor
intu the reference value
Returns
Void