Masterproject #2
6 changed files with 64 additions and 1 deletions
|
@ -58,5 +58,5 @@ The user can input different commands to the ATM-system using the serial interfa
|
|||
## References
|
||||
- [adf4351](https://github.com/dfannin/adf4351) by David Fannin was modified to be used with an ESP32 microcontroller.
|
||||
- [TMC2130Stepper](https://github.com/teemuatlut/TMC2130Stepper) by teemuatlut was used for the TMC2130 Stepper drivers.
|
||||
- [AD5593R](https://github.com/LukasJanavicius/AD5593R-Arduino-ESP32-Library) by LukasJanavicius was used for the AD5593R ADC.
|
||||
- [ArduiTaM](https://doi.org/10.5194/mr-1-105-2020) by Jouda et al. was an inspiration for the implementation.
|
||||
|
||||
|
|
|
@ -4,8 +4,10 @@
|
|||
#include "commands/FrequencySweep.h"
|
||||
#include "commands/TuneMatch.h"
|
||||
#include "commands/Homing.h"
|
||||
#include "commands/SetVoltages.h"
|
||||
#include "commands/MeasureReflection.h"
|
||||
|
||||
|
||||
#define DEBUG
|
||||
|
||||
#include "Debug.h"
|
||||
|
@ -16,6 +18,7 @@ CommandManager commandManager;
|
|||
FrequencySweep frequencySweep;
|
||||
TuneMatch tuneMatch;
|
||||
Homing homing;
|
||||
SetVoltages setVoltages;
|
||||
MeasureReflection measureReflection;
|
||||
|
||||
// Frequency Settings
|
||||
|
@ -23,6 +26,7 @@ MeasureReflection measureReflection;
|
|||
#define START_FREQUENCY 50000000U // 50MHz
|
||||
#define STOP_FREQUENCY 110000000 // 110MHz
|
||||
|
||||
|
||||
ADF4351 adf4351(SCLK_PIN, MOSI_PIN, LE_PIN, CE_PIN); // declares object PLL of type ADF4351
|
||||
|
||||
TMC2130Stepper tuning_driver = TMC2130Stepper(EN_PIN_M1, DIR_PIN_M1, STEP_PIN_M1, CS_PIN_M1, MOSI_PIN, MISO_PIN, SCLK_PIN);
|
||||
|
@ -36,6 +40,7 @@ Stepper tuner = {tuning_stepper, tuning_driver, DIAG1_PIN_M1, "Tuner"};
|
|||
Stepper matcher = {matching_stepper, matching_driver, DIAG1_PIN_M2, "Matcher"};
|
||||
|
||||
// ADC DAC Module
|
||||
|
||||
AD5593R adac = AD5593R(23, I2C_SDA, I2C_SCL);
|
||||
bool DACs[8] = {0, 0, 1, 1, 0, 0, 0, 0};
|
||||
bool ADCs[8] = {1, 1, 0, 0, 0, 0, 0, 0};
|
||||
|
@ -50,6 +55,7 @@ void setup()
|
|||
commandManager.registerCommand('f', &frequencySweep);
|
||||
commandManager.registerCommand('d', &tuneMatch);
|
||||
commandManager.registerCommand('h', &homing);
|
||||
commandManager.registerCommand('v', &setVoltages);
|
||||
commandManager.registerCommand('m', &measureReflection);
|
||||
|
||||
pinMode(MISO_PIN, INPUT_PULLUP); // Seems to be necessary for SPI to work
|
||||
|
@ -116,6 +122,8 @@ void setup()
|
|||
adac.set_DAC_max_2x_Vref();
|
||||
adac.set_ADC_max_2x_Vref();
|
||||
adac.configure_DACs(DACs);
|
||||
adac.write_DAC(VM, 0.0);
|
||||
adac.write_DAC(VT, 0.0);
|
||||
|
||||
adac.configure_ADCs(ADCs);
|
||||
|
||||
|
|
|
@ -8,6 +8,10 @@
|
|||
*/
|
||||
class FrequencySweep : public Command {
|
||||
public:
|
||||
/**
|
||||
* @brief This function performs a frequency sweep
|
||||
* @param input_line The input line from the serial monitor. The syntax is f<start frequency>f<stop frequency>f<frequency step>.
|
||||
*/
|
||||
void execute(String input_lne) override;
|
||||
void printResult() override;
|
||||
void printHelp() override;
|
||||
|
|
25
src/commands/SetVoltages.cpp
Normal file
25
src/commands/SetVoltages.cpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
#include "Utilities.h"
|
||||
#include "SetVoltages.h"
|
||||
|
||||
void SetVoltages::execute(String input_line){
|
||||
char delimiter = 'v';
|
||||
int VMIndex = input_line.indexOf(delimiter) + 1;
|
||||
int VTIndex = input_line.indexOf(delimiter, VMIndex) + 1;
|
||||
|
||||
float VMVoltage = input_line.substring(VMIndex, VTIndex - 1).toFloat();
|
||||
float VTVoltage = input_line.substring(VTIndex).toFloat();
|
||||
|
||||
adac.write_DAC(VM, VMVoltage);
|
||||
adac.write_DAC(VT, VTVoltage);
|
||||
}
|
||||
|
||||
void SetVoltages::printResult(){
|
||||
printInfo("Voltages set successfully");
|
||||
}
|
||||
|
||||
void SetVoltages::printHelp(){
|
||||
Serial.println("Set voltages command");
|
||||
Serial.println("Syntax: v<VM voltage>v<VT voltage>");
|
||||
Serial.println("Example: v0.5v0.5");
|
||||
Serial.println("This will set the VM and VT voltages to 0.5 V");
|
||||
}
|
20
src/commands/SetVoltages.h
Normal file
20
src/commands/SetVoltages.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef SETVOLTAGES_H
|
||||
#define SETVOLTAGES_H
|
||||
|
||||
#include "Command.h"
|
||||
|
||||
/**
|
||||
* @brief This class is used to set the voltages of the ADAC module
|
||||
*/
|
||||
class SetVoltages : public Command {
|
||||
public:
|
||||
/**
|
||||
* @brief This function sets the voltages of the ADAC module
|
||||
* @param input_line The input line from the serial monitor. The syntax is v<VM voltage>v<VT voltage>.
|
||||
*/
|
||||
void execute(String input_line) override;
|
||||
void printResult() override;
|
||||
void printHelp() override;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -12,6 +12,12 @@
|
|||
#include "Stepper.h"
|
||||
#include "Positions.h" // Calibrated frequency positions are defined her
|
||||
|
||||
// Global variables for the adac module
|
||||
#define MAGNITUDE 0
|
||||
#define PHASE 1
|
||||
#define VT 2
|
||||
#define VM 3
|
||||
|
||||
// We want these objects to be accessible from all files
|
||||
extern ADF4351 adf4351;
|
||||
extern Stepper tuner;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue