@@ -49,6 +49,7 @@ RigolOscilloscope::RigolOscilloscope(SCPITransport* transport)
49
49
, m_triggerArmed(false )
50
50
, m_triggerWasLive(false )
51
51
, m_triggerOneShot(false )
52
+ , m_liveMode(false )
52
53
{
53
54
// Last digit of the model number is the number of channels
54
55
if (1 == sscanf (m_model.c_str (), " DS%d" , &m_modelNumber))
@@ -107,16 +108,27 @@ RigolOscilloscope::RigolOscilloscope(SCPITransport* transport)
107
108
108
109
m_transport->SendCommandQueued (" CHAN1:BWL " + originalBandwidthLimit);
109
110
}
110
- else if (1 == sscanf (m_model.c_str (), " DHO%d" , &m_modelNumber) && (m_modelNumber < 1000 ))
111
- {
111
+ else if (1 == sscanf (m_model.c_str (), " DHO%d" , &m_modelNumber) && (m_modelNumber < 5000 ))
112
+ { // Model numbers are :
113
+ // - DHO802 (70MHz), DHO804 (70Mhz), DHO812 (100MHz),DHO814 (100MHz)
114
+ // - DHO914/DHO914S (125MHz), DHO924/DHO924S (250MHz)
115
+ // - DHO1072 (70MHz), DHO1074 (70MHz), DHO1102 (100MHz), DHO1104 (100MHz), DHO1202 (200MHz), DHO1204 (200MHz)
116
+ // - DHO4204 (200MHz), DHO4404 (400 MHz), DHO4804 (800MHz)
112
117
m_protocol = DHO;
113
118
114
119
int model_multiplicator = 100 ;
115
- if (m_modelNumber > 900 ) // special handling of DHO900 series
116
- {
120
+ int model_modulo = 100 ;
121
+ if (m_modelNumber > 1000 )
122
+ { // DHO1000 and 4000
123
+ model_multiplicator = 10 ;
124
+ model_modulo = 1000 ;
125
+ }
126
+ else if (m_modelNumber > 900 )
127
+ { // special handling of DHO900 series
117
128
model_multiplicator = 125 ;
118
129
}
119
- m_bandwidth = m_modelNumber % 100 / 10 * model_multiplicator; // should also work for DHO1000/DHO4000
130
+ m_bandwidth = m_modelNumber % model_modulo / 10 * model_multiplicator;
131
+ if (m_bandwidth == 0 ) m_bandwidth = 70 ; // Fallback for DHO80x models
120
132
121
133
m_opt200M = false ; // does not exist in 800/900 series
122
134
}
@@ -653,6 +665,9 @@ void RigolOscilloscope::SetChannelOffset(size_t i, size_t /*stream*/, float offs
653
665
654
666
Oscilloscope::TriggerMode RigolOscilloscope::PollTrigger ()
655
667
{
668
+ if (m_liveMode)
669
+ return TRIGGER_MODE_TRIGGERED;
670
+
656
671
auto stat = Trim (m_transport->SendCommandQueuedWithReply (" :TRIG:STAT?" ));
657
672
658
673
if (stat != " STOP" )
@@ -708,6 +723,7 @@ bool RigolOscilloscope::AcquireData()
708
723
maxpoints = 8192 ; // FIXME
709
724
else if (m_protocol == MSO5)
710
725
maxpoints = GetSampleDepth (); // You can use 250E6 points too, but it is very slow
726
+
711
727
unsigned char * temp_buf = new unsigned char [maxpoints + 1 ];
712
728
map<int , vector<UniformAnalogWaveform*>> pending_waveforms;
713
729
for (size_t i = 0 ; i < m_analogChannelCount; i++)
@@ -754,8 +770,17 @@ bool RigolOscilloscope::AcquireData()
754
770
&yincrement,
755
771
&yorigin,
756
772
&yreference);
773
+ if (sec_per_sample == 0 )
774
+ { // Sometimes the scope might return a null value for xincrement => replace it with a dummy value to prenvent an Arithmetic exception in WaveformArea::RasterizeAnalogOrDigitalWaveform
775
+ LogWarning (" Got null sec_per_sample value from the scope, forcing it to a dummy non null value to prevent Arithmetic exception.\n " );
776
+ sec_per_sample = 0.001 ;
777
+ }
757
778
fs_per_sample = round (sec_per_sample * FS_PER_SECOND);
758
- // LogDebug("X: %d points, %f origin, ref %f fs/sample %ld\n", npoints, xorigin, xreference, fs_per_sample);
779
+ if (m_protocol == DHO)
780
+ { // DHO models return page size instead of memory depth when paginating
781
+ npoints = GetSampleDepth ();
782
+ }
783
+ // LogDebug("X: %d points, %f origin, ref %f fs/sample %ld\n", (int) npoints, xorigin, xreference, (long int) fs_per_sample);
759
784
// LogDebug("Y: %f inc, %f origin, %f ref\n", yincrement, yorigin, yreference);
760
785
}
761
786
@@ -775,7 +800,7 @@ bool RigolOscilloscope::AcquireData()
775
800
// Downloading the waveform is a pain in the butt, because we can only pull 250K points at a time! (Unless you have a MSO5)
776
801
for (size_t npoint = 0 ; npoint < npoints;)
777
802
{
778
- if (m_protocol == MSO5 || m_protocol == DHO )
803
+ if (m_protocol == MSO5)
779
804
{
780
805
// Ask for the data block
781
806
m_transport->SendCommandQueued (" *WAI" );
@@ -899,8 +924,11 @@ bool RigolOscilloscope::AcquireData()
899
924
}
900
925
else
901
926
{
902
- m_transport->SendCommandQueued (" :SING" );
903
- m_transport->SendCommandQueued (" *WAI" );
927
+ if (!m_liveMode)
928
+ {
929
+ m_transport->SendCommandQueued (" :SING" );
930
+ m_transport->SendCommandQueued (" *WAI" );
931
+ }
904
932
}
905
933
m_triggerArmed = true ;
906
934
}
@@ -910,6 +938,24 @@ bool RigolOscilloscope::AcquireData()
910
938
return true ;
911
939
}
912
940
941
+ void RigolOscilloscope::PrepareStart ()
942
+ {
943
+ if (m_protocol == DHO)
944
+ {
945
+ // DHO models need to set raw mode off and on again or vice versa to reset the number of points according to the current memory depth
946
+ if (m_liveMode)
947
+ {
948
+ m_transport->SendCommandQueued (" :WAV:MODE RAW" );
949
+ m_transport->SendCommandQueued (" :WAV:MODE NORM" );
950
+ }
951
+ else
952
+ {
953
+ m_transport->SendCommandQueued (" :WAV:MODE NORM" );
954
+ m_transport->SendCommandQueued (" :WAV:MODE RAW" );
955
+ }
956
+ }
957
+ }
958
+
913
959
void RigolOscilloscope::Start ()
914
960
{
915
961
// LogDebug("Start single trigger\n");
@@ -918,6 +964,23 @@ void RigolOscilloscope::Start()
918
964
m_transport->SendCommandQueued (" :TRIG:EDGE:SWE SING" );
919
965
m_transport->SendCommandQueued (" :RUN" );
920
966
}
967
+ else if (m_protocol == DHO)
968
+ { // Check for memory depth : if it is 1k, switch to live mode for better performance
969
+ // Limit live mode to one channel setup to prevent grabbing waveforms from to different triggers on seperate channels
970
+ if (GetEnabledChannelCount ()==1 )
971
+ {
972
+ m_mdepthValid = false ;
973
+ GetSampleDepth ();
974
+ m_liveMode = (m_mdepth == 1000 );
975
+ }
976
+ else
977
+ {
978
+ m_liveMode = false ;
979
+ }
980
+ PrepareStart ();
981
+ m_transport->SendCommandQueued (m_liveMode ? " :RUN" : " :SING" );
982
+ m_transport->SendCommandQueued (" *WAI" );
983
+ }
921
984
else
922
985
{
923
986
m_transport->SendCommandQueued (" :SING" );
@@ -929,6 +992,9 @@ void RigolOscilloscope::Start()
929
992
930
993
void RigolOscilloscope::StartSingleTrigger ()
931
994
{
995
+ m_liveMode = false ;
996
+ m_mdepthValid = false ; // Memory depth might have been changed on scope
997
+ PrepareStart ();
932
998
if (m_protocol == DS_OLD)
933
999
{
934
1000
m_transport->SendCommandQueued (" :TRIG:EDGE:SWE SING" );
@@ -946,12 +1012,16 @@ void RigolOscilloscope::StartSingleTrigger()
946
1012
void RigolOscilloscope::Stop ()
947
1013
{
948
1014
m_transport->SendCommandQueued (" :STOP" );
1015
+ m_liveMode = false ;
949
1016
m_triggerArmed = false ;
950
1017
m_triggerOneShot = true ;
951
1018
}
952
1019
953
1020
void RigolOscilloscope::ForceTrigger ()
954
1021
{
1022
+ m_liveMode = false ;
1023
+ m_mdepthValid = false ; // Memory depth might have been changed on scope
1024
+ PrepareStart ();
955
1025
if (m_protocol == DS || m_protocol == DHO)
956
1026
m_transport->SendCommandQueued (" :TFOR" );
957
1027
else
0 commit comments