Skip to content

Commit 3d288e1

Browse files
committed
Initial ThunderScope 12-bit support fixes
1 parent c64d492 commit 3d288e1

File tree

5 files changed

+91
-6
lines changed

5 files changed

+91
-6
lines changed

scopehal/Oscilloscope.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* *
33
* libscopehal *
44
* *
5-
* Copyright (c) 2012-2024 Andrew D. Zonenberg and contributors *
5+
* Copyright (c) 2012-2025 Andrew D. Zonenberg and contributors *
66
* All rights reserved. *
77
* *
88
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
@@ -681,6 +681,11 @@ int64_t Oscilloscope::GetDeskewForChannel(size_t /*channel*/)
681681
return 0;
682682
}
683683

684+
bool Oscilloscope::HasInterleavingControls()
685+
{
686+
return true;
687+
}
688+
684689
bool Oscilloscope::CanInterleave()
685690
{
686691
//Check each conflict in the list
@@ -815,6 +820,12 @@ Oscilloscope::AnalogBank Oscilloscope::GetAnalogBank(size_t /*channel*/)
815820
return ret;
816821
}
817822

823+
bool Oscilloscope::IsADCModePerChannel()
824+
{
825+
//default is to assume adc mode is a global setting
826+
return false;
827+
}
828+
818829
bool Oscilloscope::IsADCModeConfigurable()
819830
{
820831
return false;

scopehal/Oscilloscope.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* *
33
* libscopehal *
44
* *
5-
* Copyright (c) 2012-2024 Andrew D. Zonenberg and contributors *
5+
* Copyright (c) 2012-2025 Andrew D. Zonenberg and contributors *
66
* All rights reserved. *
77
* *
88
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
@@ -564,6 +564,11 @@ class Oscilloscope : public virtual Instrument
564564
*/
565565
virtual bool SetInterleaving(bool combine) =0;
566566

567+
/**
568+
@brief Returns true if the scope has a user controllavble interleaving feature, false if not
569+
*/
570+
virtual bool HasInterleavingControls();
571+
567572
/**
568573
@brief Returns true if we have no interleave conflicts, false if we have conflicts
569574
*/
@@ -693,6 +698,11 @@ class Oscilloscope : public virtual Instrument
693698
*/
694699
virtual AnalogBank GetAnalogBank(size_t channel);
695700

701+
/**
702+
@brief Returns true if the ADC is a per-channel setting, false if global for the entire instrument
703+
*/
704+
virtual bool IsADCModePerChannel();
705+
696706
/**
697707
@brief Returns true if the ADC is configurable, false if it can only run in one mode.
698708
*/

scopehal/SiglentFunctionGenerator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* *
33
* libscopehal *
44
* *
5-
* Copyright (c) 2012-2024 Andrew D. Zonenberg and contributors *
5+
* Copyright (c) 2012-2025 Andrew D. Zonenberg and contributors *
66
* All rights reserved. *
77
* *
88
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
@@ -153,7 +153,7 @@ void SiglentFunctionGenerator::ParseOutputState(const string& str, size_t i)
153153
void SiglentFunctionGenerator::ParseBasicWaveform(const string& str, size_t i)
154154
{
155155
auto fields = explode(str, ',');
156-
LogDebug("ParseBasicWaveform\n");
156+
LogTrace("ParseBasicWaveform\n");
157157
LogIndenter li;
158158

159159
//Fields are paired as name,value consecutively

scopehal/ThunderScopeOscilloscope.cpp

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ ThunderScopeOscilloscope::ThunderScopeOscilloscope(SCPITransport* transport)
6767
, m_diag_totalWFMs(FilterParameter::TYPE_INT, Unit(Unit::UNIT_COUNTS))
6868
, m_diag_droppedWFMs(FilterParameter::TYPE_INT, Unit(Unit::UNIT_COUNTS))
6969
, m_diag_droppedPercent(FilterParameter::TYPE_FLOAT, Unit(Unit::UNIT_PERCENT))
70+
, m_adcMode(MODE_8BIT)
7071
{
7172
m_analogChannelCount = 4;
7273

@@ -171,11 +172,13 @@ ThunderScopeOscilloscope::ThunderScopeOscilloscope(SCPITransport* transport)
171172

172173
m_conversion8BitPipeline = make_unique<ComputePipeline>(
173174
"shaders/Convert8BitSamples.spv", 2, sizeof(ConvertRawSamplesShaderArgs) );
174-
175+
175176
m_conversion16BitPipeline = make_unique<ComputePipeline>(
176177
"shaders/Convert16BitSamples.spv", 2, sizeof(ConvertRawSamplesShaderArgs) );
177178

178179
m_clippingBuffer.resize(1);
180+
181+
//TODO: query ADC mode on hardware
179182
}
180183

181184
/**
@@ -414,7 +417,7 @@ bool ThunderScopeOscilloscope::AcquireData()
414417
bool clipping;
415418
if(!m_transport->ReadRawData(sizeof(clipping), (uint8_t*)&clipping))
416419
return false;
417-
420+
418421
if(!m_transport->ReadRawData(sizeof(dataType), (uint8_t*)&dataType))
419422
return false;
420423

@@ -685,6 +688,11 @@ bool ThunderScopeOscilloscope::CanInterleave()
685688
return false;
686689
}
687690

691+
bool ThunderScopeOscilloscope::HasInterleavingControls()
692+
{
693+
return false;
694+
}
695+
688696
set<Oscilloscope::InterleaveConflict> ThunderScopeOscilloscope::GetInterleaveConflicts()
689697
{
690698
//interleaving not supported
@@ -787,6 +795,48 @@ void ThunderScopeOscilloscope::SetChannelCoupling(size_t i, OscilloscopeChannel:
787795
}
788796
}
789797

798+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
799+
// ADC modes
800+
801+
bool ThunderScopeOscilloscope::IsADCModeConfigurable()
802+
{
803+
return true;
804+
}
805+
806+
vector<string> ThunderScopeOscilloscope::GetADCModeNames([[maybe_unused]] size_t channel)
807+
{
808+
vector<string> ret;
809+
ret.push_back("8 bit");
810+
ret.push_back("12 bit");
811+
return ret;
812+
}
813+
814+
size_t ThunderScopeOscilloscope::GetADCMode([[maybe_unused]] size_t channel)
815+
{
816+
return m_adcMode;
817+
}
818+
819+
void ThunderScopeOscilloscope::SetADCMode([[maybe_unused]] size_t channel, size_t mode)
820+
{
821+
switch(mode)
822+
{
823+
case 0:
824+
m_adcMode = MODE_8BIT;
825+
m_transport->SendCommandQueued("ACQ:RES 8");
826+
break;
827+
828+
//12 bit mode has lower Fmax so need to refresh sample rate in case the scope clamped us
829+
case 1:
830+
m_adcMode = MODE_12BIT;
831+
m_transport->SendCommandQueued("ACQ:RES 12");
832+
RefreshSampleRate();
833+
break;
834+
835+
default:
836+
break;
837+
}
838+
}
839+
790840
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
791841
// Checking for validity of configurations
792842

scopehal/ThunderScopeOscilloscope.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,16 @@ class ThunderScopeOscilloscope : public RemoteBridgeOscilloscope
9393
virtual bool IsInterleaving() override;
9494
virtual bool SetInterleaving(bool combine) override;
9595
virtual bool CanInterleave() override;
96+
virtual bool HasInterleavingControls() override;
9697
void SetSampleDepth(uint64_t depth) override;
9798
void SetSampleRate(uint64_t rate) override;
9899

100+
//ADC modes
101+
virtual bool IsADCModeConfigurable() override;
102+
virtual std::vector<std::string> GetADCModeNames(size_t channel) override;
103+
virtual size_t GetADCMode(size_t channel) override;
104+
virtual void SetADCMode(size_t channel, size_t mode) override;
105+
99106
protected:
100107
void ResetPerCaptureDiagnostics();
101108
void RefreshSampleRate();
@@ -150,6 +157,13 @@ class ThunderScopeOscilloscope : public RemoteBridgeOscilloscope
150157
///@brief Bandwidth limiters
151158
std::vector<unsigned int> m_bandwidthLimits;
152159

160+
///@brief ADC modes
161+
enum ADCMode
162+
{
163+
MODE_8BIT,
164+
MODE_12BIT
165+
} m_adcMode;
166+
153167
public:
154168

155169
static std::string GetDriverNameInternal();

0 commit comments

Comments
 (0)