EEVblog Electronics Community Forum

Products => Test Equipment => Topic started by: slugrustle on February 03, 2024, 08:02:05 pm

Title: Rigol DM3068 SCPI makes no sense
Post by: slugrustle on February 03, 2024, 08:02:05 pm
I'm trying to automate synchronized measurements with two Rigol DM3068 DMMs and external triggering.  In particular, both DMMs are set to 2 NPLC integration time, auto zero on, auto trigger delay, external trigger, positive slope.  I've got a signal generator outputting a 10Hz 5V square wave to the external trigger input on both meters.  They don't seem to miss triggers with this configuration.

I want to get the most recent measurement from both meters after each trigger over SCPI, but there does not seem to be a way to do this reliably because the Rigol SCPI system makes no sense.  Has anyone else run into these problems, and are there workarounds?

I want to send SCPI commands to figure out when the DMMs have triggered and read the most recent measurement.  This should be possible because the USB bus turnaround time (~3ms) is shorter than the trigger period (100ms) and integration time (67ms with autozero).  I could run the trigger slower if needed.

My problem is that there does not seem to be a way to reliably determine when a new trigger has occurred and then read the last measured value.


Is there another or better way to do this?  Other than buying Keysight or Tek meters, that is.  I'm starting to save money for that.  These meters work ok, but some of the implementation is just stupid, and it's pissing me off.

Another fun one with the DM3068 is it can save up to 512 readings in its internal buffer, but this is only accessible in the Agilent command set.  And it lets you set SAMP:COUN to greater than 512, but it just completely hangs the SCPI subsystem if you do that.  Very fun.  This is also not mentioned in the datasheet or in the SAMP:COUN or INIT or FETC commands in the programming manual.  You have to check the DATA:FEED RDG_STORE command in the programming manual.
Title: Re: Rigol DM3068 SCPI makes no sense
Post by: RoGeorge on February 03, 2024, 08:48:41 pm
Using SCPI the proper way and checking for command ready might be tricky.  There are standard SCPI registers and bits, for status and errors, and command ready to tell when a command was completed, and if successful or with error.  Then, some instruments will have additional instrument specific status registers and error registers.  Sometimes a simple chain of commands sent all at once (in the same line) may achieve what the same commands sent one by one might not work.  The higher protocol on top of SCPI might help, too, try VXI11 or VISA.

Mentioning all these because you didn't say what you are using for automation, which makes me guess you are sending over USB-TMC only raw SCPI text listed in the programming manual (without handling the status or the error registers).  The SCPI manual usually doesn't tell how to handle errors and status registers, which are usually handled in higher level protocols by the protocol drivers (not the USB drivers).

I don't have a DM3058, so no idea if it is possible or not to collect the measurements at the needed rate.
Title: Re: Rigol DM3068 SCPI makes no sense
Post by: slugrustle on February 03, 2024, 09:01:33 pm
I'm doing SCPI strings over USB with Rohde & Schwarz' VISA library.  I could add extra commands to check the status registers for errors and things.  The status register that might help the most is the one that either says "waiting for trigger" or "measuring"  I suppose I could use that if I spammed it at high enough rate.

What looks very promising right now is setting the DMMs to measure 100 samples (or so), sending the INIT command to both of them, waiting 10ms for that command to go through (I could also check *OPC) and then triggering my signal generator (Siglent SDG1032X) over SCPI in NCYCLE burst mode to output the desired number of trigger pulses to both DMMs (the one output channel is wired to the external trigger inputs on both DMMs with a BNC T junction).  Then I can use the DATA:POINts? command on the meters to figure out when they're done and call FETC? to get the data.

This basic setup is working with front panel operation and the DMMs set to turn statistics on.  Every time I trigger a burst from the signal generator, the number of samples in statistics mode goes up by exactly that amount.

This way I don't need to send or receive SCPI commands at high rate or with special timing.  All of the synchronization is down to the trigger signal itself.
Title: Re: Rigol DM3068 SCPI makes no sense
Post by: slugrustle on February 03, 2024, 09:12:27 pm
Oh, I think I get what you're saying.  I can send a raw SCPI command, *OPC?, that will return 1 once the last operation is complete.

The fun thing about the Rigol command set, mentioned in the post you replied to, is that the MEAS:VOLT:DC? command returns a value only after the next trigger.  So I can't send *OPC? following MEAS:VOLT:DC?, because MEAS:VOLT:DC? won't return until the next measurement anyway.  And once it returns a value, it's complete.  Hence my remark in the post you replied to about measuring the timing with which these measurement commands return to check for missed triggers.
Title: Re: Rigol DM3068 SCPI makes no sense
Post by: alm on February 04, 2024, 05:35:43 pm
I haven't used Rigol DMMs, but did you study the status registers in the manual? Generally there will be a master status register (*STB?) which then references other, more fine-grained, status registers. And you can sometimes configure to what you want status bits to respond. If you INITIATE the measurement, then you should be able to poll the "message available" bit in the status register for the measurement to be complete. The manual should document all status registers and how to set them up.
Title: Re: Rigol DM3068 SCPI makes no sense
Post by: slugrustle on February 04, 2024, 09:01:40 pm
Ah, thanks, and sorry to both alm and RoGeorge for being slow on the uptake here.  I checked the R&S VISA library API manual, and it does look like I can register callback handlers on events such as triggers or service requests.  I had erroneously assumed that interrupt or event style mechanisms weren't present on the USB bus because it's a serial bus... This must be handled at the protocol level like RoGeorge said.

It looks like I can set up the enable registers so that a message available event causes a service request.  If I use the MEAS:VOLT:DC? query that only returns after the next measurement, then I'd probably have to write that query, use an event callback to find out when there's a message available, then do an SCPI read to get the message.  It's not awfully different from multithreading the program, doing reads right away, and waiting for them to return, although it could likely avoid multithreading depending on how the read timing works out.

Or I could poll the meters with *STB? queries like alm said.  That probably only works with INIT AND FETCh? since MEAS:VOLT:DC? is itself a query...

So thanks to both of you.  It's good to know about these options.

What ended up working well enough was: