Page 1 of 1

How to clear output queue

Posted: November 4th, 2019, 3:47 am
by mlaursen

I am running TSP scripts on 4 2602B instruments with TSP link. I call the scripts from a VBA macro. In the scripts I make measurements with overlappediv command


I then print the measurements with

printbuffer(1, MaxIterations, smu3.nvbuffer2) --V3
printbuffer(1, MaxIterations, smu3.nvbuffer1) --I3
printbuffer(1, MaxIterations, smu2.nvbuffer2) --V2
printbuffer(1, MaxIterations, smu2.nvbuffer1) --I2
printbuffer(1, MaxIterations, smu4.nvbuffer2) --V4
printbuffer(1, MaxIterations, smu4.nvbuffer1) --I4

To get the measurements into VBA I run a ReadNumber command.

For i = 0 To 4
instrout(i) = instrAny.ReadNumber()
Next i

However, when doing this, the data queue is not cleared. So when I run a second measurement, the first measurement is still in the beginning of the instrout array.

In the TSP scripts there are both smuX.reset and smuX.nvbufferY.clear() in the very beginning of the script.

Re: How to clear output queue

Posted: November 7th, 2019, 3:56 am
by Andrea C
sounds like ReadNumber() is a function you have written? How does it relate to the data in the smuX.nvbufferX?

After you clear the buffer, see if it indeed has cleared. Interrogate the value of smuX.nvbufferX.n

Code: Select all

numberOfReadings = smua.nvbuffer1.n
A typical buffer reset function is below. Call it for each of your SMU, e.g., reset_buffers(node[1].smua)

Code: Select all

function reset_buffers(smu)
    	-- Prepare the Reading Buffers
	smu.nvbuffer1.appendmode		= 1
	smu.nvbuffer1.collecttimestamps	= 1
	smu.nvbuffer2.appendmode		= 1
	smu.nvbuffer2.collecttimestamps	= 1

end  -- function

Re: How to clear output queue

Posted: November 7th, 2019, 5:32 am
by mlaursen
Hi Andrea,

It is a command from a visa communication library

Set instrAny = New VisaComLib.FormattedIO488


The first thing I do in the functions is to clear the buffer.


However, I found a solution with the instrAny.IO.clear in the VBA macro. That appears to fix the problem.