Timeout error with Visa Device
32 views (last 30 days)
Show older comments
Hi,
im using Matlab 2202b and sucessfuly established a TCPIP connection to my oscilloscope using visadev. I was using the programming guide of the scope to receive data. Here is a very simple example of my code:
obj = visadev('TCPIP0::192.168.1.2::inst0::INSTR');
obj.Timeout = 30;
fopen(obj);
fwrite(obj, 'WAV:STAR 1');
fwrite(obj, sprintf('WAV:POIN %i', 1000));
fwrite(obj, sprintf('WAV:SOUR C%i', 1));
fwrite(obj, 'WAV:DATA?');
data = fread(obj);
% data = binblockread(obj,'int8');
clear(obj);
Short explaination: open visa device, start transmitting at waveform sample 1, transfer 1000 samples, asking for data and using fread or binblockread to read the data. The 'WAV:DATA?' command stopps the scope and queries for the (binblock)data. This works very well at my computer without any dependencies of the scope settings (timebase of the scope for example). The scope is connectd to the computer with a lan cable and a switch in between. Both devices are within the same subnetmask, the computer is using the ip address 192.168.1.1.
Now I was changing the location. Same Scope, other Laptop and Matlab version 2022a. In this case, the Laptop is directly connected to the scope via LAN cable. The communication between the two devices works very well but only in dependence of the timebase settings of the scope. If the timebase is low, lets say below 1ms, I can receive data using the script above. If I increase the timebase (the acquisition time of the scope is getting slower), i get a timout error of fread. The same script which works an my laptop causes problems now on an other one. The timeout error message appears very fast after im using the fread command. Much faster than 30 seconds, defined at the visa device. How can this happen? Binblockread also returns an error: "wrong format". Of course, binblockread is expecting something starting with #9... but did not get any values. I guess is the same timeout problem.
I was searching for hours yesterday to solve this problem, but did not find any solution. There is also an Python example at the programming guide page 638 but there are no big differences compared to my script (but i also have no experience with python). Do you have any idea?
0 Comments
Answers (2)
chrisw23
on 25 Jan 2023
Edited: chrisw23
on 25 Jan 2023
Consider the following scope states
trigger system < pretrigger / trigger ready / triggered >
acquisition system <startFromTrigger / running / complete>
The scope status subsystem can be configured to send a ServiceRequest on certain conditions (i.e. trigger occurred).
It's important to know the scope state before you request the WFM data. For long timebase values the time to the trigger ready state (pretrigger intervall) and the time between triggered and acquisition complete state can be very long.
It's seems you send the WFM request during active data acquisition which may lead to device dependent errors.
0 Comments
hyxamp
on 25 Jan 2023
Edited: hyxamp
on 25 Jan 2023
1 Comment
chrisw23
on 25 Jan 2023
Edited: chrisw23
on 25 Jan 2023
The acquisition complete detection depends on how you arm the trigger. In example, if you use the single sequence acquisition you would expect the STOP state as an indicator for the completed acquisition. So query the trigger state is the right method but you have to know what's expected.
Here are Tektronix trigger states
% ARMED indicates that the oscilloscope is acquiring pretrigger information.
% AUTO indicates that the oscilloscope is in the automatic mode and acquires data even in the absence of a trigger.
% READY indicates that all pretrigger information has been acquired and that the oscilloscope is ready to accept a trigger.
% SAVE indicates that the oscilloscope is in save mode and is not acquiring data.
% TRIGGER indicates that the oscilloscope triggered and is acquiring the post trigger information.
A hint to the "wrong format" exception. Be sure that the device (scope) output buffer is empty before any new query. I'm not using the toolbox but maybe there is a Flush command. I'm using IviVisa via .net.
See Also
Categories
Find more on Instrument Control Toolbox Supported Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!