Skip to content

Commit

Permalink
SiglentSCPIOscilloscope: SetADCMode: move :WAV:WIDTH command and quer…
Browse files Browse the repository at this point in the history
…y trigger mode for delays

This shifts the :WAV:WIDTH command after stopping trigger and replaces
thread sleep with a query command. Inserting query commands seems to
work more reliably under slow/unstable network connection scenarios.
  • Loading branch information
hansemro committed Nov 21, 2023
1 parent 10899c0 commit 01e9da9
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions scopehal/SiglentSCPIOscilloscope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ static const struct
} c_sds2000xp_threshold_table[] = {{"TTL", 1.5F}, {"CMOS", 1.65F}, {"LVCMOS33", 1.65F}, {"LVCMOS25", 1.25F}, {NULL, 0}};

static const std::chrono::milliseconds c_trigger_delay(1000); // Delay required when forcing trigger
static const std::chrono::milliseconds c_adc_delay(200); // Delay required when setting ADC mode
static const char* c_custom_thresh = "CUSTOM,"; // Prepend string for custom digital threshold
static const float c_thresh_thresh = 0.01f; // Zero equivalence threshold for fp comparisons

Expand Down Expand Up @@ -3288,25 +3287,36 @@ void SiglentSCPIOscilloscope::SetADCMode(size_t /*channel*/, size_t mode)
if(!m_triggerArmed)
m_transport->SendCommandQueued("TRIG_MODE AUTO");

//Send the actual command
//Query used as a flush and delay mechanism
m_transport->SendCommandQueuedWithReply("TRIG_MODE?");

if(mode == ADC_MODE_10BIT)
{
m_transport->SendCommandQueued("ACQ:RES 10Bits");
this_thread::sleep_for(c_adc_delay);
m_transport->SendCommandQueued(":WAVEFORM:WIDTH WORD");
}
else //if(mode == ADC_MODE_8BIT)
{
m_transport->SendCommandQueued("ACQ:RES 8Bits");
this_thread::sleep_for(c_adc_delay);
m_transport->SendCommandQueued(":WAVEFORM:WIDTH BYTE");
}
this_thread::sleep_for(c_adc_delay);

//Re-arm trigger if previously armed
if(IsTriggerArmed())
m_transport->SendCommandQueued("TRIG_MODE SINGLE");
else
m_transport->SendCommandQueued("TRIG_MODE STOP");

//Query used as a flush and delay mechanism
m_transport->SendCommandQueuedWithReply("TRIG_MODE?");

//Set waveform data width
if(mode == ADC_MODE_10BIT)
{
m_transport->SendCommandQueued(":WAVEFORM:WIDTH WORD");
}
else //if(mode == ADC_MODE_8BIT)
{
m_transport->SendCommandQueued(":WAVEFORM:WIDTH BYTE");
}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 01e9da9

Please sign in to comment.