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,7 +19,7 @@ struct FrequencyRange
|
||||||
const Filter FG_71MHZ = {71000000U, LOW, LOW};
|
const Filter FG_71MHZ = {71000000U, LOW, LOW};
|
||||||
const Filter FG_120MHZ = {120000000U, LOW, HIGH};
|
const Filter FG_120MHZ = {120000000U, LOW, HIGH};
|
||||||
const Filter FG_180MHZ = {180000000U, HIGH, LOW};
|
const Filter FG_180MHZ = {180000000U, HIGH, LOW};
|
||||||
const Filter FG_260MHZ = {260000000U, HIGH, LOW};
|
const Filter FG_260MHZ = {260000000U, HIGH, HIGH};
|
||||||
|
|
||||||
// All fitlers
|
// All fitlers
|
||||||
const Filter FILTERS[] = {FG_71MHZ, FG_120MHZ, FG_180MHZ, FG_260MHZ};
|
const Filter FILTERS[] = {FG_71MHZ, FG_120MHZ, FG_180MHZ, FG_260MHZ};
|
||||||
|
|
|
@ -108,7 +108,7 @@ void setup()
|
||||||
adf4351.begin();
|
adf4351.begin();
|
||||||
|
|
||||||
adf4351.setrf(25000000U);
|
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);
|
adf4351.setf(START_FREQUENCY);
|
||||||
|
|
||||||
// Setup for the RF Switch for the filterbank
|
// Setup for the RF Switch for the filterbank
|
||||||
|
|
|
@ -3,9 +3,8 @@
|
||||||
|
|
||||||
void VoltageSweep::execute(String input_line)
|
void VoltageSweep::execute(String input_line)
|
||||||
{
|
{
|
||||||
int AVERAGES = 4;
|
|
||||||
float VOLTAGE_STEP = 0.1;
|
|
||||||
float MAX_VOLTAGE = 5.0;
|
float MAX_VOLTAGE = 5.0;
|
||||||
|
float MIN_VOLTAGE = 0.0;
|
||||||
|
|
||||||
// First we get the frequency where the voltage sweep should be performed
|
// First we get the frequency where the voltage sweep should be performed
|
||||||
float frequency_MHz = input_line.substring(1).toFloat();
|
float frequency_MHz = input_line.substring(1).toFloat();
|
||||||
|
@ -16,19 +15,40 @@ void VoltageSweep::execute(String input_line)
|
||||||
return;
|
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);
|
setFrequency(frequency);
|
||||||
|
|
||||||
// Now we can perform the 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
|
||||||
printInfo("Started voltage sweep");
|
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
|
// We want to maximize the reflection value, so we start with zero
|
||||||
float_t minimum_reflection = 0.0;
|
float_t minimum_reflection = 0.0;
|
||||||
|
|
||||||
// This bruteforces the optimum voltage for tuning and matching.
|
// 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
|
// Set the tuning and matching voltage
|
||||||
adac.write_DAC(VM, c_matching_voltage);
|
adac.write_DAC(VM, c_matching_voltage);
|
||||||
|
@ -44,9 +64,9 @@ void VoltageSweep::execute(String input_line)
|
||||||
tuning_voltage = c_tuning_voltage;
|
tuning_voltage = c_tuning_voltage;
|
||||||
matching_voltage = c_matching_voltage;
|
matching_voltage = c_matching_voltage;
|
||||||
// If the returnloss is better than 14dB, we can stop the voltage sweep
|
// If the returnloss is better than 14dB, we can stop the voltage sweep
|
||||||
float_t reflection_db = (reflection - 900) / 30.0;
|
// float_t reflection_db = (reflection - 900) / 30.0;
|
||||||
if (reflection_db > 14)
|
// if (reflection_db > 14)
|
||||||
return;
|
// return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ public:
|
||||||
void printHelp() override;
|
void printHelp() override;
|
||||||
|
|
||||||
private:
|
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 matching_voltage;
|
||||||
float_t tuning_voltage;
|
float_t tuning_voltage;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue