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

Commits on May 4, 2021

  1. Copy the full SHA
    754b9ae View commit details
Showing with 27 additions and 3 deletions.
  1. +2 −0 src/ps6000d/ScpiServerThread.cpp
  2. +21 −3 src/ps6000d/WaveformServerThread.cpp
  3. +4 −0 src/ps6000d/ps6000d.h
2 changes: 2 additions & 0 deletions src/ps6000d/ScpiServerThread.cpp
Original file line number Diff line number Diff line change
@@ -129,6 +129,7 @@ uint64_t g_triggerDelay = 0;
PICO_THRESHOLD_DIRECTION g_triggerDirection = PICO_RISING;
float g_triggerVoltage = 0;
size_t g_triggerChannel = 0;
size_t g_triggerSampleIndex;

void UpdateTrigger();
void UpdateChannel(size_t chan);
@@ -685,6 +686,7 @@ void StartCapture(bool stopFirst)
g_channelOnDuringArm = g_channelOn;
g_captureMemDepth = g_memDepth;
g_sampleIntervalDuringArm = g_sampleInterval;
g_triggerSampleIndex = g_memDepth/2;

if(stopFirst)
ps6000aStop(g_hScope);
24 changes: 21 additions & 3 deletions src/ps6000d/WaveformServerThread.cpp
Original file line number Diff line number Diff line change
@@ -38,6 +38,7 @@
using namespace std;

volatile bool g_waveformThreadQuit = false;
float InterpolateTriggerTime(int16_t* buf);

void WaveformServerThread()
{
@@ -130,6 +131,9 @@ void WaveformServerThread()

//TODO: send overflow flags to client

//Interpolate trigger position if we're using a simple level trigger
float trigphase = InterpolateTriggerTime(waveformBuffers[g_triggerChannel]);

//Send data for each channel to the client
for(size_t i=0; i<g_numChannels; i++)
{
@@ -139,12 +143,12 @@ void WaveformServerThread()
client.SendLooped((uint8_t*)&i, sizeof(i));
client.SendLooped((uint8_t*)&numSamples, sizeof(numSamples));
float scale = g_roundedRange[i] / 32512;
client.SendLooped((uint8_t*)&scale, sizeof(scale));
float offset = g_offsetDuringArm[i];
client.SendLooped((uint8_t*)&offset, sizeof(offset));
float config[3] = {scale, offset, trigphase};
client.SendLooped((uint8_t*)&config, sizeof(config));

//Send the actual waveform data
client.SendLooped((uint8_t*)waveformBuffers[i], g_captureMemDepth * sizeof(uint16_t));
client.SendLooped((uint8_t*)waveformBuffers[i], g_captureMemDepth * sizeof(int16_t));
}
}

@@ -167,3 +171,17 @@ void WaveformServerThread()
for(auto it : waveformBuffers)
delete[] it.second;
}

float InterpolateTriggerTime(int16_t* buf)
{
float trigscale = g_roundedRange[g_triggerChannel] / 32512;
float trigoff = g_offsetDuringArm[g_triggerChannel];

float fa = buf[g_triggerSampleIndex-1] * trigscale + trigoff;
float fb = buf[g_triggerSampleIndex] * trigscale + trigoff;

//no need to divide by time, sample spacing is normalized to 1 timebase unit
float slope = (fb - fa);
float delta = g_triggerVoltage - fa;
return delta / slope;
}
4 changes: 4 additions & 0 deletions src/ps6000d/ps6000d.h
Original file line number Diff line number Diff line change
@@ -70,6 +70,10 @@ extern int64_t g_sampleInterval;
extern int64_t g_sampleIntervalDuringArm;
extern std::map<size_t, double> g_offsetDuringArm;

extern size_t g_triggerSampleIndex;
extern size_t g_triggerChannel;
extern float g_triggerVoltage;

extern bool g_triggerArmed;
extern bool g_triggerOneShot;
extern bool g_memDepthChanged;