LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Screen capture on tps2000 series oscilloscopes

Solved!
Go to solution

Hi,

 

I have been been trying to solve this problem for the past few days. I have a Tektronixs TPS2024B oscilliscope that uses RS232 to communicate with Labview 8.0 and 2012 (both have same result). The goal is to obtain a screen capture using Tek's HARDCOPY commands. I can reicive a bitmap but it's only a portion of the bitmap and the rest is black. See picture and code below.

 

You can see the oscilliscope take the hardcopy and there are obviously bytes being written to the bitmap file from the read buffer. I have been trying to place delays all over the place to see if that was the issue but with no avail. 

 

Anyone have any suggestions? Thanks.

 

 

0 Kudos
Message 1 of 11
(3,520 Views)
Solution
Accepted by topic author abeaver

Instead of reading 1 million Bytes, read a few hundred at a time in a tight loop.

0 Kudos
Message 2 of 11
(3,511 Views)

And just concatenate the read buffer each time? How do you know when to stop?

0 Kudos
Message 3 of 11
(3,506 Views)

You might want to check out this thread on performing a screen capture on the MSO4k series scope:http://forums.ni.com/t5/Instrument-Control-GPIB-Serial/Screen-capture-of-Tektronix-MSO4104B-using-La...

 

But since you are using serial, you need to read the data a lot more quickly to avoid the serial buffer from overflowing.  Send the Hardcopy Start command and then inside of a while loop just read 1MB data (or whatever your serial buffer size actually is).  Use a decently long timeout on the VISA Read (a little longer than it will take to move the 1MB of data over the serial port).  Take the string out of the VISA Read and write it directly to disk.  USE NO WAITS INSIDE OF THIS LOOP.  You will exit your loop when you have a timeout on the VISA read.

 

You will also want to open the file before starting the loop and close it after the loop.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 11
(3,500 Views)

@crossrulz wrote:

You might want to check out this thread on performing a screen capture on the MSO4k series scope:http://forums.ni.com/t5/Instrument-Control-GPIB-Serial/Screen-capture-of-Tektronix-MSO4104B-using-La...

 

But since you are using serial, you need to read the data a lot more quickly to avoid the serial buffer from overflowing.  Send the Hardcopy Start command and then inside of a while loop just read 1MB data (or whatever your serial buffer size actually is).  Use a decently long timeout on the VISA Read (a little longer than it will take to move the 1MB of data over the serial port).  Take the string out of the VISA Read and write it directly to disk.  USE NO WAITS INSIDE OF THIS LOOP.  You will exit your loop when you have a timeout on the VISA read.

 

You will also want to open the file before starting the loop and close it after the loop.


 

0 Kudos
Message 5 of 11
(3,490 Views)

@Todd_Lesher wrote:

Instead of reading 1 million Bytes, read a few hundred at a time in a tight loop.


Here is how I did it. Unfortunately it takes about 25 seconds to transfer 20KB of data with a 9600 BR. Would anybody know why that is or how to speed it up?

 

Hopefully, this will save people loads of time in the future...

 

tps2000screener.PNG

 

functiontest.png

0 Kudos
Message 6 of 11
(3,481 Views)

I optimized my solution a little bit more to detect an error timeout rather than cacluating times. Errors are generated during the inner while loop because the VISA read reads exacly 150 bytes... that is more of a warning than an error. 

 

Also I "flush" the serial line by reading 1MB in the flushserial.vi before calling the tps2000screener.vi. 

 

new.PNG

Download All
0 Kudos
Message 7 of 11
(3,436 Views)

I don't see the point of the sequence structure inside of your case structure.  There's nothing in there that needs sequenced.  Just trying to help clean stuff up.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 8 of 11
(3,430 Views)

Yeah, not required. As you can see from the previous post it was left over from my timing structures. Good catch

0 Kudos
Message 9 of 11
(3,425 Views)

@abeaver wrote:
. Unfortunately it takes about 25 seconds to transfer 20KB of data with a 9600 BR. Would anybody know why that is or how to speed it up?

 


That sounds about right.  9600 baud means 9600 bits/second.  There are about 10 bits per byte, so 960 bytes per second.  We'll round to a thousand.

 

20kB means it will take more than 20 seconds.

0 Kudos
Message 10 of 11
(3,421 Views)