Posted Thu, 06 Apr 2023 18:50:26 GMT by Smith, Chris Electronics Engineer
I'm following an example from the DMM7510 programming manual (pg 11-12). However, I receive different values when printing the created buffer (&quot;voltDigBuffer&quot;) to my laptop terminal. I'm interested to print voltage measurements and later store each list of measurements within the buffer to variables. After running the attached Python script below, I receive the following output:<br> <br> +00.056 V,04/06/2023,5.609468E-02<br> <br> After running the program again, receiving the following output:&#160;&#160;<br> <br> 5.590122E-02,5.619142E-02,5.599795E-02,5.590122E-02,5.609468E-02,5.609468E-02<br> <br> Is a delay or another parameter required to only print the six values in the print statement?&#160; <pre>print(dmm.query(':TRAC:DATA? 95, 100, &quot;voltDigBuffer&quot;'))</pre> <br> My code below: <pre>import pyvisa as visa rm = visa.ResourceManager('@py') #print(rm.list_resources()) address1 = &quot;TCPIP0::192.168.0.45::inst0::INSTR&quot; dmm = rm.open_resource(address1) dmm.write('*RST') dmm.write(':TRACe:MAKE &quot;voltDigBuffer&quot;, 10000') dmm.write(':DIG:FUNC &quot;VOLTage&quot;') dmm.write(':SENS:DIG:COUN 100') dmm.write(':READ:DIG? &quot;voltDigBuffer&quot;, FORM, DATE, READ') dmm.write(':TRAC:DATA? 95, 100, &quot;voltDigBuffer&quot;') print(dmm.query(':TRAC:DATA? 95, 100, &quot;voltDigBuffer&quot;')) dmm.close() rm.close() </pre> <br> &#160;
Posted Thu, 06 Apr 2023 19:36:58 GMT by McKinney, Ty
Hello,<br> Please run the altered code below and let me know if this performs how you were expecting it to. <pre>import pyvisa as visa rm = visa.ResourceManager('@py') #print(rm.list_resources()) address1 = &quot;TCPIP0::192.168.0.45::inst0::INSTR&quot; dmm = rm.open_resource(address1) dmm.write('*RST') dmm.write(':TRACe:MAKE &quot;voltDigBuffer&quot;, 10000') dmm.write(':DIG:FUNC &quot;VOLTage&quot;') dmm.write(':SENS:DIG:COUN 100') dmm.write(':INIT') print(dmm.query(':TRAC:DATA? 95, 100, &quot;voltDigBuffer&quot;')) dmm.close() rm.close()</pre>
Posted Fri, 07 Apr 2023 11:11:52 GMT by Smith, Chris Electronics Engineer
Thanks for your help. However, I received an error when running this code. It seems the code requires a trigger setup before calling&#160;<span style="background-color:rgb(245, 245, 245);font-family:Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;font-size:13px;">dmm.write(':INIT')</span> <p><br> How can I access parameters from&#160;the &quot;VoltDigBuffer?&quot; I'm interested to create&#160;time and voltage variables with a list of all&#160;relative time and voltage measurements in the&#160;buffer. However, I also don't receive the same output after running the same Python script. It seems I'm having an issue accessing or clearing information from the buffer.&#160;</p>
Posted Sun, 23 Apr 2023 20:05:24 GMT by C, Andrea
In general, when the command you send ends with the question mark (a query type command), you should immediately follow with a read to pull the response to the query command off the output queue.<br> <br> You are sending more than one command in a row.&#160; The first time you read, you will get the response from the first query command, not from the most recent.<br> <br> I'll attach a screen image of your code and the outputs but using a read after each query command.
Posted Sun, 23 Apr 2023 20:12:33 GMT by C, Andrea
Here is some Python code that might more in line with what you are trying to do.<br> I will upload an image of the outputs I get.&#160; I have been feeding a 500Hz sine wave to the DMM7510. <pre class="linenums prettyprint">debug = 1 NUM_SAMPLES = 100 my_instr.write('*RST') my_instr.write(':TRACe:MAKE &quot;voltDigBuffer&quot;,' + str(NUM_SAMPLES)) my_instr.write(':DIG:FUNC &quot;VOLTage&quot;') my_instr.write(':SENS:DIG:VOLT:INP AUTO') my_instr.write(':SENS:DIG:VOLT:RANG 10') my_instr.write(':SENS:DIG:VOLT:SRATE 5000') &#160; #5KHz sample rate my_instr.write(':SENS:DIG:VOLT:APER AUTO') my_instr.write(':SENS:DIG:COUN ' + str(NUM_SAMPLES)) my_instr.write(':TRAC:POIN ' + str(NUM_SAMPLES)) my_instr.write(':TRAC:CLE') my_instr.write(':TRAC:TRIG:DIG &quot;voltDigBuffer&quot;') # wait for done before asking for the data time.sleep(1) &#160;#pause before asking for data if debug == 1: &#160; &#160; my_instr.write(':TRAC:DATA? 95, 100, &quot;voltDigBuffer&quot;, REL, READ') &#160; &#160; print(&quot;****** response to last five points query *************&quot;) &#160; &#160; print(my_instr.read()) #split, parse, etc. &quot;&quot;&quot; raw_data will be comma delimted string of&#160; timestamp, reading, timestamp, reading,... etc. &quot;&quot;&quot; #ask for all the data #TODO: &#160;adjust for NUM_SAMPLES raw_data = my_instr.query(':TRAC:DATA? 1, 100, &quot;voltDigBuffer&quot;, REL, READ') raw_data_array = raw_data.split(',') timestamps = [] Digitized_V = [] # use step of 2 because there are two elements per reading for i in range(0, len(raw_data_array), 2): &#160; &#160; if len(raw_data_array[i]) &gt; 0: &#160; &#160; &#160; &#160; timestamps.append(float(raw_data_array[i])) &#160; &#160; &#160; &#160; Digitized_V.append(float(raw_data_array[i+1])) if debug == 1: &#160; &#160; print(&quot;******* Timestamps *******************&quot;) &#160; &#160; &#160; &#160; &#160; &#160; print(timestamps) &#160; &#160; print(&quot;******** Voltage ******************&quot;) &#160; &#160; print(Digitized_V) &#160; &#160; print(&quot;**************************&quot;) &#160; &#160; print() #graph it plt.autoscale(True, True, True) #plt.axis([0, 0.2, 0, 50e-6]) plt.plot(timestamps, Digitized_V, 'c--') plt.show() </pre>

You must be signed in to post in this forum.