Merge pull request #182 from andredunford/sweep_standby

implement sweep standby operation
This commit is contained in:
jankae 2022-12-21 08:29:27 +01:00 committed by GitHub
commit d022f944c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 71 additions and 7 deletions

View File

@ -250,6 +250,7 @@ The following packet types are available:
29 & ClearTrigger & D$\leftrightarrow$H & Updates the trigger status for synchronization over USB & None\\
30 & StopStatusUpdates & H$\rightarrow$D & Stops the automatic transmission of device status packets & None\\
31 & StartStatusUpdates & H$\rightarrow$D & Starts the automatic transmission of device status packets & None\\
32 & InitiateSweep & H$\rightarrow$D & Initiates a single sweep when configured for standby operation & None\\
\end{longtable}
\end{ThreePartTable}
An Ack is transmitted by the device for every received command after it has been handled successfully. If additional responses are triggered by the command, they are transmitted after this Ack.
@ -299,7 +300,7 @@ The packet contains the following fields:
\rwbits{12}{1}{FP}
\rwbits{13}{1}{SP}
\rwbits{14}{1}{SM}
\robits{15}{1}{}
\rwbits{15}{1}{SO}
\end{tikzpicture}
\end{center}
\begin{itemize}
@ -337,6 +338,15 @@ Setting & Behavior\\
\end{tabularx}
\end{center}
\item \textbf{SM:} Sync Master. Must be set to 1 at exactly one device when multiple devices are synchronized. Set to 0 when synchronization is disabled.
\item \textbf{SO:} Standby Operation. Indicates whether the VNA will begin sweep immediately, or wait in the configured state to be triggered manually by InitiateSweep packets. Standy operation allows for lower latency of intermittent single sweeps.
\begin{center}
\begin{tabularx}{\textwidth}{ c|X }
Setting & Behavior\\
\hline
0 & VNA will begin sweep immediately and timeout to idle mode 1000ms after sweep is completed or 100ms after entering the halted state. \\
1 & VNA will wait in a configured state for InitiateSweep packets. The host application is responsible for putting the VNA into idle mode with a SetIdle packet.\\
\end{tabularx}
\end{center}
\end{itemize}
\subsection{ManualStatusV1}
@ -1018,4 +1028,7 @@ This packet instructs the device to stop sending automatically scheduled DeviceS
\subsection{StartStatusUpdates}
This packet instructs the device to start sending automatically scheduled DeviceStatusV1 packets. This restores default update behaviour if a StopStatusUpdates packet has previously been sent.
\subsection{InitiateSweep}
This packet instructs the device to initiate a new single sweep when the VNA is configured for standby operation. This triggering method can be used for fast intermittent single sweeps with minimum latency. If the SweepSettings are not configured for standby operation, this packet will result in a Nack response.
\end{document}

View File

@ -181,6 +181,16 @@ inline void App_Process() {
case Protocol::PacketType::StartStatusUpdates: {
HW::setStatusUpdateFlag(true);
Communication::SendWithoutPayload(Protocol::PacketType::Ack);
}
break;
case Protocol::PacketType::InitiateSweep: {
if(VNA::GetStandbyMode()) {
VNA::InitiateSweep();
Communication::SendWithoutPayload(Protocol::PacketType::Ack);
} else {
Communication::SendWithoutPayload(Protocol::PacketType::Nack);
}
}
break;
case Protocol::PacketType::SetIdle:

View File

@ -125,6 +125,7 @@ uint16_t Protocol::EncodePacket(const PacketInfo &packet, uint8_t *dest, uint16_
case PacketType::ClearTrigger:
case PacketType::StopStatusUpdates:
case PacketType::StartStatusUpdates:
case PacketType::InitiateSweep:
// no payload
break;
case PacketType::VNADatapoint: payload_size = packet.VNAdatapoint->requiredBufferSize(); break;

View File

@ -159,7 +159,7 @@ using SweepSettings = struct _sweepSettings {
uint16_t points;
uint32_t if_bandwidth;
int16_t cdbm_excitation_start; // in 1/100 dbm
uint16_t unused:1;
uint16_t standby:1;
uint16_t syncMaster:1;
uint16_t suppressPeaks:1;
uint16_t fixedPowerSetting:1; // if set the attenuator and source PLL power will not be changed across the sweep
@ -366,6 +366,7 @@ enum class PacketType : uint8_t {
ClearTrigger = 29,
StopStatusUpdates = 30,
StartStatusUpdates = 31,
InitiateSweep = 32
};
using PacketInfo = struct _packetinfo {

View File

@ -250,6 +250,8 @@ void HW::SetIdle() {
FPGA::Enable(FPGA::Periphery::RefMixer, false);
FPGA::Enable(FPGA::Periphery::PortSwitch, false);
activeMode = Mode::Idle;
VNA::SetWaitingInStandby(false);
}
HW::AmplitudeSettings HW::GetAmplitudeSettings(int16_t cdbm, uint64_t freq, bool applyCorrections, bool port2) {
@ -303,7 +305,7 @@ bool HW::TimedOut() {
auto bufISR = lastISR;
uint64_t now = Delay::get_us();
uint64_t timeSinceLast = now - bufISR;
if(activeMode != Mode::Idle && activeMode != Mode::Generator && timeSinceLast > timeout) {
if(activeMode != Mode::Idle && activeMode != Mode::Generator && !VNA::IsWaitingInStandby() && timeSinceLast > timeout) {
LOG_WARN("Timed out, last ISR was at %lu%06lu, now %lu%06lu"
, (uint32_t) (bufISR / 1000000), (uint32_t)(bufISR%1000000)
, (uint32_t) (now / 1000000), (uint32_t)(now%1000000));

View File

@ -27,6 +27,7 @@ static uint32_t last_LO2;
static double logMultiplier, logFrequency;
static Protocol::VNADatapoint<32> data;
static bool active = false;
static bool waitingInStandby = false;
static Si5351C::DriveStrength fixedPowerLowband;
static bool adcShifted;
static uint32_t actualBandwidth;
@ -258,12 +259,38 @@ bool VNA::Setup(Protocol::SweepSettings s) {
// Enable new data and sweep halt interrupt
FPGA::EnableInterrupt(FPGA::Interrupt::NewData);
FPGA::EnableInterrupt(FPGA::Interrupt::SweepHalted);
// Start the sweep
// Start the sweep if not configured for standby
firstPoint = true;
FPGA::StartSweep();
if (settings.standby) {
waitingInStandby = true;
}
else {
FPGA::StartSweep();
}
return true;
}
void VNA::InitiateSweep() {
// Invoked by a host via InitiateSweep packet
if(waitingInStandby){
// make sure that SweepSettings have been configured for standby operation
FPGA::StartSweep();
waitingInStandby = false;
}
}
bool VNA::GetStandbyMode() {
return settings.standby;
}
bool VNA::IsWaitingInStandby() {
return waitingInStandby;
}
void VNA::SetWaitingInStandby(bool waiting) {
waitingInStandby = waiting;
}
static void PassOnData() {
Protocol::PacketInfo info;
info.type = Protocol::PacketType::VNADatapoint;
@ -330,8 +357,14 @@ void VNA::Work() {
Communication::Send(packet);
}
// do not reset unlevel flag here, as it is calculated only once at the setup of the sweep
// Start next sweep
FPGA::StartSweep();
// Start next sweep if not configured for standby
if (settings.standby) {
waitingInStandby = true;
}
else {
FPGA::StartSweep();
}
}
void VNA::SweepHalted() {

View File

@ -7,6 +7,10 @@
namespace VNA {
bool Setup(Protocol::SweepSettings s);
void InitiateSweep();
bool GetStandbyMode();
bool IsWaitingInStandby();
void SetWaitingInStandby(bool waiting);
bool MeasurementDone(const FPGA::SamplingResult &result);
void Work();
void SweepHalted();