Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c9a6997fccce
Choose a base ref
...
head repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7073816b1703
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Sep 25, 2020

  1. TektronixOscilloscope: implemented setting sample rate and depth. Fix…

    …ed some errors in sample rate table. See #13.
    azonenberg committed Sep 25, 2020

    Verified

    This commit was signed with the committer’s verified signature.
    makenowjust Hiroya Fujinami
    Copy the full SHA
    cf73c5a View commit details
  2. Copy the full SHA
    7073816 View commit details
Showing with 62 additions and 26 deletions.
  1. +56 −14 scopehal/TektronixOscilloscope.cpp
  2. +6 −12 scopehal/Unit.cpp
70 changes: 56 additions & 14 deletions scopehal/TektronixOscilloscope.cpp
Original file line number Diff line number Diff line change
@@ -76,14 +76,14 @@ TektronixOscilloscope::TektronixOscilloscope(SCPITransport* transport)
{
case FAMILY_MSO5:
case FAMILY_MSO6:
m_transport->SendCommand("ACQ:MOD SAM"); //actual sampled data, no averaging etc
m_transport->SendCommand("VERB OFF"); //Disable verbose mode (send shorter commands)
m_transport->SendCommand("DAT:ENC SRI"); //signed, little endian binary
m_transport->SendCommand("DAT:WID 2"); //16-bit data
m_transport->SendCommand("ACQ:STOPA SEQ"); //Stop after acquiring a single waveform
m_transport->SendCommand("CONFIG:ANALO:BANDW?");
m_bandwidth = stof(m_transport->ReadReply()) * 1e-6;
LogDebug("Instrument has %d MHz bandwidth\n", m_bandwidth);
m_transport->SendCommand("ACQ:MOD SAM"); //actual sampled data, no averaging etc
m_transport->SendCommand("VERB OFF"); //Disable verbose mode (send shorter commands)
m_transport->SendCommand("DAT:ENC SRI"); //signed, little endian binary
m_transport->SendCommand("DAT:WID 2"); //16-bit data
m_transport->SendCommand("ACQ:STOPA SEQ"); //Stop after acquiring a single waveform
m_transport->SendCommand("CONFIG:ANALO:BANDW?"); //Figure out what bandwidth we have
m_bandwidth = stof(m_transport->ReadReply()) * 1e-6; //(so we know what probe bandwidth is)
m_transport->SendCommand("HOR:MODE MAN"); //Enable manual sample rate and record length
break;

default:
@@ -1066,6 +1066,10 @@ vector<uint64_t> TektronixOscilloscope::GetSampleRatesNonInterleaved()
}

//We break with the pattern on the upper end of the frequency range
ret.push_back(12500 * k);
ret.push_back(25 * m);
ret.push_back(31250 * k);
ret.push_back(62500 * k);
ret.push_back(125 * m);
ret.push_back(250 * m);
ret.push_back(312500 * k);
@@ -1178,7 +1182,7 @@ uint64_t TektronixOscilloscope::GetSampleRate()
{
case FAMILY_MSO5:
case FAMILY_MSO6:
m_transport->SendCommand("HOR:SAMPLER?");
m_transport->SendCommand("HOR:MODE:SAMPLER?");
m_sampleRate = stod(m_transport->ReadReply()); //stoull seems to not handle scientific notation
break;

@@ -1201,7 +1205,7 @@ uint64_t TektronixOscilloscope::GetSampleDepth()
{
case FAMILY_MSO5:
case FAMILY_MSO6:
m_transport->SendCommand("HOR:RECO?");
m_transport->SendCommand("HOR:MODE:RECO?");
m_sampleDepth = stos(m_transport->ReadReply());
break;

@@ -1213,14 +1217,52 @@ uint64_t TektronixOscilloscope::GetSampleDepth()
return m_sampleDepth;
}

void TektronixOscilloscope::SetSampleDepth(uint64_t /*depth*/)
void TektronixOscilloscope::SetSampleDepth(uint64_t depth)
{
//FIXME
//Update the cache
{
lock_guard<recursive_mutex> lock(m_cacheMutex);
m_sampleDepth = depth;
m_sampleDepthValid = true;
}

//Send it
lock_guard<recursive_mutex> lock(m_mutex);

switch(m_family)
{
case FAMILY_MSO5:
case FAMILY_MSO6:
m_transport->SendCommand(string("HOR:MODE:RECO ") + to_string(depth));
break;

default:
break;
}
}

void TektronixOscilloscope::SetSampleRate(uint64_t /*rate*/)
void TektronixOscilloscope::SetSampleRate(uint64_t rate)
{
//FIXME
//Update the cache
{
lock_guard<recursive_mutex> lock(m_cacheMutex);
m_sampleRate = rate;
m_sampleRateValid = true;
}

//Send it
lock_guard<recursive_mutex> lock(m_mutex);

switch(m_family)
{
case FAMILY_MSO5:
case FAMILY_MSO6:
m_transport->SendCommand(string("HOR:MODE:SAMPLER ") + to_string(rate));
break;

default:
break;
}
}

void TektronixOscilloscope::SetTriggerOffset(int64_t /*offset*/)
18 changes: 6 additions & 12 deletions scopehal/Unit.cpp
Original file line number Diff line number Diff line change
@@ -187,35 +187,29 @@ string Unit::PrettyPrint(double value)
return "Invalid unit";
}

//TODO: allow user to specify how many sigfigs they want
char tmp[128];
switch(m_type)
{
case UNIT_LOG_BER: //special formatting for BER since it's already logarithmic
snprintf(tmp, sizeof(tmp), "1e%.0f", value);
break;

case UNIT_SAMPLERATE:
default:
{
//If sample rate isn't a round number, add more digits (up to 3)
//If not a round number, add more digits (up to 4)
//TODO: allow user to specify how many sigfigs they want
if( fabs(round(value_rescaled) - value_rescaled) < 0.1 )
snprintf(tmp, sizeof(tmp), "%.0f %s%s", value_rescaled, scale, unit);
else if(fabs(round(value_rescaled*10) - value_rescaled*10) < 0.1)
snprintf(tmp, sizeof(tmp), "%.1f %s%s", value_rescaled, scale, unit);
else if(fabs(round(value_rescaled*100) - value_rescaled*100) < 0.1 )
snprintf(tmp, sizeof(tmp), "%.2f %s%s", value_rescaled, scale, unit);
else
else if(fabs(round(value_rescaled*1000) - value_rescaled*1000) < 0.1 )
snprintf(tmp, sizeof(tmp), "%.3f %s%s", value_rescaled, scale, unit);
else
snprintf(tmp, sizeof(tmp), "%.4f %s%s", value_rescaled, scale, unit);
}
break;

case UNIT_SAMPLEDEPTH:
snprintf(tmp, sizeof(tmp), "%.0f %s%s", value_rescaled, scale, unit);
break;

default:
snprintf(tmp, sizeof(tmp), "%.4f %s%s", value_rescaled, scale, unit);
break;
}
return string(tmp);
}