Posted Mon, 08 May 2023 13:40:12 GMT by Whist Tvedt, Lars Geir
Hi,<br> <br> I am currently trying to set up a python script to get the results of measurement sweeps using a 3700A, but I cannot seem to get a correct understanding on how to use the registers to do this.<br> <br> I want to use the OPC() command to check if the measurements are complete, before reading the measurement buffer.<br> <br> <br> Could anyone help me understand how to do this?<br> <br> Kind regards,&#160;<br> Lars
Posted Tue, 09 May 2023 17:30:13 GMT by Holland, Paul
Hi Lars,<br> <br> Thanks for the inquiry. I work in the documentation department but have submitted this to one of our engineers. We will follow up with you as soon as we have an answer.<br> <br> Thanks,<br> &#160; <table class=Table style="border:undefined;"> <tbody> <tr> <td colspan=2 nowrap=nowrap style="padding:0in 0in 0in 0in;"><span style="font-size:11pt;"><span style="font-family:Calibri,sans-serif;"><b><span style="font-size:10.0pt;"><span style="font-family:&quot;Arial&quot;,sans-serif;"><span style="color:black;">Paul</span></span></span></b></span></span></td> </tr> <tr> <td colspan=2 nowrap=nowrap style="padding:0in 0in 0in 0in;"><span style="font-size:11pt;"><span style="font-family:Calibri,sans-serif;"><span style="font-size:10.0pt;"><span style="font-family:&quot;Arial&quot;,sans-serif;"><span style="color:black;">Technical Documentation</span></span></span></span></span></td> </tr> <tr> <td nowrap=nowrap style="padding:0in 0in 0in 0in;"></td> <td style="padding:0in 0in 0in 0in;"></td> </tr> </tbody> </table> <div dir=ltr style=""> <div style="color:initial;font:initial;text-rendering:initial;writing-mode:initial;zoom:initial;alignment-baseline:initial;backface-visibility:initial;background:initial;baseline-shift:initial;border:initial;border-radius:initial;border-collapse:initial;box-shadow:initial;box-sizing:initial;caption-side:initial;clear:initial;clip:initial;clip-path:initial;clip-rule:initial;color-interpolation:initial;color-interpolation-filters:initial;color-rendering:initial;columns:initial;column-fill:initial;column-rule:initial;column-span:initial;counter-increment:initial;counter-reset:initial;cursor:initial;display:initial;dominant-baseline:initial;empty-cells:initial;fill:initial;fill-opacity:initial;fill-rule:initial;flex:initial;flex-flow:initial;float:initial;flood-color:initial;flood-opacity:initial;height:initial;image-rendering:initial;letter-spacing:initial;lighting-color:initial;line-break:initial;list-style:initial;margin:initial;mask:initial;max-height:initial;max-width:initial;min-height:initial;min-width:initial;opacity:initial;outline:initial;overflow:initial;padding:initial;perspective:initial;perspective-origin:initial;pointer-events:initial;position:absolute;ruby-position:initial;shape-rendering:initial;size:initial;speak:initial;stop-color:initial;stop-opacity:initial;stroke:initial;stroke-dasharray:initial;stroke-dashoffset:initial;stroke-linecap:initial;stroke-linejoin:initial;stroke-miterlimit:initial;stroke-opacity:initial;stroke-width:initial;table-layout:initial;text-align:initial;text-align-last:initial;text-anchor:initial;text-decoration:initial;text-emphasis-position:initial;text-indent:initial;text-overflow:initial;text-shadow:initial;text-transform:initial;text-underline-position:initial;transform-origin:initial;transform-style:initial;transition:initial;vertical-align:initial;visibility:initial;border-spacing:initial;white-space:initial;width:initial;word-break:initial;word-spacing:initial;z-index:2147483647;"></div> </div> <div style="color:initial;font:initial;text-rendering:initial;writing-mode:initial;zoom:initial;alignment-baseline:initial;backface-visibility:initial;background:initial;baseline-shift:initial;border:initial;border-radius:initial;border-collapse:initial;box-shadow:initial;box-sizing:initial;caption-side:initial;clear:initial;clip:initial;clip-path:initial;clip-rule:initial;color-interpolation:initial;color-interpolation-filters:initial;color-rendering:initial;columns:initial;column-fill:initial;column-rule:initial;column-span:initial;counter-increment:initial;counter-reset:initial;cursor:initial;display:initial;dominant-baseline:initial;empty-cells:initial;fill:initial;fill-opacity:initial;fill-rule:initial;flex:initial;flex-flow:initial;float:initial;flood-color:initial;flood-opacity:initial;height:initial;image-rendering:initial;letter-spacing:initial;lighting-color:initial;line-break:initial;list-style:initial;margin:initial;mask:initial;max-height:initial;max-width:initial;min-height:initial;min-width:initial;opacity:initial;outline:initial;overflow:initial;padding:initial;perspective:initial;perspective-origin:initial;pointer-events:initial;position:absolute;ruby-position:initial;shape-rendering:initial;size:initial;speak:initial;stop-color:initial;stop-opacity:initial;stroke:initial;stroke-dasharray:initial;stroke-dashoffset:initial;stroke-linecap:initial;stroke-linejoin:initial;stroke-miterlimit:initial;stroke-opacity:initial;stroke-width:initial;table-layout:initial;text-align:initial;text-align-last:initial;text-anchor:initial;text-decoration:initial;text-emphasis-position:initial;text-indent:initial;text-overflow:initial;text-shadow:initial;text-transform:initial;text-underline-position:initial;transform-origin:initial;transform-style:initial;transition:initial;vertical-align:initial;visibility:initial;border-spacing:initial;white-space:initial;width:initial;word-break:initial;word-spacing:initial;z-index:2147483647;"></div> <div style="color:initial;font:initial;text-rendering:initial;writing-mode:initial;zoom:initial;alignment-baseline:initial;backface-visibility:initial;background:initial;baseline-shift:initial;border:initial;border-radius:initial;border-collapse:initial;box-shadow:initial;box-sizing:initial;caption-side:initial;clear:initial;clip:initial;clip-path:initial;clip-rule:initial;color-interpolation:initial;color-interpolation-filters:initial;color-rendering:initial;columns:initial;column-fill:initial;column-rule:initial;column-span:initial;counter-increment:initial;counter-reset:initial;cursor:initial;display:initial;dominant-baseline:initial;empty-cells:initial;fill:initial;fill-opacity:initial;fill-rule:initial;flex:initial;flex-flow:initial;float:initial;flood-color:initial;flood-opacity:initial;height:initial;image-rendering:initial;letter-spacing:initial;lighting-color:initial;line-break:initial;list-style:initial;margin:initial;mask:initial;max-height:initial;max-width:initial;min-height:initial;min-width:initial;opacity:initial;outline:initial;overflow:initial;padding:initial;perspective:initial;perspective-origin:initial;pointer-events:initial;position:absolute;ruby-position:initial;shape-rendering:initial;size:initial;speak:initial;stop-color:initial;stop-opacity:initial;stroke:initial;stroke-dasharray:initial;stroke-dashoffset:initial;stroke-linecap:initial;stroke-linejoin:initial;stroke-miterlimit:initial;stroke-opacity:initial;stroke-width:initial;table-layout:initial;text-align:initial;text-align-last:initial;text-anchor:initial;text-decoration:initial;text-emphasis-position:initial;text-indent:initial;text-overflow:initial;text-shadow:initial;text-transform:initial;text-underline-position:initial;transform-origin:initial;transform-style:initial;transition:initial;vertical-align:initial;visibility:initial;border-spacing:initial;white-space:initial;width:initial;word-break:initial;word-spacing:initial;z-index:2147483647;"></div> <div style="color:initial;font:initial;text-rendering:initial;writing-mode:initial;zoom:initial;alignment-baseline:initial;backface-visibility:initial;background:initial;baseline-shift:initial;border:initial;border-radius:initial;border-collapse:initial;box-shadow:initial;box-sizing:initial;caption-side:initial;clear:initial;clip:initial;clip-path:initial;clip-rule:initial;color-interpolation:initial;color-interpolation-filters:initial;color-rendering:initial;columns:initial;column-fill:initial;column-rule:initial;column-span:initial;counter-increment:initial;counter-reset:initial;cursor:initial;display:initial;dominant-baseline:initial;empty-cells:initial;fill:initial;fill-opacity:initial;fill-rule:initial;flex:initial;flex-flow:initial;float:initial;flood-color:initial;flood-opacity:initial;height:initial;image-rendering:initial;letter-spacing:initial;lighting-color:initial;line-break:initial;list-style:initial;margin:initial;mask:initial;max-height:initial;max-width:initial;min-height:initial;min-width:initial;opacity:initial;outline:initial;overflow:initial;padding:initial;perspective:initial;perspective-origin:initial;pointer-events:initial;position:absolute;ruby-position:initial;shape-rendering:initial;size:initial;speak:initial;stop-color:initial;stop-opacity:initial;stroke:initial;stroke-dasharray:initial;stroke-dashoffset:initial;stroke-linecap:initial;stroke-linejoin:initial;stroke-miterlimit:initial;stroke-opacity:initial;stroke-width:initial;table-layout:initial;text-align:initial;text-align-last:initial;text-anchor:initial;text-decoration:initial;text-emphasis-position:initial;text-indent:initial;text-overflow:initial;text-shadow:initial;text-transform:initial;text-underline-position:initial;transform-origin:initial;transform-style:initial;transition:initial;vertical-align:initial;visibility:initial;border-spacing:initial;white-space:initial;width:initial;word-break:initial;word-spacing:initial;z-index:2147483647;"></div> <div style=""></div>
Posted Wed, 10 May 2023 09:04:05 GMT by Whist Tvedt, Lars Geir
<blockquote> <p>Hi Paul,&#160;</p> <p>thanks for doing that.</p> <p></p> <p>Just so you technicians have some more input I have added my code below.</p> <p>TSP script on the 3706A (sweep.tsp):</p> <pre class="linenums prettyprint">-- Reads the sensor output from 3720 in slot2 (channel 1-10) and temperature reading from 3720 in slot1 (channel 1) reset()&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;-- Reset instrument errorqueue.clear()&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;-- Clear error queue status.reset()&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;-- Clearing the status registers and output queue status.request_enable = 0&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;-- Clearing the status enable status.measurement.enable = 0&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;-- Clearing the SRQ on measurement complete enable tempOutput_buffer = dmm.makebuffer(5)&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;-- Create buffer sensorOutput_buffer = dmm.makebuffer(50)&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;-- Create buffer tempOutput_buffer.clear()&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;-- Clearing the tempOutput_buffer sensorOutput_buffer.clear()&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;-- Clearing the sensorOutput_buffer -- Status registers status.standard.enable = 1169 status.request_enable = 129 status.measurement.enable = status.measurement.BAV &#160; -- Enable SRQ on measurement complete function getTemperature() &#160;&#160; &#160;dmm.func = dmm.TEMPERATURE&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;-- Set function to Temperature &#160;&#160; &#160;dmm.transducer = dmm.TEMP_FOURRTD&#160;&#160; &#160;&#160;&#160; &#160;-- Set sensor to 4 wire RTD &#160;&#160; &#160;dmm.fourrtd = dmm.RTD_PT100&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;-- Set RTD to PT100 &#160;&#160; &#160;dmm.units = dmm.UNITS_CELSIUS&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;-- Set units to C &#160;&#160; &#160;dmm.nplc = 2&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;-- Set NPLC &#160;&#160; &#160;dmm.configure.set(&quot;temp&quot;)&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;-- Save DMM setting to RTDtemp &#160;&#160; &#160;dmm.setconfig(&quot;1001&quot;, &quot;temp&quot;)&#160;&#160; &#160;&#160;&#160; &#160;-- Assign RTDtemp setting to channel 1 on MUX in slot 1 &#160;&#160; &#160;scan.create(&quot;1001&quot;)&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;-- Create scan list &#160;&#160; &#160;scan.measurecount = 5&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;-- Set number of repeated measurements in the scan &#160;&#160; &#160;scan.execute(tempOutput_buffer)&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;-- Execute scan and save readings to buffer &#160;&#160; &#160;--scan.background(tempOutput_buffer)&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;-- Execute backgound scan and save readings to buffer &#160;&#160; &#160;waitcomplete() end function getSensorOutput() &#160;&#160; &#160;dmm.func = dmm.DC_VOLTS&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;-- Set dmm function to Volts &#160;&#160; &#160;dmm.nplc = 2&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;-- Set NPLC &#160;&#160; &#160;dmm.range = 10&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;-- Set Range &#160;&#160; &#160;dmm.configure.set(&quot;sensor&quot;)&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;-- Save DMM setting to SensorOutput &#160;&#160; &#160;dmm.setconfig(&quot;2001:2010&quot;, &quot;sensor&quot;)&#160;&#160; &#160;-- Assign sensorOutput setting to channel 1 on MUX in slot 2 &#160;&#160; &#160;scan.create(&quot;2001:2010&quot;)&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;-- Create scan list &#160;&#160; &#160;scan.measurecount = 5&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;-- Set number of repeated measurements on each channel &#160;&#160; &#160;scan.execute(sensorOutput_buffer)&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;-- Execute scan and save readings to buffer &#160;&#160; &#160;--scan.background(sensorOutput_buffer)&#160;&#160; &#160;&#160;&#160; &#160;-- Execute background scan and save readings to buffer &#160;&#160; &#160;waitcomplete() end getTemperature() getSensorOutput() opc() </pre> </blockquote> <pre class="linenums prettyprint"></pre> <blockquote> <pre class="linenums prettyprint"></pre> <p><br> Python script to start measurement and read the results:</p> <pre>import pyvisa as visa import time rm = visa.ResourceManager() inst = rm.open_resource('TCPIP0::192.168.10.3::inst0::INSTR') inst.read_termination = '\n' inst.write_termination = '\n' # running sweep.tsp stored on instrument inst.write('sweep.run()') script_running = True status_byte = 0 debug = 1 while script_running: &#160; &#160; status_byte = inst.read_stb() &#160; &#160; if debug: print(str(status_byte) + ' - ' + str(bin(status_byte))) # for debugging &#160; &#160; if debug: print(status_byte) # for debugging &#160; &#160; if (status_byte and 64) == 64: &#160; &#160; &#160; &#160; script_running = False &#160; &#160; time.sleep(0.25) print(inst.query('printbuffer(1, tempOutput_buffer.n, tempOutput_buffer)')) print(inst.query('printbuffer(1, sensorOutput_buffer.n, sensorOutput_buffer)'))</pre> <p></p> <p>Kind regards,&#160;</p> <p>Lars</p> </blockquote>
Posted Thu, 11 May 2023 18:55:50 GMT by C, Andrea
Hello Lars,<br> <br> Are you saying it is not working for you?&#160; Or you just want to better understand it.<br> <br> I ran just the TSP portion from Test Script Builder, and I am seeing the SRQ annunciator on the front panel.&#160; So I conclude the Python status byte polling loop should be OK.<br> <br> Each of your functions that perform a scan, also make use of waitcomplete().&#160; This will cause the code execution to stall there until the scan finishes.&#160; This seems fine.<br> <br> If you want the SRQ notification on operation complete, the opc bit in status.standard register set &quot;feeds&quot; the ESB bit in the status byte.<br> <br> I would make minor chance to your code and instead use these lines to configure the status subsytem:<br> status.request_enable = 32 &#160; -- enable SRQ on ESB<br> status.standard.enable = 1 &#160; -- OPC bit in this register feeds the ESB bit<br> <br> The last thing your TSP script does is call opc();&#160; when that is able to report complete, the ESB bit will go to logic 1 and the SRQ will go logic 1.<br> The value of the status byte will be 96 or bit pattern 01100000 (in TSP use print(status.condition) to see value of status byte).<br> <br> &#160;
Posted Fri, 12 May 2023 09:22:18 GMT by Whist Tvedt, Lars Geir
Hello Andrea,&#160;<br> thanks for you quick reply.<br> <br> This is not working for me.<br> Also, I would like to understand this a bit better, as I find the manual a bit confusing.&#160;There is no SRQ annunciator on the front panel when running this on my instrument.<br> <br> Kind regards,&#160;<br> Lars
Posted Fri, 12 May 2023 17:30:23 GMT by C, Andrea
Hello Lars,<br> <br> See if the attached document helps.<br> <br> &#160;
Posted Fri, 12 May 2023 19:08:58 GMT by Whist Tvedt, Lars Geir
Hello Andrea.<br> <br> thanks for the explanation and suggestions.<br> I will try this as soon as I am in the lab on monday, and report back to you.<br> <br> Your help is much appreachiated!<br> <br> Have a great weekend!<br> Kind regards,&#160;<br> Lars
Posted Mon, 15 May 2023 08:25:03 GMT by Whist Tvedt, Lars Geir
Hello Andrea,&#160;<br> <br> I just tried your suggestion, and it seems that if I load my TSP script into the 3706A up front, using a separate python script and the command&#160;<code>write('loadscript filename')</code>, it does not work.<br> <br> If I instead write the TSP script to the instrument line by line in the same python script that also trigger the measurement, like your example, it seemed to work for awhile. Now, suddenly, it is not possible to reset the status registers by use of&#160;<code>status.reset()</code><br> <br> Is there any ways of completely reset the instrument to factory defaults (the&#160;<code>reset()</code>&#160;does not seem to fix anything either)?<br> <br> <br> Kind regards,&#160;<br> Lars

You must be signed in to post in this forum.