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: e00767ee9839
Choose a base ref
...
head repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1b908228ec79
Choose a head ref
  • 3 commits
  • 5 files changed
  • 1 contributor

Commits on Oct 1, 2020

  1. Copy the full SHA
    1788668 View commit details
  2. Copy the full SHA
    759145f View commit details
  3. Copy the full SHA
    1b90822 View commit details
Showing with 199 additions and 5 deletions.
  1. +35 −0 scopehal/Oscilloscope.cpp
  2. +48 −1 scopehal/Oscilloscope.h
  3. +1 −1 scopehal/PeakDetectionFilter.cpp
  4. +104 −3 scopehal/TektronixOscilloscope.cpp
  5. +11 −0 scopehal/TektronixOscilloscope.h
35 changes: 35 additions & 0 deletions scopehal/Oscilloscope.cpp
Original file line number Diff line number Diff line change
@@ -448,3 +448,38 @@ vector<string> Oscilloscope::GetTriggerTypes()
ret.push_back(EdgeTrigger::GetTriggerName());
return ret;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Spectrum analyzer configuration (default no-op for scopes without SA feature)

void Oscilloscope::SetSpan(int64_t /*span*/)
{
}

int64_t Oscilloscope::GetSpan()
{
return 1;
}

void Oscilloscope::SetCenterFrequency(size_t /*channel*/, int64_t /*freq*/)
{
}

int64_t Oscilloscope::GetCenterFrequency(size_t /*channel*/)
{
return 0;
}

void Oscilloscope::SetResolutionBandwidth(int64_t /*freq*/)
{
}

int64_t Oscilloscope::GetResolutionBandwidth()
{
return 1;
}

bool Oscilloscope::HasFrequencyControls()
{
return false;
}
49 changes: 48 additions & 1 deletion scopehal/Oscilloscope.h
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ class Instrument;
#include "SCPITransport.h"

/**
@brief Generic representation of an oscilloscope or logic analyzer.
@brief Generic representation of an oscilloscope, logic analyzer, or spectrum analyzer.
An Oscilloscope contains triggering logic and one or more OscilloscopeChannel objects.
*/
@@ -526,6 +526,53 @@ class Oscilloscope : public virtual Instrument
*/
virtual void SetDigitalThreshold(size_t channel, float level);

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Frequency domain channel configuration

/**
@brief Sets the span for frequency-domain channels
@param span Span, in Hz
*/
virtual void SetSpan(int64_t span);

/**
@brief Gets the span for frequency-domain channels
*/
virtual int64_t GetSpan();

/**
@brief Sets the center frequency for frequency-domain channels
@param channel Channel number
@param freq Center frequency, in Hz
*/
virtual void SetCenterFrequency(size_t channel, int64_t freq);

/**
@brief Gets the center frequency for a frequency-domain channel
@param channel Channel number
*/
virtual int64_t GetCenterFrequency(size_t channel);

/**
@brief Gets the resolution bandwidth for frequency-domain channels
*/
virtual void SetResolutionBandwidth(int64_t rbw);

/**
@brief Gets the resolution bandwidth for frequency-domain channels
*/
virtual int64_t GetResolutionBandwidth();

/**
@brief Returns true if the instrument has at least one frequency-domain channel
*/
virtual bool HasFrequencyControls();

//TODO: window controls

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Configuration storage

2 changes: 1 addition & 1 deletion scopehal/PeakDetectionFilter.cpp
Original file line number Diff line number Diff line change
@@ -79,7 +79,7 @@ void PeakDetector::FindPeaks(AnalogWaveform* cap, int64_t max_peaks, float searc

//If the highest point in the search window is at our location, we're a peak
if(max_delta == 0)
peaks.push_back(Peak(i, max_value));
peaks.push_back(Peak(cap->m_offsets[i], max_value));
}

//Sort the peak table and pluck out the requested count
107 changes: 104 additions & 3 deletions scopehal/TektronixOscilloscope.cpp
Original file line number Diff line number Diff line change
@@ -86,6 +86,8 @@ TektronixOscilloscope::TektronixOscilloscope(SCPITransport* transport)
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
m_transport->SendCommand("HOR:DEL:MOD ON"); //Horizontal position is in time units
m_transport->SendCommand("SV:RBWMODE MAN"); //Manual resolution bandwidth control
m_transport->SendCommand("SV:LOCKCENTER 0"); //Allow separate center freq per channel
break;

default:
@@ -1244,6 +1246,7 @@ bool TektronixOscilloscope::AcquireDataMSO56(map<int, vector<WaveformBase*> >& p

//Process it
double hzbase = 0;
double hzoff = 0;
for(int j=0; j<22; j++)
{
string reply = m_transport->ReadReply();
@@ -1255,6 +1258,11 @@ bool TektronixOscilloscope::AcquireDataMSO56(map<int, vector<WaveformBase*> >& p
hzbase = round(stof(reply));
//LogDebug("xincrement = %s\n", Unit(Unit::UNIT_HZ).PrettyPrint(hzbase).c_str());
}
else if(j == 12)
{
hzoff = round(stof(reply));
//LogDebug("xzero = %s\n", Unit(Unit::UNIT_HZ).PrettyPrint(hzbase).c_str());
}
else if(j == 15)
{
ymult = stof(reply);
@@ -1266,8 +1274,6 @@ bool TektronixOscilloscope::AcquireDataMSO56(map<int, vector<WaveformBase*> >& p
m_channelOffsets[i] = -yoff;
//LogDebug("yoff = %s\n", Unit(Unit::UNIT_DBM).PrettyPrint(yoff).c_str());
}

//TODO: xzero is trigger time
}

//Read the data block
@@ -1302,9 +1308,10 @@ bool TektronixOscilloscope::AcquireDataMSO56(map<int, vector<WaveformBase*> >& p

//We get dBm from the instrument, so just have to convert double to single precision
//TODO: are other units possible here?
int64_t ibase = hzoff / hzbase;
for(size_t j=0; j<nsamples; j++)
{
cap->m_offsets[j] = j;
cap->m_offsets[j] = j + ibase;
cap->m_durations[j] = 1;
cap->m_samples[j] = ymult*samples[j] + yoff;
}
@@ -2098,3 +2105,97 @@ void TektronixOscilloscope::SetDigitalThreshold(size_t channel, float level)
break;
}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Spectrum analyzer configuration

bool TektronixOscilloscope::HasFrequencyControls()
{
switch(m_family)
{
case FAMILY_MSO5:
case FAMILY_MSO6:
return true;

default:
return false;
}
}

void TektronixOscilloscope::SetSpan(int64_t span)
{
lock_guard<recursive_mutex> lock(m_mutex);

switch(m_family)
{
case FAMILY_MSO5:
case FAMILY_MSO6:
m_transport->SendCommand(string("SV:SPAN ") + to_string(span));
break;

default:
break;
}
}

int64_t TektronixOscilloscope::GetSpan()
{
lock_guard<recursive_mutex> lock(m_mutex);

switch(m_family)
{
case FAMILY_MSO5:
case FAMILY_MSO6:
m_transport->SendCommand("SV:SPAN?");
return round(stod(m_transport->ReadReply()));

default:
return 1;
}
}

void TektronixOscilloscope::SetCenterFrequency(size_t channel, int64_t freq)
{
lock_guard<recursive_mutex> lock(m_mutex);

//CH1:SV:CENTERFREQUENCY 100.0000E+6;
}

int64_t TektronixOscilloscope::GetCenterFrequency(size_t channel)
{
lock_guard<recursive_mutex> lock(m_mutex);

return 1;
}

void TektronixOscilloscope::SetResolutionBandwidth(int64_t rbw)
{
lock_guard<recursive_mutex> lock(m_mutex);

switch(m_family)
{
case FAMILY_MSO5:
case FAMILY_MSO6:
m_transport->SendCommand(string("SV:RBW ") + to_string(rbw));
break;

default:
break;
}
}

int64_t TektronixOscilloscope::GetResolutionBandwidth()
{
lock_guard<recursive_mutex> lock(m_mutex);

switch(m_family)
{
case FAMILY_MSO5:
case FAMILY_MSO6:
m_transport->SendCommand("SV:RBW?");
return round(stod(m_transport->ReadReply()));

default:
return 1;
}
}
11 changes: 11 additions & 0 deletions scopehal/TektronixOscilloscope.h
Original file line number Diff line number Diff line change
@@ -120,6 +120,17 @@ class TektronixOscilloscope : public SCPIOscilloscope
virtual void SetDigitalHysteresis(size_t channel, float level);
virtual void SetDigitalThreshold(size_t channel, float level);

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Spectrum analyzer configuration

virtual bool HasFrequencyControls();
virtual void SetSpan(int64_t span);
virtual int64_t GetSpan();
virtual void SetCenterFrequency(size_t channel, int64_t freq);
virtual int64_t GetCenterFrequency(size_t channel);
virtual void SetResolutionBandwidth(int64_t rbw);
virtual int64_t GetResolutionBandwidth();

protected:
OscilloscopeChannel* m_extTrigChannel;