%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User example %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Name : Starter_USWave_English_R0.m
% Date : 10/09/2013
% Written by : Aimeric Delage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Description : This script includes all functions of the DLL called US-Wave.dll with for each function : 
% calling prototype, an example and comments on the possible values (see the DLL documentation that you  
% can find in the repertory C:\US-Wave for more information)
% Before to use this script, make sure Matlab software is configured to call the DLL (the procedure  
% is described in the doc, see Matlab part) 
% Parameters which can be modified by the user are indicated by comments.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Declaration of input/output tables used by the dll %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    Tableau_In(1000000) = uint16(0);                                 % Input table (16 bits)
    Tableau_Out(1000000) = uint16(0);                                % Output table (16 bits)


%%%%%%%%%%%%%%%
% DLL loading %
%%%%%%%%%%%%%%%

    loadlibrary('C:\US-Wave\US-Wave.dll','C:\US-Wave\US-Wave.h','alias','US-Wave')


%%%%%%%%%%%%
% Init USB %
%%%%%%%%%%%%

    Fonction = 'Init USB';                                          % Function name
    Tableau_In(1) = 1;                                              % Type of table (1D or 2D)                                 
    Tableau_In(2) = 0;                                              % Number of elements by line
    Tableau_In(3) = 0;                                              % Number of lines

    [Code_Retour Nom_Fonction Tableau_Entree Tableau_Sortie] = calllib('US-Wave','USWave',uint16(0),Fonction,Tableau_In,Tableau_Out);

    
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Standard Acquisition Mode %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%
% Mode %
%%%%%%%%

    Fonction = 'Mode';                                              % Function name
    Tableau_In(1) = 1;                                              % 1D table                                
    Tableau_In(2) = 1;                                              % One element
    Tableau_In(3) = 1;                                              % One line

    %% Editable parameter  %%
    Tableau_In(4) = 0;                                              % Select the operating mode (0 => Pulse Echo or 1 => Pitch and Catch)
    %%
    [Code_Retour Nom_Fonction Tableau_Entree Tableau_Sortie] = calllib('US-Wave','USWave',uint16(0),Fonction,Tableau_In,Tableau_Out);


%%%%%%%%%%%%%%%%%%%
% Input Impedance %
%%%%%%%%%%%%%%%%%%%

    Fonction = 'Input Impedance';                                   % Function name
    Tableau_In(1) = 1;                                              % 1D table                               
    Tableau_In(2) = 1;                                              % One element
    Tableau_In(3) = 1;                                              % One line

    %% Editable parameter %%
    Tableau_In(4) = 1;                                              % Select the receiver input impedance
                                                                    % (0 => 50 Ohms, 1 => 100 Ohms, 2 => 200 Ohms or 3 => 6K Ohms)
    %%
    [Code_Retour Nom_Fonction Tableau_Entree Tableau_Sortie] = calllib('US-Wave','USWave',uint16(0),Fonction,Tableau_In,Tableau_Out);


%%%%%%%%%%%%%%%%%%%%%
% Transmitting Mode %
%%%%%%%%%%%%%%%%%%%%%

    Fonction = 'Transmitting Mode';                                 % Function name
    Tableau_In(1) = 1;                                              % 1D table                               
    Tableau_In(2) = 1;                                              % One element
    Tableau_In(3) = 1;                                              % One line

    %% Editable parameter %%
    Tableau_In(4) = 0;                                              % Select the transmitting mode (the type of transmitter)
                                                                    % (0 => Internal Analog, 1 => Pulse or 2 => External Analog)
    %%
    [Code_Retour Nom_Fonction Tableau_Entree Tableau_Sortie] = calllib('US-Wave','USWave',uint16(0),Fonction,Tableau_In,Tableau_Out);


%%%%%%%%%
% Width %
%%%%%%%%%

    Fonction = 'Width';                                             % Function name
    Tableau_In(1) = 1;                                              % 1D table                               
    Tableau_In(2) = 1;                                              % One element
    Tableau_In(3) = 1;                                              % One line

    %% Editable parameter %%
    Tableau_In(4) = 1;                                              % Transmission pulse width by step of 8 ns (from the value 5) 
                                                                    % (1 => 36 ns, 2 => 54 ns, 3 => 68 ns, 4 => 78 ns, ...)
    %%
    [Code_Retour Nom_Fonction Tableau_Entree Tableau_Sortie] = calllib('US-Wave','USWave',uint16(0),Fonction,Tableau_In,Tableau_Out);


%%%%%%%%%%%%%%%%%%%%%%
% Transmitting Delay %
%%%%%%%%%%%%%%%%%%%%%%

    Fonction = 'Transmitting Delay';                                % Function name
    Tableau_In(1) = 1;                                              % 1D table                           
    Tableau_In(2) = 1;                                              % One element
    Tableau_In(3) = 1;                                              % One line

    %% Editable parameter %%
    Tableau_In(4) = 0;                                              % Delay value between the synchro signal and the beginning of the transmission signal
                                                                    % Adjustable by step of 8 ns
                                                                    % (0 => 28 ns, 1 => 36 ns, 2 => 44 ns, ...)
    %%                                                            
    [Code_Retour Nom_Fonction Tableau_Entree Tableau_Sortie] = calllib('US-Wave','USWave',uint16(0),Fonction,Tableau_In,Tableau_Out);


%%%%%%%%%%%%%%%%%%
% Sampling Delay %
%%%%%%%%%%%%%%%%%%

    Fonction = 'Sampling Delay';                                    % Funcrion name
    Tableau_In(1) = 1;                                              % 1D table                            
    Tableau_In(2) = 1;                                              % One element
    Tableau_In(3) = 1;                                              % One line

    %% Editable parameter %%
    Tableau_In(4) = 0;                                              % Delay value between the synchro signal and the beginning of the sampling window  
                                                                    % Adjustable by step of the sampling frequency
                                                                    % (0 => no delay, 1 => 1*(1/SampFreq), 2 => 2*(1/SampFreq), ... )
    %%                                                            
    [Code_Retour Nom_Fonction Tableau_Entree Tableau_Sortie] = calllib('US-Wave','USWave',uint16(0),Fonction,Tableau_In,Tableau_Out);

    
%%%%%%%%
% Gain %
%%%%%%%%

    Fonction = 'Gain';                                              % Function name
    Tableau_In(1) = 1;                                              % 1D table                                
    Tableau_In(2) = 1;                                              % One element
    Tableau_In(3) = 1;                                              % One line

    %% Editable parameter %%
    Tableau_In(4) = 20;                                             % Amplifier gain value in dB
                                                                    % Gain range : 0 dB to 80 dB with a variation step of 1 dB                                                             
    %%                                                            
    [Code_Retour Nom_Fonction Tableau_Entree Tableau_Sortie] = calllib('US-Wave','USWave',uint16(0),Fonction,Tableau_In,Tableau_Out);
    
    
%%%%%%%%%%%%%%
% Gain Curve %
%%%%%%%%%%%%%%

    Fonction = 'Gain Curve';                                        % Function name
    Tableau_In(1) = 1;                                              % 1D table                                
    Tableau_In(2) = 2048;                                           % 2048 elements
    Tableau_In(3) = 1;                                              % One line

    %% Editable parameters %%
    Tableau_In(3+1) = 20;                                           % Gain in dB before the gain curve (one point)         

    for i=2:70
        Tableau_In(3+i) = 30;                                       % Table which contains gain curve points (here 30 dB)
    end

    for i=71:2041
        Tableau_In(3+i) = 40;                                       % Table which contains other gain curve points (here 40 dB)
    end

    for i=2042:2048
        Tableau_In(3+i) = 20;                                       % Gain after the gain curve (for the worst case 0 dB, you 
    end                                                             % must have 6 points with the desired value ; see documentation for more information)

    plot(Tableau_In(4:2051));                                       % A view of the gain curve
    %%
    %[Code_Retour Nom_Fonction Tableau_Entree Tableau_Sortie] = calllib('US-Wave','USWave',uint16(0),Fonction,Tableau_In,Tableau_Out);
    
    
%%%%%%%%%%%%%%%%%%%%
% Gain Curve Delay %
%%%%%%%%%%%%%%%%%%%%

    Fonction = 'Gain Curve Delay';                                  % Function name
    Tableau_In(1) = 1;                                              % 1D table                               
    Tableau_In(2) = 1;                                              % One element
    Tableau_In(3) = 1;                                              % One line

    %% Editable parameter %%
    Tableau_In(4) = 0;                                              % Delay value between the synchro signal and the beginning of the gain curve
                                                                    % Adjustable by step of the sampling frequency
                                                                    % (0 => no delay, 1 => 1*(1/SampFreq), 2 => 2*(1/SampFreq), ... )
    %%                                                            
    [Code_Retour Nom_Fonction Tableau_Entree Tableau_Sortie] = calllib('US-Wave','USWave',uint16(0),Fonction,Tableau_In,Tableau_Out);


%%%%%%%%%%%%%%%%%%%%%%
% Sampling Frequency %
%%%%%%%%%%%%%%%%%%%%%%

    Fonction = 'Sampling Frequency';                                % Function name
    Tableau_In(1) = 1;                                              % 1D table                               
    Tableau_In(2) = 1;                                              % One element
    Tableau_In(3) = 1;                                              % One line

    %% Editable parameter %%
    Tableau_In(4) = 0;                                              % Select the sampling frequency
                                                                    % (0 => 125 MHz, 1 => 75 MHz, 2 => 50 MHz, 3 => 25 MHz,
                                                                    %  4 => 10 MHz, 5 => 5 MHz, 6 => External frequency)  
    %%                                                            
    [Code_Retour Nom_Fonction Tableau_Entree Tableau_Sortie] = calllib('US-Wave','USWave',uint16(0),Fonction,Tableau_In,Tableau_Out);


%%%%%%%
% PRF %
%%%%%%%

    Fonction = 'PRF';                                               % Function name
    Tableau_In(1) = 1;                                              % 1D table                               
    Tableau_In(2) = 1;                                              % One element
    Tableau_In(3) = 1;                                              % One line

    %% Editable parameter %%
    Tableau_In(4) = 5000;                                           % PRF value by step of 200 ns (defined the time between two transmission signals)  
                                                                    % (ex : 5000 * 200 ns = 1 ms; 1 ms => 1 KHz)
    %%                                                                                                                        
    [Code_Retour Nom_Fonction Tableau_Entree Tableau_Sortie] = calllib('US-Wave','USWave',uint16(0),Fonction,Tableau_In,Tableau_Out);


%%%%%%%%%%%
% Trigger %
%%%%%%%%%%%

    Fonction = 'Trigger';                                           % Function name
    Tableau_In(1) = 1;                                              % 1D table                           
    Tableau_In(2) = 1;                                              % One element
    Tableau_In(3) = 1;                                              % One line

    %% Editable parameter %%
    Tableau_In(4) = 0;                                              % Select the trigger mode for the transmission signals
                                                                    % (0 => Soft, 1 => Internal or 2 => External)  
    %%                                                             
    [Code_Retour Nom_Fonction Tableau_Entree Tableau_Sortie] = calllib('US-Wave','USWave',uint16(0),Fonction,Tableau_In,Tableau_Out);
  
    
%%%%%%%%%%%%%%%%%%%%%%
% Transmitting Curve %
%%%%%%%%%%%%%%%%%%%%%%

    Fonction = 'Transmitting Curve';                                % Function name
    Tableau_In(1) = 1;                                              % Tableau 1D                                
    Tableau_In(2) = 64000;                                          % 64 000 elements
    Tableau_In(3) = 4;                                              % 4 lines
    
    %% DAC parameters %%
    Fe = 125e+06;                                                   % Sampling frequency for the Digital Analog Converter (used to create the analog signal) 
    Nb_Bits = 12;                                                   % Number of bits of the DAC
    Y = 2^Nb_Bits / 2;                                              % Reference 0 (2048 => 0 Volt)
    Phi = 0;                                                        % Dephasing in degrees
    Phi = Phi*pi/180;                                               % Dephasing calculation   

    %% Editable parameters %%

    % Pattern N°1 %
    F0 = 1e+06;                                                     % Center frequency of the signal (here 1 MHz)
    N0 = round(Fe/F0);                                              % Calculation of the number of points in the signal
    t0 = [0:1/Fe:(N0-1)/Fe];                                        % Time vector
    s0 = 0.5 * sin(2*pi*F0*t0+Phi);                                 % Signal vector (0.5 => transmission signal between +Vmax/2 and -Vmax/2)
    s0 = Y + s0 * (Y - 1);                                          % Signal vector with an offset of 0        
    s0 = [s0,2048];                                                 % Reset signal (the signal must start and finish by 2048)
    N0 = N0 + 1;                                                    % Update signal size

    % Pattern N°2 %
    F1 = 2e+06;                                                     % Center frequency of the signal (here 2 MHz)
    N1 = round(Fe/F1);                                              % Calculation of the number of points in the signal
    t1 = [0:1/Fe:(N1-1)/Fe];                                        % Time vector
    s1 = -0.9 * sin(2*pi*F1*t1+Phi);                                % Signal vector
    s1 = Y + s1 * (Y - 1);                                          % Signal vector with an offset of 0 
    s1 = [s1,2048];                                                 % Reset signal (the signal must start and finish by 2048)
    N1 = N1 + 1;                                                    % Update signal size

    % Pattern N°3 %
    F2A = 3e+06;                                                    % Center frequency of the signal (here 3 MHz)
    N2A = round(Fe/F2A);                                            % Calculation of the number of points in the signal
    t2A = [0:1/Fe:(N2A-1)/Fe];                                      % Time vector
    s2A = 0.6 * sin(2*pi*F2A*t2A+Phi);                              % Signal vector
    s2A = Y + s2A * (Y - 1);                                        % Signal vector with an offset of 0 

    F2B = 1e+06;                                                    % Center frequency of the signal (here 1 MHz)
    N2B = round(Fe/F2B);                                            % Calculation of the number of points in the signal
    t2B = [0:1/Fe:(N2B-1)/Fe];                                      % Time vector
    s2B = 0.6 * sin(2*pi*F2B*t2B+Phi);                              % Signal vector
    s2B = Y + s2B * (Y - 1);                                        % Signal vector with an offset of 0 
    s2B = [s2B,2048];                                               % Reset signal (the signal must start and finish by 2048)
    N2B = N2B + 1;                                                  % Update signal size

    s2 = [s2A,s2B];                                                 % Signal vector for the pattern N°3
    N2 = N2A + N2B ;                                                % Update signal size

    s = [s0,s1,s2];                                                 % The three patterns are combined into a single vector
    [L C] = size(s);

    for i=1:C
        Tableau_In(3+i) = s(i);                                     % Writing points into the transfer table
    end

    for i=C+1:256000
        Tableau_In(3+i) = 2048;                                     % The not used points are fixed to 2048 (0 Volt)
    end
    %%
    [Code_Retour Nom_Fonction Tableau_Entree Tableau_Sortie] = calllib('US-Wave','USWave',uint16(0),Fonction,Tableau_In,Tableau_Out);

    
%%%%%%%%%%%
% Data RF %
%%%%%%%%%%%

    Fonction = 'Data RF';                                           % Function name
    Tableau_In(1) = 1;                                              % 1D table                                
    Tableau_In(2) = 1;                                              % One element
    Tableau_In(3) = 1;                                              % One line

    %% Editable parameter %%
    Tableau_In(4) = 16384;                                          % Number of samples                                         
    %%
    [Code_Retour Nom_Fonction Tableau_Entree Tableau_Sortie] = calllib('US-Wave','USWave',uint16(0),Fonction,Tableau_In,Tableau_Out);

    Type_Tableau = Tableau_Sortie(1);                               % Return the table type
    Nb_Data = Tableau_Sortie(2);                                    % Return the number of elements (here 16384)
    Nb_Ligne = Tableau_Sortie(3);                                   % Return the number of lines (here 1)

    %% Editable parameters %%
    Nb_Data = Nb_Ligne * Nb_Data;                                   % Number of data to read
    Nb_Acquisitions = 1000;                                         % Number of acquisitions required
    Nb_Samples_Display = 16384;                                     % Number of samples to display
    %%
    
    for i=1:Nb_Acquisitions

        [Code_Retour Nom_Fonction Tableau_Entree Tableau_Sortie] = calllib('US-Wave','USWave',uint16(0),Fonction,Tableau_In,Tableau_Out);
        Offset_Data = double(Tableau_Sortie(4:(Nb_Data+3))) - double(32768);
        plot(Offset_Data * double(0.00003052)); 
        xlabel('Samples','FontSize',14);
        ylabel('Volts','FontSize',14);
        title('ADC input (Mode Standard)','FontSize',14);
        axis([1 Nb_Samples_Display -1 1]);
        drawnow;

    end

    
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Sequencer Acquisition Mode %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
%%%%%%%%%%%%%%%%%%
% Load Sequencer %
%%%%%%%%%%%%%%%%%%

    Fonction = 'Load Sequencer';                                    % Function name
    Tableau_In(1) = 1;                                              % 1D table                                
    Tableau_In(2) = 2048;                                           % 2048 elements
    Tableau_In(3) = 1;                                              % One line

    %% Editable parameters %%

    % Common parameters to all sequences %
    Tableau_In(4) = 3;                                              % Number of patterns and so of sequences (here 3 sequences)       
    Tableau_In(5) = 1;                                              % Trigger (Internal = 1 or External = 2)     
    Tableau_In(6) = 10000;                                          % PRF (10000 => 500 Hz)        
    Tableau_In(7) = 0;                                              % Not used for this moment                                             
    Tableau_In(8) = 0;                                              % Operating mode (0 => Pulse Echo or 1 => Pitch and Catch)   
    Tableau_In(9) = 0;                                              % Not used for this moment 

    % Parameters for the first sequence (pattern N°1) %
    Tableau_In(10) = 1;                                             % Number of acquisitions for this sequence (here one with the pattern N°1) 
    Tableau_In(11) = 126+3;                                         % Number of points in the pattern (always add 3 to the real number of points) 
    Tableau_In(12) = 0;                                             % Transmitting delay       
    Tableau_In(13) = 0;                                             % Sampling delay                                             
    Tableau_In(14) = 15;                                            % Gain   
    Tableau_In(15) = 100;                                           % Number of bursts in the sampling window (One burst = 1024 samples)
    Tableau_In(16) = 0;                                             % Sampling frequency (0 => 125 MHz)
    Tableau_In(17) = 1;                                             % Input impedance (1 => 100 Ohms)
    Tableau_In(18) = 0;                                             % Start address for the pattern N°1 in the memory (here 0 because it's the first pattern)

    % Parameters for the second sequence (pattern N°2) %
    Tableau_In(19) = 1;                                             % Number of acquisitions for this sequence (here one with the pattern N°2) 
    Tableau_In(20) = N1+3;                                          % Number of points in the pattern (always add 3 to the real number of points)
    Tableau_In(21) = 0;                                             % Transmitting delay        
    Tableau_In(22) = 0;                                             % Sampling delay                                                
    Tableau_In(23) = 30;                                            % Gain   
    Tableau_In(24) = 200;                                           % Number of bursts in the sampling window
    Tableau_In(25) = 0;                                             % Sampling frequency 
    Tableau_In(26) = 0;                                             % Input impedance (0 => 50 Ohms)
    Tableau_In(27) = N0;                                            % Start address for the pattern N°2 in the memory (N0 = 126)

    % Parameters for the third sequence (pattern N°3) %
    Tableau_In(28) = 1;                                             % Number of acquisitions for this sequence (here one with the pattern N°3) 
    Tableau_In(29) = N2+3;                                          % Nombre de points dans le motif (+3)
    Tableau_In(30) = 0;                                             % Transmitting delay        
    Tableau_In(31) = 0;                                             % Sampling delay                                               
    Tableau_In(32) = 20;                                            % Gain   
    Tableau_In(33) = 100;                                           % Number of bursts in the sampling window
    Tableau_In(34) = 0;                                             % Sampling frequency
    Tableau_In(35) = 0;                                             % Input impedance
    Tableau_In(36) = N0+N1;                                         % Start address for the pattern N°3 in the memory (N0+N1 = 190)

    for i=34:2048
        Tableau_In(3+i) = 0;                                        % Reset all other parameters
    end
    %%
    [Code_Retour Nom_Fonction Tableau_Entree Tableau_Sortie] = calllib('US-Wave','USWave',uint16(0),Fonction,Tableau_In,Tableau_Out);


%%%%%%%%%%%%%%%%%
% Exe Sequencer % 
%%%%%%%%%%%%%%%%%

    Fonction = 'Exe Sequencer';                                     % Function name
    Tableau_In(1) = 1;                                              % 1D table                               
    Tableau_In(2) = 1;                                              % One element
    Tableau_In(3) = 1;                                              % One line

    [Code_Retour Nom_Fonction Tableau_Entree Tableau_Sortie] = calllib('US-Wave','USWave',uint16(0),Fonction,Tableau_In,Tableau_Out);


%%%%%%%%%%%%%%%
% Read Memory %
%%%%%%%%%%%%%%%

    Fonction = 'Read Memory';                                       % Function name
    Tableau_In(1) = 1;                                              % 1D table                                
    Tableau_In(2) = 3;                                              % 3 elements
    Tableau_In(3) = 1;                                              % One line
    
    %% Editable parameters %%
    Tableau_In(4) = 400;                                            % Number of bursts to read (One burst = 1024 samples)
    Tableau_In(5) = 0;                                              % Row number to choose the first burst to read
    Tableau_In(6) = 0;                                              % Column number to choose the first burst to read
    %%
    [Code_Retour Nom_Fonction Tableau_Entree Tableau_Sortie] = calllib('US-Wave','USWave',uint16(0),Fonction,Tableau_In,Tableau_Out);

    Type_Tableau = Tableau_Sortie(1);                               % Return the type of table
    Nb_Burst = Tableau_Sortie(2);                                   % Return the number of elements
    Nb_Ligne = Tableau_Sortie(3);                                   % Return the number of lines
    
    Nb_Data = 400*1024;                                             % Number of samples to display (here 400 bursts)    
    
    figure;
    
    Offset_Data = double(Tableau_Sortie(4:(Nb_Data+3))) - double(32768);
    plot(Offset_Data * double(0.00003052)); 
    xlabel('Samples','FontSize',14);
    ylabel('Volts','FontSize',14);
    title('ADC input','FontSize',14);
    axis([1 1024 -1 1]);
   
 % Example with a "Exe Sequencer" follow by a "Read Memory" 
 
    for i=1:120

        Fonction = 'Exe Sequencer';                                     % Function name
        [Code_Retour Nom_Fonction Tableau_Entree Tableau_Sortie] = calllib('US-Wave','USWave',uint16(0),Fonction,Tableau_In,Tableau_Out);
        Fonction = 'Read Memory';                                       % Function name
        [Code_Retour Nom_Fonction Tableau_Entree Tableau_Sortie] = calllib('US-Wave','USWave',uint16(0),Fonction,Tableau_In,Tableau_Out);
        Offset_Data = double(Tableau_Sortie(4:(Nb_Data+3))) - double(32768);
        plot(Offset_Data * double(0.00003052)); 
        xlabel('Samples','FontSize',14);
        ylabel('Volts','FontSize',14);
        title('ADC input (Mode séquenceur)','FontSize',14);
        axis([1 Nb_Data -1 1]);
        drawnow;

    end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%