Skip to content

Conversation

@diggit
Copy link

@diggit diggit commented Nov 15, 2025

This is a Rigol Oscilloscope driver refactor.
Related issues #943

I need testers for most scope families (see below).

Refactor

  • each family has it's own identifier and can be easily handled individually
  • use STL containers instead of plain C arrays
  • use RAII for safe(r) resource management

Supported devices and new features

  • DS1000: Broken ❎
    • times out on some commands and FW crashes, needs more investigation
  • MSO/DS1000Z: tested ✔️ (DS1054Z with all options, MSO1104Z with all options)
    • LA: ✔️ (MSO1000Z only)
    • implemented memory/samplerate configuration: ✔️
    • improved download speed: ✔️
    • improved trigger poll performance/robustness: ✔️
  • MSO5000: fixed trigger polling, added LA support
    • analog, samplerate control, triggering, polling, data acq.: ✔️
    • LA: ✔️
  • DHO800:
    • analog, samplerate control, triggering, polling, data acq.: ✔️
    • switched download to single block, doubled the download speed
  • DHO900: no intended changes, but untested (I can borrow one to validate my changes) 🙏
    • should be the same as DHO800
    • LA: untested
  • DHO1000: no intended changes, but untested 🙏
  • DHO4000: no intended changes, but untested 🙏

Known issues (TBD):

non device specific

  • Some trigger offset fixes (keep in place and in valid range on samplerate/memory depthy changes)

Triggers

Not yet supported devices

  • MSO/DS2000: not supported yet
  • MSO/DS4000: not supported yet (I have access to this device and can work on the support)
  • MHO900/MHO098: not supported yet, device available via network (Rigol MHO900/MHO98 support #1022)

Differentiate between scope families and
then group their common behavior in switch statements.
This is more flexible approach and allow more fine tuned,
per family behavior than immediately grouping them by protocol.

- use smart pointers where it makes sense
- use vector/array rather than C arrays

DS1000Z
- implemented memory/samplerate configuration
- improved download speed
- improved trigger poll performance/robustness

Other families should have same handling as before.
to make sure all scope families are handled everywhere
When trigger offset was beyond memory range,
at least DS1000Z never received trigger.
This is necessary, because samplerate changes timebase.
While TB changes, Rigol oscilloscopes keep the trigger position constant
relative to the capture mid point.
Because scopehal reference point is at start, the trigger has to be updated
to keep it constant from scopehal's POV.
As interleaving done automatically by scope is not considered
to be an interleaving feature, see ngscopeclient#1014
@preamp-org
Copy link

Known issues (TBD):

  • Memory depth does not update (in ngscopesclient) when channels are added to the capture.

This is happening with the pico-bridge, too, so probably a bug of ngscopeclient itself and not specific to any make or model of 'scopes.

Initial tests with 1 channel and 1 MB chunks worked fine.
Later tests with 2 channels failed, but 500 kB chunk size worked fine,
but failed for 3 or 4 channels. It looks like the chunk size (maxpoints),
also depends on the amount of enabled channels.
There may be still some margin, but it's not worth chaseing it.
Proper resource locking was missing at multiple places.
It may not be 100% complete yet.
- change verbose logs to trace
- add more trace logs
- print detected options
- remove purely development logs
There are DHO4000 series scopes, which support 250 MHZ BW limit.
- all the series/model -> limiters logic is now in `GetChannelBandwidthLimiters`
- `SetChannelBandwidthLimit` uses values from `GetChannelBandwidthLimiters` and uses nearest higher limit
it is more complicated than expected, no obvious rules
- deduce whole trigger state from data preamble rather than status
- resilient against fast triggers skipping transitions
- properly handles busy(wait)/armed(run) states
…ies::MSODS1000Z as there are also MSO scopes
MSODS1000Z was the only exception and it works there.
- recognize MSO1000Z as MSODS1000Z (tested)
- recognize DHO800/DHO900/DHO1000/DHO4000 (untested)
only `double` for now, but templating allows easy addition of more
…nnel configuration

- it may touch channels and it caused bugs when adding LA support
most of necessary includes are already included indirectly
- developed with MSO1000Z series
- MSO5000/DHO900 implemented, but not tested
…series

because at least `ngscopeclient` starts the download when the scope enters triggered state, but the data are not ready yet.
So we interpret `TD` as `TRIGGER_MODE_RUN` and flip to triggered/stop later
…mble`

just in case so we don't read some garbage
@diggit
Copy link
Author

diggit commented Dec 17, 2025

DHO800 was mostly working. Some quirks were added.
DS1000E support is broken. Initial handshake fails as the cope does not respond to :CHAN<N>:DISP? commands (it should).

@Wiljan1
Copy link

Wiljan1 commented Dec 23, 2025

MSO5072 with upgrade for 4 channels and 200MHz here.
Only CH1+2 does show up in ngscopeclient-windows-x64-v0.1.msi on win10
Also get an error message when I hover over the output of ch2
Rigol_ngscopeclient_error
Look like other see same behavior https://www.eevblog.com/forum/testgear/ngscopeclient-ultimate-acquisition-software-protocol-decoder-debug-tool/50/

@diggit
Copy link
Author

diggit commented Dec 23, 2025

hi @Wiljan1, yeah according to the web, MSO5072 has only 2 analog channels, so the behavior is as expected. I am surprised the model number did not change with mentioned upgrade (upgrading DS1054Z to 100 MHz BW changes the model numbert to DS1104Z).

I am not aware of any way how to inject some per instance overrides, so I will look into some alternative way, how to detect available channels.

Thanks for the feedback! Though this driver changed a lot since 0.1, this logic did not.

@Wiljan1
Copy link

Wiljan1 commented Dec 24, 2025

Hi @diggit ,

I am not aware of any way how to inject some per instance overrides, so I will look into some alternative way, how to detect available channels.

I think the :SYSTem:OPTion:STATus? can be used to check number of Analog channels, BW :

:SYSTem:OPTion:STATus? Syntax :SYSTem:OPTion:STATus? <type> Description Queries the status of the options of the oscilloscope. Parameter Name Type Range Default <type> Discrete {BW071|BW072|BW073|BW12|BW13|BW 23|RL2|4CH|BND|COMP|EMBD|AUTO|FLE X|AUDIO|AERO|AWG|PWR} —— 说明 ➢ BW071: bandwidth upgrade option. The bandwidth upgrades from 70 MHz to 100 MHz. ➢ BW072: bandwidth upgrade option. The bandwidth upgrades from 70 MHz to 200 MHz. ➢ BW073: bandwidth upgrade option. The bandwidth upgrades from 70 MHz to 350 MHz. ➢ BW12: bandwidth upgrade option. The bandwidth upgrades from 100 MHz to 200 MHz. ➢ BW13: bandwidth upgrade option. The bandwidth upgrades from 100 MHz to 350 MHz. ➢ BW23: bandwidth upgrade option. The bandwidth upgrades from 200 MHz to 350 MHz. ➢ RL2: memory depth option. Maximum memory depth up to 200 Mpts. ➢ 4CH: channel number upgrade option. Upgrade the number of analog channels to 4 Chapter 2 Command System RIGOL MSO5000 Programming Guide 2-169 (only available for the MSO5XX2 model). ➢ BND: function and application bundle option, MSO5000-COMP, MSO5000-EMBD, MSO5000-AUTO, MSO58000-FLEX, MSO5000-AUDIO, MSO5000-AERO, MSO5000-AWG, and MSO5000-PWR. ➢ COMP: PC serial bus trigger and analysis option (RS232/UART). ➢ EMBD: embedded serial bus trigger and analysis option (I2C and SPI). ➢ AUTO: auto serial bus trigger and analysis option (CAN and LIN). ➢ FLEX: FlexRay serial bus trigger and analysis option (FlexRay). ➢ AUDIO: audio serial bus trigger and analysis (I2S, only available for the MSO5XX4 model or the model installed with the MSO5000-4CH option). ➢ AERO: MIL-STD-1553 serial bus trigger and analysis option (MIL-STD-1553). ➢ AWG: dual-channel 25 MHz Arbitrary Waveform Generator. ➢ PWR: built-in power analysis option. Return Format The query returns 0 or 1. 0: indicates that the option is not installed. 1: indicates that the official option has been installed.

Let me know if you want me to test something?

Thank you
Wiljan1

@diggit
Copy link
Author

diggit commented Dec 26, 2025

@x44203 mentioned, that :SYSTem:OPTion:STATus? does not work properly on some scopes. x44203, can you elaborate on that? What did you observe?

@diggit
Copy link
Author

diggit commented Dec 26, 2025

@Wiljan1 I've tried :SYSTem:OPTion:STATus?/:SYST:OPT:STAT? on my MSO5074 and it times out without response.

I have to read more carefully next time. :SYSTem:OPTion:STATus? requires one argument with option name, but it still returns 0 for every option even though the scope has them all installed.

EDIT: Ok, :SYSTem:OPTion:STATus? may not work reliably on scopes modified in a certain way.

Alternative approach could be to request :CHAN3:DISP 1 and then check for an error. Tried that with CHAN5 on mentioned (4ch) scope and it looks feasible, but feedback from someone with MSO5072 without the 4 CH option installed, would be appreciated.

@x44203
Copy link
Contributor

x44203 commented Dec 26, 2025

@diggit It seems to return 1 for some options, but they do not reflect the full capabilities of the scope (mine definitely has 4 channels)

:SYS:OPT:STAT? BW071
:SYSTem:OPTion:STATus? BW071 
0
:SYSTem:OPTion:STATus? 4CH
0
:SYSTem:OPTion:STATus? AWG
1
:SYSTem:OPTion:STATus? RL2
0
:SYSTem:OPTion:STATus? BND
1
:SYST:OPT:STAT? BND
1

Edit:

Alternative approach could be to request :CHAN3:DISP 1 and then check for an error.

Agreed, when I wrote that code I must have assumed that MSO5072 shows up as MSO5074. Maybe a check similar to the code for memory depth checking would be better.

@Wiljan1
Copy link

Wiljan1 commented Dec 26, 2025

@diggit @x44203 could be that an original 4ch scope does not accept the cmd.
In the user manual it says for the options:

Channel Number Upgrade Option
Upgrade the Number of Analog Channels to 4 (only available for the
MSO5XX2 model)
MSO5000-4CH

I'm not next to the scope until Tuesday, then I can try the :SYSTem:OPTion:STATus? 4CH on the MSO5072

…option detection

MSO5xx2 scopes are scopes with only 2 channels and other 2 channels are SW option.
Usually `:SYST:OPT:STAT? 4CH` query should be enough, but there are modifier FWs
which report `0` (not present), but the option is active.
This is and attempt to detect it using `:CHAN3:VERN ON`,
which is expected to trigger error if option is missing.
We intentionally do not use any CHAN3 query, as those time out.
@diggit
Copy link
Author

diggit commented Dec 26, 2025

@Wiljan1 new commit 20864ba should address 4CH option detection. Please give it a shot on some MSO5xx2 device (preferably with and without this option).
This check is only done for MSO5xx2 scopes. We assume 4 channels on MSO5xx4 models.

@Wiljan1
Copy link

Wiljan1 commented Dec 27, 2025

@diggit thx I need to know how add the commit to the build on windows in the MSYS2 so I can test it, right now I can compile the main git source.

@diggit
Copy link
Author

diggit commented Dec 27, 2025

@Wiljan1 if you have the environment to build scopehal-apps, you are 99% done.
Assuming you are in directory of the scopehal-apps

  1. cd lib
  2. git fetch origin pull/1017/head:rigol_oscilloscope_refactor
  3. git switch rigol_oscilloscope_refactor
  4. cd ..
  5. build in the same way you did previously

@Wiljan1
Copy link

Wiljan1 commented Dec 28, 2025

@diggit when I add your instructions above and do a build it unfortunate fails:

`[201/542] Building CXX object lib/scopehal/CMakeFiles/scopehal.dir/RigolOscilloscope.cpp.obj
FAILED: [code=1] lib/scopehal/CMakeFiles/scopehal.dir/RigolOscilloscope.cpp.obj

In file included from C:/msys64/home/Jan Jakobsen/scopehal-apps/lib/scopehal/RigolOscilloscope.cpp:31:
C:/msys64/home/Jan Jakobsen/scopehal-apps/lib/scopehal/RigolOscilloscope.h:128:17: warning: declaration of 'BYTE' shadows a global declaration [-Wshadow]
128 | BYTE = 0, // a waveform point occupies one byte (namely 8 bits).
| ^~~~
In file included from C:/msys64/ucrt64/include/windef.h:9,
from C:/msys64/ucrt64/include/windows.h:69,
from C:/msys64/ucrt64/include/winsock2.h:23,
from C:/msys64/ucrt64/include/ws2tcpip.h:17,
from C:/msys64/home/Jan Jakobsen/scopehal-apps/lib/scopehal/scopehal.h:42,
from C:/msys64/home/Jan Jakobsen/scopehal-apps/lib/scopehal/RigolOscilloscope.cpp:30:
C:/msys64/ucrt64/include/minwindef.h:139:25: note: shadowed declaration is here
139 | typedef unsigned char BYTE;
| ^~~~

and a lot more warnings and finally

cc1plus.exe: all warnings being treated as errors
[204/542] Building CXX object lib/scopehal/CM...es/scopehal.dir/TektronixOscilloscope.cpp.ob
ninja: build stopped: subcommand failed.`

@diggit
Copy link
Author

diggit commented Dec 28, 2025

Eh, Windows environment never disappoints. Please pull changes and retry. cd lib; git pull

@Wiljan1
Copy link

Wiljan1 commented Dec 30, 2025

Still having trouble with the git pull / compile, now I'm next to my scope and did connect by a terminal program

*IDN?
RIGOL TECHNOLOGIES,MSO5072,MS5A241xxxxxxx,00.01.03.02.02

:SYSTem:RAMount?
4

Syntax :SYSTem:RAMount?
Description Queries the number of analog channels of the current instrument.
Return
Format
The query returns the number of analog channels of the current instrument in integer.

The :SYSTem:OPTion:STATus? did noit respond for the 4CH

@diggit
Copy link
Author

diggit commented Dec 30, 2025

Ok, this looks straightforward. I will implement channel detestion this way.
Please share the failing build output. We want working builds for Windows too.

@Wiljan1
Copy link

Wiljan1 commented Dec 30, 2025

It's the same error when build since the cmd you suggestgit pulldoes not work correctly

$ git pull
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> rigol_oscilloscope_refactor

I'm new to use git so have to learn :-)

@diggit
Copy link
Author

diggit commented Dec 30, 2025

My bad, pull request are not branches, so local branch can't track it. instead of pulling changes (git pull), use git fetch origin pull/1017/head in lib. That will fetch all latest changes into current local branch.

I've also simplified analog channel detection to use :SYST:RAM?

@Wiljan1
Copy link

Wiljan1 commented Dec 31, 2025

@diggit
I used

Jan Jakobsen@LAPTOP-JJ UCRT64 ~/scopehal-apps/lib
$ git fetch origin pull/1017/head
From https://github.com/ngscopeclient/scopehal
 * branch              refs/pull/1017/head -> FETCH_HEAD

Jan Jakobsen@LAPTOP-JJ UCRT64 ~/scopehal-apps/lib
$ cd ..

Jan Jakobsen@LAPTOP-JJ UCRT64 ~/scopehal-apps
$ cd build

Jan Jakobsen@LAPTOP-JJ UCRT64 ~/scopehal-apps/build
$ ninja -j4
[11/11] Copying icons...

when running the ./ngscopeclient.exe and adding the scope I only see 2 channels and 1 is disabled
when using wireshark and sniffing I do not see the :SYST:RAM? send over network so I doubt the patch are actually done
rigol_02

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants