# Reading an Analog Voltage Waveform with a Programmable Scope

I am trying to automate the use of a Tektronix TBS 1052B digital oscilloscope in order to get the waveform for an analog voltage signal. Or in other words, get a number of voltage measurement samples over time.

There seem to be at least two measurement modes for configuring the scope to perform the measurement, MEASurement and WAVFrm. This is where I am having some trouble. Based on the way that WAVFrm works, it seems like that is only used for interpreting binary data (this is where I could be wrong) so that seems like the configuration I should not be using. On the other hand, the documentation for MEASurement does not describe a way for taking a specific number of samples (which is what I need to do in order to get the analog waveform), so this also does not seem like a reasonable configuration.

It seems like no matter which configuration I pick, it will not give me the result I am looking for! I must be getting confused by their documentation [here].

Can anyone help shed light on which configuration I should be using, MEASurement or WAVFrm?

• Commonly, waveform on scopes refers to the time/value samples, while measurement refers to "post-processed" information such as peak-to-peak voltage, overshoot, period, etc. I'm unfamiliar with the programming interface for this scope, but I wouldn't be surprised if it followed this terminology. Aug 8 '16 at 17:12
• Looks to me like you'd want to use the Waveform commands (starting on page 2-37) to capture the waveform. The Measure commands (2-23) look to be more for getting numbers that are evaluated from the waveform (as @helloworld922 says, "post-processed" information.)
– JRE
Aug 8 '16 at 17:14
• I am really trying to do a very simple thing. The documentation on how the waveform and measurement functionalities work, leaves something to be desired. Instead of describing the general process, the documentation is more like a dictionary for every possible command. Aug 8 '16 at 17:14
• So will the measurement commands give me all of the data points? That I've specified with DATA:STAR through DATA:STOP? Because all of the examples show only returning a single point of data. Aug 8 '16 at 17:15
• At the end of the day, I'd really like to just have an array of voltage values. Aug 8 '16 at 17:16

I've never used this particular oscilloscope, but I'll give it a go. Note that you'll need to figure out how to incorporate the command sequence I've recommended below into whichever data acquisition software package you're using (LabVIEW, MATLAB, VEE, etc.).

Start by resetting the oscilloscope's controls and settings to their "factory setup defaults" (see also appendix B "Factory Setup" in the TBS1000 Programmer manual [hint: search for "tbs1000 programmer manual" on tek.com]). This is done by issuing the SCPI "*RST" command:

*RST


Display channel 1, AND turn OFF channel 2:

SELECT:CH1 ON;CH2 OFF


Configure the horizontal, vertical, triggering controls, etc. as desired—e.g., horizontal time/div = 1ms/div; channel 1 volts/div = 1V/div:

HORIZONTAL:MAIN:SCALE 1E-3
CH1:SCALE 1


Configure the oscilloscope to acquire a single waveform when the oscilloscope detects that the triggering conditions are met:

ACQUIRE:STATE STOP
ACQUIRE:STOPAFTER SEQUENCE


Acquire a single waveform ("run once"):

ACQUIRE:STATE RUN


Wait for the data acquisition to complete. This is done by issuing the SCPI query "*OPC?" (operation complete?). As stated in the oscilloscope's Programmer manual, "[t]he *OPC? response is not available to read until all pending operations finish", meaning the *OPC? invocation blocks until the oscilloscope finishes the data acquisition task.

*OPC?


In the WAVEFORM commands group, use the CURVE? query to transfer Channel 1's waveform data from the oscilloscope to your computer:

DATA:SOURCE CH1
CURVE?


Note that the "CURVE?" query returns a stream of bytes that are typically stored in a buffer that your program creates for this purpose (e.g., a character array, or a byte array). Your program then parses the desired information from the stored data in the buffer. Exactly how this is done depends entirely upon the programming language and instrument I/O libraries you're using—e.g., LabVIEW, MATLAB, VEE, etc.—and is left as an exercise for the reader.

P.S. If you need help writing the code for a specific programming language, I recommend you find/use forums that are dedicated to the particular programming language you're working with—e.g., LabVIEW instrument I/O programming forums; MATLAB instrument I/O programming forums, etc. Those folks would be much better suited to answering programming language specific questions than the folks in an electronics forum. (<- Not complaining/whining, just sayin'...)

• I spoke with a representative from Tek, and got a very similar answer to this. I will give it a try and get back to you. Aug 9 '16 at 12:17

Just figured I'd add my answer (that worked for me) here in case anyone needs help down the road.

Obtaining the Waveform

Although not required, the first thing I do is clear out the event-status-register as follows:

*ESR?


Next, I tell the scope to start acquiring the waveform:

ACQUIRE:STATE ON


I then wait for acquisition to complete, observing the status of the operation.

*OPC?


Then, in order to make sense of the data that comes back from the waveform I switch over to ASCII format as follows:

DATA:ENC ASCI


Now, I am ready to obtain the waveform:

CURVE?


Gathering the Voltage Samples

Now comes the tricky part, that took me a while. The following formula (pulled from the programmer's reference manual) is required to convert the digitizer values into voltage values:

So, in this equation yn symbolizes our digitizer values (points on the waveform), and I will not go into too much detail about what the other variables are because they are in the manual. The variables can be obtained as follows, and note that it is easiest to keep the scope in ASCII mode because then we can plug the values directly into the formula.

For YZEro:

WFMPre:YZEro?


For YMUlty:

WFMPre:YMUlty?


For YOFf:

WFMPre:YOFf?


Now, plug all of these values into the formula and then compute the voltage (Yn) for each of the digitizer values (yn).