Do I need to clear the input buffer of visa object every time when I acquire data from oscilloscope?

7 ビュー (過去 30 日間)
Yujie Xia
Yujie Xia 2021 年 3 月 25 日
回答済み: Pratheek Punchathody 2021 年 3 月 29 日
Hi everyone,
I was trying to write a MATLAB script which plots data from the oscilloscope every couple of seconds until stopped by user. The way it was done was that, in a while loop, commend was sent to the oscillosopce to do a single acquisition. Then data was read using binblockread, and fread was used to remove the terminating character. Then the data were plotted, and the script pause for a few seconds before starting a new acquisition.
I was not sure about one thing: when binblockread reads data from the visa object, does it clear the input buffer? Or, when I do the new acquisition, will old data automatically get overwitten? Will the old data remain in the input buffer, and I end up with a mixture of old and new data every time I do another acquisition?
Ideas, suggestions, or links of useful resources would all be really appreciated. Thanks!

回答 (1 件)

Pratheek Punchathody
Pratheek Punchathody 2021 年 3 月 29 日
As per my understanding during the read and write operations with a VISA Object, the "read" function suspends MATLAB execution when "The input buffer is filled".
You can use "flush" function to clear buffers for communication with the VISA resources.
flush(v,"input"); % flushes only the input buffer of the VISA resource.
Refer to the documentation on Read Binary Data using VSA and Flush for more information.
Hope this helps..!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by