Effacer les filtres
Effacer les filtres

Timeout error with Visa Device

56 vues (au cours des 30 derniers jours)
hyxamp le 24 Jan 2023
Modifié(e) : chrisw23 le 25 Jan 2023
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::');
obj.Timeout = 30;
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');
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
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?

Réponses (2)

chrisw23 le 25 Jan 2023
Modifié(e) : chrisw23 le 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.

hyxamp le 25 Jan 2023
Modifié(e) : hyxamp le 25 Jan 2023
Hi Chris,
good answer, thank you very much! At some parts of my script, Im asking and waiting for the stopped trigger:
iWrite(obj,'TRMD SINGLE');
triggerStat = iQuery(obj, ':TRIGger:STATus?');
while ~strcmp(triggerStat(1:end-1), 'Stop') && ~strcmp(triggerStat(1:end-1), 'FStop')
triggerStat = iQuery(obj, ':TRIGger:STATus?');
iWrite and iQuery are other own functions to send/request data.. I can test this tomorrow for my download function as well. The 'WAV:DATA?' command stopps the scope but you are right. Maybe I should stop the trigger in advance, wait for the stopped trigger and than requesting the data. Unfortunately there is no command to read the acquisition state of the scope. I guess, if the trigger is stoped, the acquisition is done. But im still wondering, why I dont have any problems with my computer. Im a bit confused about the timeout message of fread and why this message appears much faster than my 30 seconds timeout setting.
  1 commentaire
chrisw23 le 25 Jan 2023
Modifié(e) : chrisw23 le 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.

Connectez-vous pour commenter.




Community Treasure Hunt

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

Start Hunting!

Translated by