Tektronix Technical Forums are maintained by community involvement. Feel free to post questions or respond to questions by other members. Should you require a time-sensitive answer, please contact your local Tektronix support center here.

PC cannot read 2450-buffer while script is running

Models 2450, 2460, 2461, 2470
Post Reply
[email protected]
Posts: 3
Joined: November 19th, 2021, 1:40 am
Country: Croatia

PC cannot read 2450-buffer while script is running

Post by [email protected] » November 24th, 2021, 4:47 pm

Hi,
I have 2450 on which I have loaded the script (with Python) which basically changes the source (voltage), quasi-continuously by small steps (1 mV) at specified speed, and measures current at specific source values (say every 100 mV). So the script runs 'while loop' and checks timer for next sourcing and reads the measurement into the buffer.

While this sourcing/measuring script is running on 2450, I want to grab already measured values into PC and plot them, like to have real-time data acquisition. I tried with the printbuffer or userstring.get() functions, but failed.
I found on this forum couple of similar questions, but without clear answer. So the conclusion would be that the communication with the instrument is impossible while the script is running. If so, it is pity because this disables taking full advantage of the advanced instrument as 2450 is.

Question: Am I miss something and there is still a some way to real-time communicate with the instrument while a script is running? With new firmware?

Thank you
Kreso Salamon

Andrea C
Keithley Applications
Keithley Applications
Posts: 1653
Joined: October 15th, 2010, 10:35 am
Country: United States
Contact:

Re: PC cannot read 2450-buffer while script is running

Post by Andrea C » November 29th, 2021, 6:58 pm

Hello,
It is not impossible, but does require a balancing of rates for new data in and old data out across the bus.

Expressed in how many total samples to send across bus, how long do you need to run? How big would data buffer need to be to hold it all?

And sounds like the desired rate of data transfers is not high if measuring only once for 100 source values.

For the values to be sourced, do you know them ahead of time and can use source config list? Or in your while loop, do you compute next source value based on last measurement or something where you don’t know ahead of time?

Basically you need logic to keep track of buffer index and have the script print data to the output queue so that PC side VISA reads can bring it to you.
Depending upon the various constraints, there are couple different ways to approach it.

[email protected]
Posts: 3
Joined: November 19th, 2021, 1:40 am
Country: Croatia

Re: PC cannot read 2450-buffer while script is running

Post by [email protected] » November 30th, 2021, 3:28 am

Hello,
Thanks for the response.

It is not so much data points. Per scan, in total, of the order of 100, less than 1000.
The rate of data transfers is about 1 per 50 source values. But, it is important to have no delay in sourcing, that is, the source speed must be constant during the scan. The values to be sourced are calculated before the loop begins. I'm not using 'config list'; source values are stored in the list/array.

I tried to query the buffer index with the command bufferName.n, but the program stucks, like with any other query command during the loop. The only thing I can do to interact with the script while it runs loop is to rise one of the digital line (using another instrument) and then the script, within the loop, checks the state of this digital line. In that way I can stop the script from the PC side. The live measurements I'm watching on the 2450's screen, and then after the scan is finished, I'm allowed to query the data and draw them within my software. :cry:

How can I 'keep track of buffer index' when running-script doesn't allow any communication between PC and 2450?
Regarding 'print data to the output queue', is there somewhere any details on 'different ways to approach it'?

Best regards,
Kreso Salamon

Andrea C
Keithley Applications
Keithley Applications
Posts: 1653
Joined: October 15th, 2010, 10:35 am
Country: United States
Contact:

Re: PC cannot read 2450-buffer while script is running

Post by Andrea C » November 30th, 2021, 6:33 am

If the "computer" that is your instrument, is put into a loop, then as you have experienced, the instrument is not able to parse new commands sent over the bus from the PC. The loop does not yield.

One exception would be commands to read the status byte. If using pyVISA for example, the read_stb() can be used to interrogate the status byte while the Lua based loop is running.

If you want to keep with your while loop, the Lua code logic in the loop will need to periodically printbuffer() the data.
The loop would need to keep track of what values have already been written, and adjust the start and stop index used by the printbuffer().
Printing something to the output queue will cause the MAV bit in the status byte to go to logic 1 and in response the PC could do a VISA read to offload the content.
The downside to this approach would be the introduction of loop time variation for when you do or don't invoke printbuffer().
So in general, I do not like this approach unless jitter is acceptable.

Alternate approach would be to use trigger blocks and a timer and source config lists to make a background task that does the analog sourcing at desired intervals and measuring at other intervals. And then you could have a get_data function the the PC calls at certain intervals when you want to update your user interface on the PC side.

For some of our DMM products, we have a couple samples that illustrate some of these concepts of having trigger blocks running the task and separate means for PC side interaction. Here are some links:

DMM6500 data streaming:
https://github.com/tektronix/keithley/t ... _Triggered

DMM6500 or DMM7510 long running Amp-Hr:
https://github.com/tektronix/keithley/b ... -Hours.tsp


For the SourceMeter, the trigger block setup will be quite different, but there is still some helpful content in the links.

Post Reply

Return to “2450/2460/2461/2470 Touchscreen SourceMeter”

Who is online

Users browsing this forum: No registered users and 3 guests