Station Automation Code

Here is the main script that combines the code work of Jesus, Daniel, and Joshua that automates the station.

% This is a MIC DROP!!!!!
%
% Break the wrist and walk away!
%
% SATFSS
% Danny Boy and JP 
%
% 4/9/2021
% 
% This is our main code. it is used to automate the SATFSS station
% 
% 
% call to the Daniel's go home function to return the stages to a (0,0)  
go_home;
% Ask user for input of NA IP address
ip = input('IP = ');
% created a KEY with calling of Joshua's FFConnectFunction and passing it IP
% address
KEY = FFConnectFunction(ip);
% call Joshua's FFSetup and pass it the KEY
FFSetup(KEY);
% ask user to input matrix dimension then number of sample points
nsite = input('Enter the size of NxN matrix: ');
nsample = input('Enter number of seeding sample points: ');

% create our S-parameter data storage array the size of the user input  
MeasurementField = cell(nsite,nsite);

% establish the variable that will determine where the stages move
tX = floor(lhsu([1 1],[nsite nsite],nsample));
tX = unique(tX,'rows');
nsample = length(tX(:,1));

% create an array for the coordinates
cp = [0 0];

% this is the seeding loop it will run the number of sample points input by
% user
for i = 1:nsample
    dx = tX(i,1) - cp(1,1);
    dxx = round(dx*30*316.5); % calculate pulse
    dy = tX(i,2) - cp(1,2);
    dyy = round(dy*30*316.5); % calculate pulse 
    
% mathematics determines movement left or right, once determined
% Jesus's stages_function is called 
    if dx > 0
        tX(i,1);
        stages_function(dxx,3)
        x = "Move right dx";
        %pause(10);
    else
        tX(i,1);
        stages_function(abs(dxx),4)
        x = "Move left dx";
        %pause(10);
    end
    
% mathematics determines movement up or down, once determined
% Jesus's stages_function is called
    if dy > 0
        tX(i,2);
        stages_function(dyy,1)
        y = "Move up dy";
        pause(15);
        
% KEY is passed to Joshua's ReadSParameters function and outputs data vectors 
% [101x1] for S-parameters in both magnitude and phase,   
        [S11M, S21M, S12M, S22M, S11P, S21P, S12P, S22P] = ReadSParameters(KEY);
        pause(5);
% the vectors are then saved into a matrix variable [101x8] that is inserted into
% the cell array at the location of the measurement 
        SParameters = [S11M, S21M, S12M, S22M, S11P, S21P, S12P, S22P];
        MeasurementField{cp(1,1)+dx,cp(1,2)+dy} = SParameters;
        
%  the same code is run if the z-stage moves down    
    else
        tX(i,2);
        stages_function(abs(dyy),2)
        y = "Move down dy";
        pause(15);
        [S11M, S21M, S12M, S22M, S11P, S21P, S12P, S22P] = ReadSParameters(KEY);
        pause(5);        
        SParameters = [S11M, S21M, S12M, S22M, S11P, S21P, S12P, S22P];
        MeasurementField{cp(1,1)+dx,cp(1,2)+dy} = SParameters;
       
    end
    pause(10);
    cp(1,1) = cp(1,1) + dx;
    cp(1,2) = cp(1,2) + dy;    
   
end