octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #58252] [octave forge] (instrument-control) us


From: anonymous
Subject: [Octave-bug-tracker] [bug #58252] [octave forge] (instrument-control) ustmc_read() does not read all the waveform data from oscilloscope
Date: Tue, 28 Apr 2020 18:59:52 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0

Follow-up Comment #2, bug #58252 (project octave):

%% Octave version:
>> version
ans = 4.2.2

%% Octave packages installed:
>> pkg list
Package Name        | Version | Installation directory
--------------------+---------+-----------------------
           control *|   3.2.0 | /home/waltersjursen/octave/control-3.2.0
instrument-control *|   0.5.0 |
/home/waltersjursen/octave/instrument-control-0.5.0
            signal  |   1.4.1 | /home/waltersjursen/octave/signal-1.4.1

%% Get an FID for the oscilloscope:
>> scope=usbtmc('/dev/usbtmc0')
scope = 40

%% run a script to get the waveform from the oscilloscope:
>> test3
nChar = 107530 % this is the number of characters that are requested in the
usbtmc_write().
>> whos
Variables in the current scope:

   Attr Name             Size                     Bytes  Class
   ==== ====             ====                     =====  =====
        Xtime            1x7680                   61440  double
        Xtrigger         1x1                          8  double
        Ydata            0x0                          0  double
        ans              1x1                          8  double
        chan             1x1                          8  double
        cmd              1x15                        15  char
        count            1x1                          8  double
        dataFormat       1x10                        80  double
        data_raw         1x2                          2  uint8
        data_str         1x0                          0  char
        format           1x1                          8  double
        mode             1x4                          4  char
        nChar            1x1                          4  uint32
        nFormatRead      1x1                          8  double
        nRead            1x1                          8  double
        points           1x1                          8  double
        scope            0x0                          0  octave_usbtmc
        type             1x1                          8  double
        xincrement       1x1                          8  double
        xorigin          1x1                          8  double
        xreference       1x1                          8  double
        yincrement       1x1                          8  double
        yorigin          1x1                          8  double
        yreference       1x1                          8  double

Total is 7727 elements using 61665 bytes

%% Q. What is the output from usbtmc_write(scope,':WAV:PRE?') read? 
%% A. Here is a snippet of test3.m

usbtmc_write(scope,':WAV:PRE?');
[dataFormat, nFormatRead] = usbtmc_read(scope, 200);
dataFormat = str2num(char(dataFormat));

format     = dataFormat(1);
type       = dataFormat(2);
points     = dataFormat(3);
count      = dataFormat(4);
xincrement = dataFormat(5);
xorigin    = dataFormat(6);
xreference = dataFormat(7);
yincrement = dataFormat(8);
yorigin    = dataFormat(9);
yreference = dataFormat(10);

%% and the data it returned:
>> nFormatRead
nFormatRead =  86       % number of characters read (returned)
>> dataFormat
dataFormat =

   4.0000e+00   3.0000e+00   7.6800e+03   1.0000e+00   2.6042e-07  -1.0000e-03
  0.0000e+00   7.8518e-04   0.0000e+00   3.2768e+04

%% interpreting the returned data:
format     = 4           % return data format (WORD|BYTE|ASCII) The manual
does not define "4", but the data was returned in ASCII.
type       = 3           % the acquisition mode of the scope is HiRes
points     = 7680        % number of data points available from the scope
count      = 1           % 1 indicates not in Average mode
xincrement = 2.6042e-07  % sample rate = 1/xincrement
xorigin    = -0.0010000  % first data point is 1ms before the trigger point
xreference = 0           % index of data at xorigin
yincrement = 7.8518e-04  % resolution of y-axis
yorigin    = 0           % y-axis value at center of oscilloscope screen
yreference = 32768       % data point value at yorigin, but not meaningful if
data is in ASCII format
 

%% Q. What is the output from the ":WAVeform?" query?
%% A. There is no generic ":WAVeform?" query defined.


%% Q. What is the output from the ":ACQuire:POINts?" query?
%% A. After running the 'test3.m' script, I manually queried the scope. It
returned:

>> acq_points = usbtmc_write(scope,':ACQuire:POINTs?')
acq_points =  16



%% Q. What is the output data from usbtmc_write(scope,':WAV:DATA?') read when
it returns only 2 bytes?
%% A. The code snippet to read the data and the return data follow:

usbtmc_write(scope,':WAV:DATA?');
nChar = uint32(10 + 14*points);
nChar=uint32(nChar);
[data_raw, nRead] = usbtmc_read(scope,nChar);
data_str = char(data_raw(11:length(data_raw)));

%% The returned data is:

>> nRead
nRead =  2
>> data_raw
data_raw =
  35  5
>> char(data_raw)
ans = #8
>>

%% Note that the "#8" is the beginning of the header that defines how many
characters are going to be returned.
%% Return data has the form:
#800107519-2.26131e-001,-2.26131e-001,-2.01005e-001,-2.26131e-001,-1.75879e-001,...
%% where the '#' is the start of the header, the next character '8' indicates
the next 8 characters provide the number of bytes (characters)
%% of data that follow. In this example, the first data point is -0.226131
volts.
 

%% I rebooted the system, added a few extra statements into the test3.m script
and ran it again. This time it returned more than 2 characters,
%% but still not all.

%% new lines of code before reading the waveform data:

% added for debugging...
acq_points = usbtmc_write(scope,':ACQuire:POINTs?')
wav_points_mode = usbtmc_write(scope,':WAVeform:POINTs:MODE?')
wav_points = usbtmc_write(scope,':WAVeform:POINTs?')

acq_points =  16
wav_points_mode =  22
wav_points =  17

>> nChar
nChar = 107530
>> whos
Variables in the current scope:

   Attr Name                 Size                     Bytes  Class
   ==== ====                 ====                     =====  =====
        Xtime                1x7680                   61440  double
        Xtrigger             1x1                          8  double
        Ydata                1x571                     4568  double
        acq_points           1x1                          8  double
        ans                  1x1                          8  double
        chan                 1x1                          8  double
        cmd                  1x15                        15  char
        count                1x1                          8  double
        dataFormat           1x10                        80  double
        data_raw             1x8004                    8004  uint8
        data_str             1x7994                    7994  char
        format               1x1                          8  double
        mode                 1x4                          4  char


%% It now read 8004 of the 107530 characters which is 571 of 7680 data points.
:-(

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?58252>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]