mirror of
https://github.com/nqrduck/ATM.git
synced 2024-11-25 19:42:30 +00:00
Improved voltage sweep.
This commit is contained in:
parent
1cb7a66f1d
commit
155921a0e1
4 changed files with 37 additions and 16 deletions
|
@ -19,14 +19,14 @@ struct FrequencyRange
|
|||
const Filter FG_71MHZ = {71000000U, LOW, LOW};
|
||||
const Filter FG_120MHZ = {120000000U, LOW, HIGH};
|
||||
const Filter FG_180MHZ = {180000000U, HIGH, LOW};
|
||||
const Filter FG_260MHZ = {260000000U, HIGH, LOW};
|
||||
const Filter FG_260MHZ = {260000000U, HIGH, HIGH};
|
||||
|
||||
// All fitlers
|
||||
const Filter FILTERS[] = {FG_71MHZ, FG_120MHZ, FG_180MHZ, FG_260MHZ};
|
||||
|
||||
// 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_35_70MHZ =
|
||||
{
|
||||
35000000U,
|
||||
|
@ -60,5 +60,5 @@ const FrequencyRange RANGE_125_180MHZ =
|
|||
const FrequencyRange HOME_RANGE = RANGE_70_125MHZ;
|
||||
|
||||
// Settings for 125MHz -30dB
|
||||
//#define TUNING_STEPPER_HOME 37550U
|
||||
//#define MATCHING_STEPPER_HOME 29500U
|
||||
// #define TUNING_STEPPER_HOME 37550U
|
||||
// #define MATCHING_STEPPER_HOME 29500U
|
|
@ -108,7 +108,7 @@ void setup()
|
|||
adf4351.begin();
|
||||
|
||||
adf4351.setrf(25000000U);
|
||||
adf4351.pwrlevel = 2; // This equals -4dBm*/ For the electrical probe coils one should use at least -20dbm so an attenuator is necessary
|
||||
adf4351.pwrlevel = 2; // This equals 2dBm*/ For the electrical probe coils one should use at least -20dbm so an attenuator is necessary
|
||||
adf4351.setf(START_FREQUENCY);
|
||||
|
||||
// Setup for the RF Switch for the filterbank
|
||||
|
|
|
@ -3,9 +3,8 @@
|
|||
|
||||
void VoltageSweep::execute(String input_line)
|
||||
{
|
||||
int AVERAGES = 4;
|
||||
float VOLTAGE_STEP = 0.1;
|
||||
float MAX_VOLTAGE = 5.0;
|
||||
float MIN_VOLTAGE = 0.0;
|
||||
|
||||
// First we get the frequency where the voltage sweep should be performed
|
||||
float frequency_MHz = input_line.substring(1).toFloat();
|
||||
|
@ -16,19 +15,40 @@ void VoltageSweep::execute(String input_line)
|
|||
return;
|
||||
}
|
||||
|
||||
// First set the frequency
|
||||
// First set the frequency 2 MHz below the target frequency
|
||||
uint32_t distance = 2000000;
|
||||
setFrequency(frequency - distance);
|
||||
|
||||
// Then we perform a rough voltage sweep with a step size of 1V
|
||||
sweepVoltages(1, MIN_VOLTAGE, MAX_VOLTAGE, MIN_VOLTAGE, MAX_VOLTAGE);
|
||||
|
||||
// Now we set the target frequency
|
||||
setFrequency(frequency);
|
||||
|
||||
// Now we can perform the voltage sweep
|
||||
printInfo("Started voltage sweep");
|
||||
// Then we perform a more precise voltage sweep with a step size of 0.1V but only in the region of the found voltages
|
||||
float_t tuning_range = 0.5;
|
||||
sweepVoltages(0.05, tuning_voltage - tuning_range, tuning_voltage + tuning_range, MIN_VOLTAGE, MAX_VOLTAGE);
|
||||
|
||||
// Then we perform a last very precise voltage sweep with a step size of 0.01V but only in the region of the found voltages
|
||||
tuning_range = 0.1;
|
||||
float_t matching_range = 0.2;
|
||||
sweepVoltages(0.01, tuning_voltage - tuning_range, tuning_voltage + tuning_range, matching_voltage - matching_range, matching_voltage + matching_range);
|
||||
|
||||
// Finally we set the found voltages
|
||||
adac.write_DAC(VM, matching_voltage);
|
||||
adac.write_DAC(VT, tuning_voltage);
|
||||
}
|
||||
|
||||
void VoltageSweep::sweepVoltages(float_t voltage_step, float_t tuning_start, float_t tuning_stop, float_t matching_start, float_t matching_stop)
|
||||
{
|
||||
int AVERAGES = 4;
|
||||
// We want to maximize the reflection value, so we start with zero
|
||||
float_t minimum_reflection = 0.0;
|
||||
|
||||
// This bruteforces the optimum voltage for tuning and matching.
|
||||
for (float_t c_tuning_voltage = 0.0; c_tuning_voltage <= MAX_VOLTAGE; c_tuning_voltage += VOLTAGE_STEP)
|
||||
for (float_t c_tuning_voltage = tuning_start; c_tuning_voltage <= tuning_stop; c_tuning_voltage += voltage_step)
|
||||
{
|
||||
for (float_t c_matching_voltage = 0.0; c_matching_voltage <= MAX_VOLTAGE; c_matching_voltage += VOLTAGE_STEP)
|
||||
for (float_t c_matching_voltage = matching_start; c_matching_voltage <= matching_stop; c_matching_voltage += voltage_step)
|
||||
{
|
||||
// Set the tuning and matching voltage
|
||||
adac.write_DAC(VM, c_matching_voltage);
|
||||
|
@ -44,9 +64,9 @@ void VoltageSweep::execute(String input_line)
|
|||
tuning_voltage = c_tuning_voltage;
|
||||
matching_voltage = c_matching_voltage;
|
||||
// If the returnloss is better than 14dB, we can stop the voltage sweep
|
||||
float_t reflection_db = (reflection - 900) / 30.0;
|
||||
if (reflection_db > 14)
|
||||
return;
|
||||
// float_t reflection_db = (reflection - 900) / 30.0;
|
||||
// if (reflection_db > 14)
|
||||
// return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ public:
|
|||
void printHelp() override;
|
||||
|
||||
private:
|
||||
void sweepVoltages(float_t voltage_step, float_t tuning_start, float_t tuning_stop, float_t matching_start, float_t matching_stop);
|
||||
float_t matching_voltage;
|
||||
float_t tuning_voltage;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue