mirror of
https://github.com/nqrduck/ATM.git
synced 2025-01-05 23:08:10 +00:00
Implemented frequency-ranges with filterbank.
This commit is contained in:
parent
6c8920c2c8
commit
e035e9d578
4 changed files with 69 additions and 12 deletions
|
@ -25,3 +25,7 @@
|
|||
|
||||
//ADC Pin
|
||||
#define REFLECTION_PIN 15
|
||||
|
||||
// Filter Bank
|
||||
#define FILTER_SWITCH_A 22
|
||||
#define FILTER_SWITCH_B 23
|
||||
|
|
|
@ -1,14 +1,43 @@
|
|||
// Position @ 40, 60, 80, 100, 120, 140, 160, 180, 200, 220 MHz
|
||||
struct FREQUENCY_POSITION
|
||||
// Position @ 40, 60, 80, 100, 120, 140, 160, 180, 200, 220 MHzstruct Filter
|
||||
struct Filter
|
||||
{
|
||||
uint32_t FREQUENCY;
|
||||
uint32_t TUNING_POSITION;
|
||||
uint32_t MATCHING_POSITION;
|
||||
uint32_t fg;
|
||||
int control_input_a;
|
||||
int control_input_b;
|
||||
};
|
||||
|
||||
struct FrequencyRange
|
||||
{
|
||||
uint32_t START_FREQUENCY;
|
||||
uint32_t STOP_FREQUENCY;
|
||||
uint32_t CENTER_FREQUENCY;
|
||||
Filter FILTER;
|
||||
uint32_t TUNING_CENTER_POSITION;
|
||||
uint32_t MATCHING_CENTER_POSITION;
|
||||
};
|
||||
|
||||
const Filter FG_71MHZ = {71000000U, HIGH, HIGH};
|
||||
const Filter FG_120MHZ = {120000000U, LOW, HIGH};
|
||||
const Filter FG_180MHZ = {180000000U, LOW, LOW};
|
||||
const Filter FG_260MHZ = {260000000U, HIGH, LOW};
|
||||
|
||||
// Settings for 100MHz -18dB
|
||||
#define TUNING_STEPPER_HOME 34250U
|
||||
#define MATCHING_STEPPER_HOME 45000U
|
||||
//#define TUNING_STEPPER_HOME 34250U
|
||||
//#define MATCHING_STEPPER_HOME 45000U
|
||||
|
||||
const FrequencyRange RANGE_75_125MHZ =
|
||||
{
|
||||
75000000U,
|
||||
125000000U,
|
||||
100000000U,
|
||||
FG_120MHZ,
|
||||
34250U,
|
||||
45000U,
|
||||
};
|
||||
|
||||
|
||||
const FrequencyRange HOME_RANGE = RANGE_75_125MHZ;
|
||||
|
||||
|
||||
// Settings for 125MHz -30dB
|
||||
//#define TUNING_STEPPER_HOME 37550U
|
||||
|
|
|
@ -8,5 +8,5 @@ struct Stepper{
|
|||
AccelStepper STEPPER;
|
||||
TMC2130Stepper DRIVER;
|
||||
int STALL_PIN;
|
||||
int HOME_POSITION;
|
||||
String TYPE;
|
||||
};
|
||||
|
|
32
src/ATM.ino
32
src/ATM.ino
|
@ -25,9 +25,11 @@ TMC2130Stepper matching_driver = TMC2130Stepper(EN_PIN_M2, DIR_PIN_M2, STEP_PIN_
|
|||
AccelStepper tuning_stepper = AccelStepper(tuning_stepper.DRIVER, STEP_PIN_M1, DIR_PIN_M1);
|
||||
AccelStepper matching_stepper = AccelStepper(matching_stepper.DRIVER, STEP_PIN_M2, DIR_PIN_M2);
|
||||
|
||||
Stepper tuner = {tuning_stepper, tuning_driver, DIAG1_PIN_M1, TUNING_STEPPER_HOME};
|
||||
Stepper tuner = {tuning_stepper, tuning_driver, DIAG1_PIN_M1, "Tuner"};
|
||||
|
||||
Stepper matcher = {matching_stepper, matching_driver, DIAG1_PIN_M2, MATCHING_STEPPER_HOME};
|
||||
Stepper matcher = {matching_stepper, matching_driver, DIAG1_PIN_M2, "Matcher"};
|
||||
|
||||
boolean homed = false;
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
@ -85,6 +87,12 @@ void setup()
|
|||
adf4351.setrf(25000000U);
|
||||
adf4351.pwrlevel = 2; // This equals -4dBm*/
|
||||
adf4351.setf(START_FREQUENCY);
|
||||
|
||||
pinMode(FILTER_SWITCH_A, OUTPUT);
|
||||
pinMode(FILTER_SWITCH_B, OUTPUT);
|
||||
|
||||
digitalWrite(FILTER_SWITCH_A, LOW);
|
||||
digitalWrite(FILTER_SWITCH_B, LOW);
|
||||
}
|
||||
|
||||
// Implement Serial communication ...
|
||||
|
@ -163,6 +171,9 @@ void loop()
|
|||
Serial.println("Homing...");
|
||||
homeStepper(tuner);
|
||||
homeStepper(matcher);
|
||||
homed = true;
|
||||
changeFrequencyRange(HOME_RANGE);
|
||||
|
||||
Serial.println("Resonance frequency after homing:");
|
||||
uint32_t resonance_frequency = findCurrentResonanceFrequency(START_FREQUENCY, STOP_FREQUENCY, FREQUENCY_STEP);
|
||||
Serial.println(resonance_frequency);
|
||||
|
@ -302,8 +313,6 @@ void homeStepper(Stepper stepper)
|
|||
stepper.STEPPER.setAcceleration(12000);
|
||||
|
||||
stepper.STEPPER.setCurrentPosition(0);
|
||||
stepper.STEPPER.moveTo(stepper.HOME_POSITION);
|
||||
stepper.STEPPER.runToPosition();
|
||||
}
|
||||
|
||||
int stallStepper(Stepper stepper)
|
||||
|
@ -322,6 +331,21 @@ int stallStepper(Stepper stepper)
|
|||
return stepper.STEPPER.currentPosition(); // returns value until limit is reached
|
||||
}
|
||||
|
||||
// This function changes the filterbank settings for the selected target range
|
||||
// and drives the tuner and matcher stepper to the center of the selected frequency range
|
||||
void changeFrequencyRange(FrequencyRange target_range)
|
||||
{
|
||||
digitalWrite(FILTER_SWITCH_A, target_range.FILTER.control_input_a);
|
||||
digitalWrite(FILTER_SWITCH_B, target_range.FILTER.control_input_b);
|
||||
|
||||
tuner.STEPPER.moveTo(target_range.TUNING_CENTER_POSITION);
|
||||
tuner.STEPPER.runToPosition();
|
||||
|
||||
matcher.STEPPER.moveTo(target_range.TUNING_CENTER_POSITION);
|
||||
matcher.STEPPER.runToPosition();
|
||||
|
||||
}
|
||||
|
||||
uint32_t automaticTM(uint32_t target_frequency)
|
||||
{
|
||||
uint32_t resonance_frequency = findCurrentResonanceFrequency(START_FREQUENCY, STOP_FREQUENCY, FREQUENCY_STEP);
|
||||
|
|
Loading…
Reference in a new issue