|
R2R
|
The source for the current control file. More...
#include "r2r.h"#include "CurrentControl.h"#include "PositionControl.h"#include "Motor.h"#include "Utilities.h"#include <stdio.h>Macros | |
| #define | SWITCHDELAY 30 |
| #define | MA_PER_COUNT 5.75474330357 |
Functions | |
| void | currentControlInit (void) |
| Init ADC. More... | |
| 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 | 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... | |
| void | setCurrent (int motor, int u) |
| Sets the reference current for a given motor. 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 | get_mA (void) |
| Print the current in mA to UART. More... | |
| void | get_counts (void) |
| Print the current counts to UART. 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... | |
The source for the current control file.
This file contains the functions for current sensing and control.
| 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
| int | the muxed pins, specify 1 for phase A and 2 for phase B |
| void counts_read | ( | void | ) |
Reads the counts of the current to UART from an array.
| Void |
| 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
| Void |
| void CurrentControlIntHandler | ( | void | ) |
The interrupt handler for the current control loop.
| Void |
| void get_counts | ( | void | ) |
Print the current counts to UART.
| Void |
| void get_current_gains | ( | void | ) |
Print the current gains to UART.
| Void |
| void get_mA | ( | void | ) |
Print the current in mA to UART.
| Void |
| int getCurrent | ( | int | motor | ) |
Gets the motor current in counts (12 bit signed)
| int | motor |
| void PI_controller | ( | int | motor, |
| int | reference, | ||
| int | actual | ||
| ) |
Simple PI controller that uses motorxControlPWM to control the motor output.
| int | motor |
| int | reference value |
| int | actual value |
| void reset_current_error | ( | void | ) |
Sets the current gains by reading the UART buffer.
| Void |
| void set_current_gains | ( | void | ) |
Sets the current gains by reading the UART buffer.
| Void |
| 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.
| Void |
| void setCurrent | ( | int | motor, |
| int | u | ||
| ) |
Sets the reference current for a given motor.
| int | motor |
| int | u the reference value |
1.8.14