output amplitude unlevel check in VNA mode

This commit is contained in:
Jan Käberich 2021-08-13 21:44:12 +02:00
parent 6bb22b5e43
commit 220fa208e9
2 changed files with 13 additions and 1 deletions

View File

@ -307,7 +307,7 @@ void HW::fillDeviceInfo(Protocol::DeviceInfo *info, bool updateEvenWhenBusy) {
LOG_INFO("ADC limits: P1: %d/%d P2: %d/%d R: %d/%d", LOG_INFO("ADC limits: P1: %d/%d P2: %d/%d R: %d/%d",
limits.P1min, limits.P1max, limits.P2min, limits.P2max, limits.P1min, limits.P1max, limits.P2min, limits.P2max,
limits.Rmin, limits.Rmax); limits.Rmin, limits.Rmax);
#define ADC_LIMIT 30000 #define ADC_LIMIT 27000
if(limits.P1min < -ADC_LIMIT || limits.P1max > ADC_LIMIT if(limits.P1min < -ADC_LIMIT || limits.P1max > ADC_LIMIT
|| limits.P2min < -ADC_LIMIT || limits.P2max > ADC_LIMIT || limits.P2min < -ADC_LIMIT || limits.P2max > ADC_LIMIT
|| limits.Rmin < -ADC_LIMIT || limits.Rmax > ADC_LIMIT) { || limits.Rmin < -ADC_LIMIT || limits.Rmax > ADC_LIMIT) {

View File

@ -76,6 +76,8 @@ bool VNA::Setup(Protocol::SweepSettings s) {
// has to be one less than actual number of samples // has to be one less than actual number of samples
FPGA::SetSamplesPerPoint(samplesPerPoint); FPGA::SetSamplesPerPoint(samplesPerPoint);
// reset unlevel flag if it was set from a previous sweep/mode
HW::SetOutputUnlevel(false);
// Start with average level // Start with average level
auto cdbm = (s.cdbm_excitation_start + s.cdbm_excitation_stop) / 2; auto cdbm = (s.cdbm_excitation_start + s.cdbm_excitation_stop) / 2;
// correct for port 1, assumes port 2 is identical // correct for port 1, assumes port 2 is identical
@ -85,12 +87,18 @@ bool VNA::Setup(Protocol::SweepSettings s) {
centerFreq = HW::BandSwitchFrequency; centerFreq = HW::BandSwitchFrequency;
} }
auto amplitude = HW::GetAmplitudeSettings(cdbm, centerFreq, true, false); auto amplitude = HW::GetAmplitudeSettings(cdbm, centerFreq, true, false);
if(amplitude.unlevel) {
HW::SetOutputUnlevel(true);
}
uint8_t fixedAttenuatorHighband = amplitude.attenuator; uint8_t fixedAttenuatorHighband = amplitude.attenuator;
Source.SetPowerOutA(amplitude.highBandPower, true); Source.SetPowerOutA(amplitude.highBandPower, true);
// amplitude calculation for lowband // amplitude calculation for lowband
amplitude = HW::GetAmplitudeSettings(cdbm, HW::BandSwitchFrequency / 2, true, false); amplitude = HW::GetAmplitudeSettings(cdbm, HW::BandSwitchFrequency / 2, true, false);
if(amplitude.unlevel) {
HW::SetOutputUnlevel(true);
}
uint8_t fixedAttenuatorLowband = amplitude.attenuator; uint8_t fixedAttenuatorLowband = amplitude.attenuator;
fixedPowerLowband = amplitude.lowBandPower; fixedPowerLowband = amplitude.lowBandPower;
@ -212,6 +220,9 @@ bool VNA::Setup(Protocol::SweepSettings s) {
if(freq >= HW::BandSwitchFrequency) { if(freq >= HW::BandSwitchFrequency) {
Source.SetPowerOutA(amplitude.highBandPower, true); Source.SetPowerOutA(amplitude.highBandPower, true);
} }
if(amplitude.unlevel) {
HW::SetOutputUnlevel(true);
}
attenuator = amplitude.attenuator; attenuator = amplitude.attenuator;
} }
@ -319,6 +330,7 @@ void VNA::Work() {
packet.type = Protocol::PacketType::DeviceInfo; packet.type = Protocol::PacketType::DeviceInfo;
HW::fillDeviceInfo(&packet.info, true); HW::fillDeviceInfo(&packet.info, true);
Communication::Send(packet); Communication::Send(packet);
// do not reset unlevel flag here, as it is calculated only once at the setup of the sweep
// Start next sweep // Start next sweep
FPGA::StartSweep(); FPGA::StartSweep();
} }