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

Commits on May 24, 2020

  1. Copy the full SHA
    46dcb36 View commit details
  2. Copy the full SHA
    429dd58 View commit details
  3. Copy the full SHA
    db4d095 View commit details
21 changes: 0 additions & 21 deletions scopemeasurements/CMakeLists.txt

This file was deleted.

50 changes: 0 additions & 50 deletions scopemeasurements/scopemeasurements.cpp

This file was deleted.

49 changes: 0 additions & 49 deletions scopemeasurements/scopemeasurements.h

This file was deleted.

3 changes: 3 additions & 0 deletions scopeprotocols/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -34,8 +34,10 @@ set(SCOPEPROTOCOLS_SOURCES
JtagDecoder.cpp
MDIODecoder.cpp
MovingAverageDecoder.cpp
OvershootMeasurementDecoder.cpp
ParallelBusDecoder.cpp
PeriodMeasurementDecoder.cpp
PkPkMeasurementDecoder.cpp
RiseMeasurementDecoder.cpp
SincInterpolationDecoder.cpp
SPIDecoder.cpp
@@ -44,6 +46,7 @@ set(SCOPEPROTOCOLS_SOURCES
TopMeasurementDecoder.cpp
UARTDecoder.cpp
UartClockRecoveryDecoder.cpp
UndershootMeasurementDecoder.cpp
USB2ActivityDecoder.cpp
USB2PacketDecoder.cpp
USB2PCSDecoder.cpp
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2019 Andrew D. Zonenberg *
* Copyright (c) 2012-2020 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
@@ -27,68 +27,163 @@
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Declaration of OvershootMeasurement
*/

#include "scopemeasurements.h"
#include "OvershootMeasurement.h"
#include "scopeprotocols.h"
#include "OvershootMeasurementDecoder.h"

using namespace std;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Construction/destruction
// Construction / destruction

OvershootMeasurement::OvershootMeasurement()
: FloatMeasurement(TYPE_PERCENTAGE)
OvershootMeasurementDecoder::OvershootMeasurementDecoder(string color)
: ProtocolDecoder(OscilloscopeChannel::CHANNEL_TYPE_ANALOG, color, CAT_MEASUREMENT)
{
//Configure for a single input
m_signalNames.push_back("Vin");
//Set up channels
m_signalNames.push_back("din");
m_channels.push_back(NULL);

m_midpoint = 0;
m_range = 1;
}

OvershootMeasurement::~OvershootMeasurement()
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory methods

bool OvershootMeasurementDecoder::ValidateChannel(size_t i, OscilloscopeChannel* channel)
{
if( (i == 0) && (channel->GetType() == OscilloscopeChannel::CHANNEL_TYPE_ANALOG) )
return true;
return false;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Accessors

Measurement::MeasurementType OvershootMeasurement::GetMeasurementType()
void OvershootMeasurementDecoder::SetDefaultName()
{
return Measurement::MEAS_VERT;
char hwname[256];
snprintf(hwname, sizeof(hwname), "Overshoot(%s)", m_channels[0]->m_displayname.c_str());
m_hwname = hwname;
m_displayname = m_hwname;
}

string OvershootMeasurement::GetMeasurementName()
string OvershootMeasurementDecoder::GetProtocolName()
{
return "Overshoot";
}

bool OvershootMeasurement::ValidateChannel(size_t i, OscilloscopeChannel* channel)
bool OvershootMeasurementDecoder::IsOverlay()
{
if( (i == 0) && (channel->GetType() == OscilloscopeChannel::CHANNEL_TYPE_ANALOG) )
return true;
//we create a new analog channel
return false;
}

bool OvershootMeasurementDecoder::NeedsConfig()
{
//automatic configuration
return false;
}

double OvershootMeasurementDecoder::GetVoltageRange()
{
return m_range;
}

double OvershootMeasurementDecoder::GetOffset()
{
return -m_midpoint;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Measurement processing
// Actual decoder logic

bool OvershootMeasurement::Refresh()
void OvershootMeasurementDecoder::Refresh()
{
//Get the input data
if(m_channels[0] == NULL)
return false;
AnalogCapture* din = dynamic_cast<AnalogCapture*>(m_channels[0]->GetData());
if(din == NULL || (din->GetDepth() == 0))
return false;

//Calculate the worst case overshoot
float max = GetMaxVoltage(din);
float top = GetTopVoltage(din);
float base = GetBaseVoltage(din);
m_value = (max-top) / (top-base);
return true;
{
SetData(NULL);
return;
}
auto din = dynamic_cast<AnalogWaveform*>(m_channels[0]->GetData());
if(din == NULL)
{
SetData(NULL);
return;
}

//We need meaningful data
size_t len = din->m_samples.size();
if(len == 0)
{
SetData(NULL);
return;
}

//Figure out the nominal top of the waveform
float top = Measurement::GetTopVoltage(din);
float base = Measurement::GetBaseVoltage(din);
float midpoint = (top+base)/2;

//Create the output
auto cap = new AnalogWaveform;

float fmax = -FLT_MAX;
float fmin = FLT_MAX;

int64_t tmax = 0;
float vmax = 0;

//For each cycle, find how far we got above the top
for(size_t i=0; i < len; i++)
{
//If we're below the midpoint, reset everything and add a new sample
float v = din->m_samples[i];
if(v < midpoint)
{
//Add a sample for the current value (if any)
if(tmax > 0)
{
//Update duration of the previous sample
size_t off = cap->m_offsets.size();
if(off > 0)
cap->m_durations[off-1] = tmax - cap->m_offsets[off-1];

float value = vmax - top;
fmax = max(fmax, value);
fmin = min(fmin, value);

//Add the new sample
cap->m_offsets.push_back(tmax);
cap->m_durations.push_back(0);
cap->m_samples.push_back(value);
}

//Reset
tmax = 0;
vmax = -FLT_MAX;
}

//Accumulate the highest peak of this cycle
else
{
if(v > vmax)
{
tmax = din->m_offsets[i];
vmax = v;
}
}
}

m_range = fmax - fmin;
if(m_range < 0.025)
m_range = 0.025;
m_midpoint = (fmax + fmin) / 2;

SetData(cap);

//Copy start time etc from the input.
cap->m_timescale = din->m_timescale;
cap->m_startTimestamp = din->m_startTimestamp;
cap->m_startPicoseconds = din->m_startPicoseconds;
}
Loading