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, 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.

Thanks

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
Posted Wed, 17 May 2023 23:00:24 GMT by C, Andrea
<p>When you say you cannot reset the status registers, can you elaborate?</p> <p>Is it that the status.condition register still has some bits at logic 1 but you expect 0?&#160; Which ones/what is the value of the register?</p> <p>For example, if data is still sitting in the output queue (from print or printbuffer), the MAV bit will be set.</p> <p>Either VISA read the info or send a inst.clear() to clear old data in output queue and that will reset the MAV bit to 0.</p> <p>The status reset affects the enable and other writable registers.&#160; The read only condition registers are not affected by status reset.</p>
Posted Tue, 23 May 2023 09:45:01 GMT by Whist Tvedt, Lars Geir
Yes, the status.condition register still had some bits at logic 1.<br> I am not exactly sure what solved it, but I believe that I missed the&#160;<code>keithley.send_end = True</code><br> Now it is working as expected. Thanks for the help.<br> <br> Kind regards,&#160;<br> Lars

You must be signed in to post in this forum.