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: e961df4026f1
Choose a base ref
...
head repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 17ba6a9956ac
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on Jul 31, 2020

  1. DeEmbedDecoder: fixed truncation of de-embedded waveforms, allowed vi…

    …ewport to be rescaled to actual waveform bounds in case S-parameters have significant gain/loss
    azonenberg committed Jul 31, 2020
    Copy the full SHA
    17ba6a9 View commit details
Showing with 35 additions and 6 deletions.
  1. +28 −6 scopeprotocols/DeEmbedDecoder.cpp
  2. +7 −0 scopeprotocols/DeEmbedDecoder.h
34 changes: 28 additions & 6 deletions scopeprotocols/DeEmbedDecoder.cpp
Original file line number Diff line number Diff line change
@@ -47,6 +47,11 @@ DeEmbedDecoder::DeEmbedDecoder(string color)
m_parameters[m_fname] = ProtocolDecoderParameter(ProtocolDecoderParameter::TYPE_FILENAMES);
m_parameters[m_fname].m_fileFilterMask = "*.s2p";
m_parameters[m_fname].m_fileFilterName = "Touchstone S-parameter files (*.s2p)";

m_range = 1;
m_offset = 0;
m_min = FLT_MAX;
m_max = -FLT_MAX;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -64,12 +69,12 @@ bool DeEmbedDecoder::ValidateChannel(size_t i, OscilloscopeChannel* channel)

double DeEmbedDecoder::GetVoltageRange()
{
return m_channels[0]->GetVoltageRange();
return m_range;
}

double DeEmbedDecoder::GetOffset()
{
return m_channels[0]->GetOffset();
return m_offset;
}

string DeEmbedDecoder::GetProtocolName()
@@ -121,6 +126,14 @@ void DeEmbedDecoder::Refresh()
DoRefresh(true);
}

void DeEmbedDecoder::ClearSweeps()
{
m_range = 1;
m_offset = 0;
m_min = FLT_MAX;
m_max = -FLT_MAX;
}

/**
@brief Applies the S-parameters in the forward or reverse direction
*/
@@ -286,16 +299,25 @@ void DeEmbedDecoder::DoRefresh(bool invert)
cap->m_timescale = din->m_timescale;

//Copy waveform data after rescaling
//We seem to have problems with the first and last few points, not sure why!
//For now, just skip them.
float scale = 1.0f / npoints;
for(size_t i=512; i<npoints - 512; i++)
float vmin = FLT_MAX;
float vmax = -FLT_MAX;
for(size_t i=0; i<npoints; i++)
{
cap->m_offsets.push_back(din->m_offsets[i]);
cap->m_durations.push_back(din->m_durations[i]);
cap->m_samples.push_back(ddout[i] * scale);
float v = ddout[i] * scale;
vmin = min(v, vmin);
vmax = max(v, vmax);
cap->m_samples.push_back(v);
}

//Calculate bounds
m_max = max(m_max, vmax);
m_min = min(m_min, vmin);
m_range = (m_max - m_min) * 1.05;
m_offset = -( (m_max - m_min)/2 + m_min );

SetData(cap);

//Clean up
7 changes: 7 additions & 0 deletions scopeprotocols/DeEmbedDecoder.h
Original file line number Diff line number Diff line change
@@ -54,6 +54,8 @@ class DeEmbedDecoder : public ProtocolDecoder
virtual double GetOffset();
virtual bool ValidateChannel(size_t i, OscilloscopeChannel* channel);

virtual void ClearSweeps();

PROTOCOL_DECODER_INITPROC(DeEmbedDecoder)

void DoRefresh(bool invert = true);
@@ -63,6 +65,11 @@ class DeEmbedDecoder : public ProtocolDecoder

std::vector<std::string> m_cachedFileNames;

float m_min;
float m_max;
float m_range;
float m_offset;

TouchstoneParser m_sparams;
};