Project tutorial
Matlab/Arduino-Controlled Macro Rail for Macrophotography

Matlab/Arduino-Controlled Macro Rail for Macrophotography © GPL3+

Simple GUI to automate focus stacking used in macrophotography.

  • 2,418 views
  • 3 comments
  • 8 respects

Components and supplies

Proxxon 27100 Micro Compound Table KT 70
×1
A000066 iso both
Arduino UNO & Genuino UNO
×1
Adafruit Motor Shield V2
×1

Apps and online services

About this project

This setup allows me to automate the process of taking several pictures of tiny things that we can’t get in focus with a single shot. Many solutions exist for a “problem” like this and here is my DIY approach. Once done, I use Zerene Stacker (http://zerenesystems.com/cms/stacker) to create a single stacked image of the frames. Most ideas around the setup and the math behind it was acquired through this link http://extreme-macro.co.uk/

I started out doing macrophotography the "manual" way which meant turning the knob on the Proxxon table, triggering the camera, and doing this 10, 20, 30 times to get all the images I need to subsequently focus stack the object of interest. This was time-consuming and did lack the accuracy of an automated approach.

My solution to this problem was accomplished through adding a stepper motor to the Proxxon table and connecting it to an Arduino UNO with Adafruit Motor Shield V2 on top. Adding a circuit to remotely trigger the camera was the other piece of the equation. Building a Matlab graphical user interface that allows me to set up and control stepper motor and shutter release finalized this project.

Setup

A stable table, a whole lot of PPE sheets, and the Proxxon table make up the core of the hardware. Parts list with more details can be found in the manual attached in the “Schematics” section.

Schematics

Stepper motor connects to Adafruit Motor Shield V2 sitting on Arduino UNO. A separate breadboard holds the circuits for the shutter control. PIN 8 controls the focus circuit, while PIN 9 the shutter release. Both circuits connect to 4N34 Optocouplers through a 470ohm resistor to keep Arduino and camera electronics separated. Camera specific remote trigger release cable plugs into a 2.5mm audio jack.

Software

A graphical user interface built with Matlab allows me to connect to Arduino UNO and control stepper motor and shutter from my desktop.

Result

30 frames stacked to end up with an image that has everything I wanted in focus.


Code

G01_MacroRail.mMATLAB
Main function to control stepper motor and shutter release.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This is a simple GUI to control a DIY Macro Rail for Macrophotography
% Using Arduino UNO and Motorshield V2, this setup allows me to automate
% the process of taking several/many exposures for subsequent stacking of
% images to have everything of the object in focus.
%
% Additional Files:
%   - var_LUT_Specs.mat     LUT for camera, lens setup, shutter speeds,...
%   - FD_G01_Design(hFig01,sFig01)  mat file creating the GUI
%
% ***** DISCLAIMER *****
% This setup works fine for me but be aware that we are dealing with
% electronics remotely triggering the camera. While the setup in theory is 
% almost fail safe, I can not be held responsible for any damage to your 
% camera equipment or harm to yourself. Please educate yourself about the 
% workings of the circuits and possible consequences of incorrect setup.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


function G01_MacroRail()


    EXEDIR = cd;        % directory where executable is launched from
    load('var_LUT_Specs.mat','LUT_Specs')
    
    getCOM        = cellstr(seriallist);
    LUT_Specs.COM = getCOM';
    lib           = listArduinoLibraries();
    
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%%%% LOOK AND FEEL %%%%%%%%%%
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
    Screen = get(0,'screensize');
    PercW  = 0.7;   % Fraction of screen width   
    PercH  = 0.8;   % Fraction of screen height
    Width  = Screen(3)*PercW;
    Height = Screen(4)*PercH;
    WPos   = [floor(Screen(3)/2 - Width/2),...
              floor(Screen(4)/2 - Height/2),...
              Width,...
              Height];

    
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%%%% GLOBAL VARIABLES %%%%%%%
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    sFig01           = struct;                    % Create Handle structure for Module 3
    sFig01.mPnl      = zeros(4,1);                % setup matrix that holds handles for Panels 
    sFig01.BGC       = ([214,217,223])/256;       % Set Background
    sFig01.BGCEdit   = ([247,248,250])/256;       % Set Background, Color of Background in Editable Fields/Cells
    sFig01.FGCEdit   = ([51,98,140])/256;         % Set Foreground, Color of Font in Editable Fields/Cells
    sFig01.FGCCalc   = [0,0,0];                   % Set Foreground, Color of Font in Calculated, Non-Editable Fields/Cells
    sFig01.ORA       = ([191,98,4])/256;          % NimbusOrange
    sFig01.BPB       = [0.000,1.000,0.000];       % Set BackgroundColor for PushButton
    sFig01.EXEDIR    = EXEDIR;
    sFig01.LUT_Specs = LUT_Specs;
    sFig01.ALibs     = lib;
    sFig01.Stop      = 0;
    
    
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%% Create MATLAB figure %%%
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
    disp('Creating Main Window...')
    
    hFig01 = figure('Name', 'Macro Rail', ...
                    'NumberTitle', 'off', ...
                    'MenuBar', 'none', ...
                    'Toolbar', 'none',...;
                    'CloseRequestFcn',{@onExit,sFig01});

    set(hFig01,'Units','pixel',...
               'Position',WPos,...
               'Color',sFig01.BGC,...;
               'UserData',0);

    set(hFig01,'Units','normalized');

    
    %%%%%%%%%%%%%%%%%%%%%%
    %%%%% MAIN MENU %%%%%%
    %%%%%%%%%%%%%%%%%%%%%%
    
    sFig01 = MainMenus(hFig01,sFig01);
    
    
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%%%% DESIGN FUNCTION FOR MODULE 1 %%%%%
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
    sFig01 = FD_G01_Design(hFig01,sFig01);
    
       
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%%%% CALLBACKS %%%%%%%%%%%%%%%%%%%%%%%%
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
    set(sFig01.hBtp_Connect,'MouseClickedCallback',{@Connect,hFig01});
    
    set(sFig01.hBtt_XFFWD,'MouseClickedCallback',{@Toggle,hFig01});
    set(sFig01.hBtp_XFWD,'MouseClickedCallback',{@Push,hFig01});
    set(sFig01.hBtp_XREV,'MouseClickedCallback',{@Push,hFig01});
    set(sFig01.hBtt_XFREV,'MouseClickedCallback',{@Toggle,hFig01});
        
    set(sFig01.hBtt_YFFWD,'MouseClickedCallback',{@Toggle,hFig01});
    set(sFig01.hBtp_YFWD,'MouseClickedCallback',{@Push,hFig01});
    set(sFig01.hBtp_YREV,'MouseClickedCallback',{@Push,hFig01});
    set(sFig01.hBtt_YFREV,'MouseClickedCallback',{@Toggle,hFig01});
               
    set(sFig01.hBtp_XSetStart,'MouseClickedCallback',{@PushSet,hFig01});    
    set(sFig01.hBtp_XSetStop,'MouseClickedCallback',{@PushSet,hFig01});
       
    set(sFig01.hCb_Lens,'ActionPerformedCallback',{@CalcFrames,hFig01});
    set(sFig01.hCb_SS,'ActionPerformedCallback',{@CalcFrames,hFig01});
    set(sFig01.hCb_Apt,'ActionPerformedCallback',{@CalcFrames,hFig01});
    set(sFig01.hCb_Overlap,'ActionPerformedCallback',{@CalcFrames,hFig01});
    
    set(sFig01.hBtpTest,'MouseClickedCallback',{@Test,hFig01});
    set(sFig01.hBtpStart,'MouseClickedCallback',{@RunSequence,hFig01});
    set(sFig01.hBtpStop,'MouseClickedCallback',{@RunSequence,hFig01});
    
          
    set(sFig01.mPnl(2:end),'Visible','off')
    
    %%%%%%%%%%%%%%%%%%%%%%%%
    %%%%% SAVE %%%%%%%%%%%%%
    %%%%%%%%%%%%%%%%%%%%%%%% 

    setappdata(hFig01,'sFig01',sFig01)
    
end
    
    
%% ADD MAIN MENU
function sFig01 = MainMenus(hFig01,sFig01)

    
    % File main menu
    FileMenu = uimenu(hFig01,'Label','File');
               uimenu(FileMenu,'Label','Exit','Callback',{@onExit});

    % Options menu
    OMenu    = uimenu(hFig01,'Label','Options');
               uimenu(OMenu,'Label','Preferences','Callback',{@onPreferences,hFig01});

    % Help main menu
    HMenu    = uimenu(hFig01,'Label','Help');
               uimenu(HMenu,'Label','Open Manual','Callback',{@onHelp,hFig01});



    %%%%%%%%%%%%%%%%%%%%%%%%
    %%%%% SAVE %%%%%%%%%%%%%
    %%%%%%%%%%%%%%%%%%%%%%%% 

    sFig01.FileMenu = FileMenu;          
    sFig01.OMenu    = OMenu;          
    sFig01.HMenu    = HMenu;          
    setappdata(hFig01,'sFig01',sFig01)

end


%% CONNECT TO ARDUINO
function sFig01 = Connect(~,~,hFig01)
   
    sFig01 = getappdata(hFig01,'sFig01');

    try
        Board = char(sFig01.hCb_Board.getSelectedItem); 
        COM   = char(sFig01.hCb_COM.getSelectedItem); 
        LIB   = char(sFig01.hCb_Libraries.getSelectedItem); 
        SPR   = str2double(char(sFig01.hEb_SMS.getText)); 

        %%%%% ARDUINO SETUP %%%%%
        UNO      = arduino(COM,Board,'Libraries',LIB);
        SH_Motor = addon(UNO,LIB);
        configurePin(UNO,'D8','DigitalOutput')
        configurePin(UNO,'D9','DigitalOutput')       
        writeDigitalPin(UNO,'D8',0);  % Focus
        writeDigitalPin(UNO,'D9',0);  % Release
        %%%%%%%%%%%%%%%%%%%%%%%%%

        %%%%% STEPPER SETUP %%%%%
        Port = 2;                   % Port #1 = M1&M2; Port #2 = M3&M4
        RPM  = 32767;               % max of 32767
        %%%%%%%%%%%%%%%%%%%%%%%%%

        X_SM          = stepper(SH_Motor,Port,SPR,'RPM',RPM,'StepType','Double');
        sFig01.X_SM   = X_SM;
        sFig01.UNO    = UNO;
        sFig01.XPos   = 0;
        sFig01.XStart = 0;
        sFig01.XStop  = 0;
        sFig01.DpR    = str2double(char(sFig01.hEb_DpR.getText));
        sFig01.SMS    = str2double(char(sFig01.hEb_SMS.getText));
        sFig01.RES    = sFig01.DpR/sFig01.SMS;
        
        %%%%% SAVE %%%%%%%%%%%%%
        set(sFig01.mPnl(2:end),'Visible','on')
        setappdata(hFig01,'sFig01',sFig01)
        
    catch err
        disp(err.message)
    end
    
end


%% TOGGLE BUTTON
function Toggle(event,source,hFig01)
        
    sFig01 = getappdata(hFig01,'sFig01');
    Button = char(event.getName);
    Status = event.isSelected;
           
    switch Button
        case 'hBtt_XFFWD'
            SM   = sFig01.X_SM;
            Dir  = -1;
            XPos = sFig01.XPos;
        case 'hBtt_XFREV'
            SM  = sFig01.X_SM;
            Dir = 1;
            XPos  = sFig01.XPos;
        case 'hBtt_YFFWD'
            SM   = sFig01.Y_SM;
            Dir  = -1;
            YPos = sFig01.YPos;
        case 'hBtt_YFREV'
            SM   = sFig01.Y_SM;
            Dir  = 1;
            YPos = sFig01.YPos;
    end
        
    while Status == 1
        move(SM,Dir);
        XPos   = XPos + Dir;
        Status = event.isSelected;
        sFig01.hEb_XPos.setText(num2str(XPos))
        drawnow
    end
    
    %%%%% SAVE %%%%%
    sFig01.XPos = XPos;
    setappdata(hFig01,'sFig01',sFig01)
    
end


%% MOUSE PRESS
function Push(event,source,hFig01)
        
    sFig01 = getappdata(hFig01,'sFig01');
    Button = char(event.getName);
    
    switch Button
        case 'hBtp_XFWD'
            SM  = sFig01.X_SM;
            Dir = -1;
            XPos  = sFig01.XPos;
        case 'hBtp_XREV'
            SM  = sFig01.X_SM;
            Dir = 1;
            XPos  = sFig01.XPos;
        case 'hBtp_YFWD'
            SM  = sFig01.Y_SM;
            Dir = -1;
            YPos  = sFig01.YPos;            
        case 'hBtp_YREV'
            SM  = sFig01.Y_SM;
            Dir = 1;
            YPos  = sFig01.YPos;            
    end
        
    move(SM,Dir);
    XPos   = XPos + Dir;
    sFig01.hEb_XPos.setText(num2str(XPos))   
    
    %%%%% SAVE %%%%%
    sFig01.XPos = XPos;
    setappdata(hFig01,'sFig01',sFig01)
      
end


%% PUSH SET
function sFig01 = PushSet(event,source,hFig01)
    
    sFig01 = getappdata(hFig01,'sFig01');
    
    switch char(event.getName)
        case 'hBtp_XSetStart'
            sFig01.XStart = sFig01.XPos;
            sFig01.hEb_XStart.setText(num2str(sFig01.XPos));
            sFig01.hSb_Distance.setText('0')
        case 'hBtp_XSetStop'
            sFig01.XStop = sFig01.XPos;
            Dist         = abs(diff([sFig01.XStart,sFig01.XStop])*sFig01.RES);
            sFig01.hEb_XStop.setText(num2str(sFig01.XPos));
            sFig01.hSb_Distance.setText(sprintf('%3.2f',Dist))
            
            DOF  = str2double(char(sFig01.hSb_Dof.getText));
            OVL  = 100 - (str2double(char(sFig01.hCb_Overlap.getSelectedItem)));
            numF = ceil(Dist/(DOF*OVL/100));
            DLY  = str2double(char(sFig01.hEb_Delay.getText));    
            SS   = sFig01.hCb_SS.getSelectedItem;
            TIME = numF*(DLY+SS)/60;

            sFig01.hSb_Frames.setText(num2str(numF))
            sFig01.hSb_Time.setText(sprintf('%3.1f',TIME))    
    end
    
    %%%%% SAVE %%%%%
    setappdata(hFig01,'sFig01',sFig01)
              
end


%% PUSH STOP
function sFig01 = PushStop(event,source,hFig01)
    
    % NOT WORKING YET
    sFig01      = getappdata(hFig01,'sFig01');
    sFig01.Stop = 1;
    
    %%%%% SAVE %%%%%
    setappdata(hFig01,'sFig01',sFig01)
    
end


%% CALCULATE FRAMES
function sFig01 = CalcFrames(event,source,hFig01)
    
    sFig01 = getappdata(hFig01,'sFig01');
       
    CAM = sFig01.hCb_Cam.getSelectedItem;
    row = strcmp(CAM,sFig01.LUT_Specs.Cam(:,1));
    COC = sFig01.LUT_Specs.Cam{row,2};
    
    LEN = sFig01.hCb_Lens.getSelectedItem;
    row = strcmp(LEN,sFig01.LUT_Specs.Lens(:,1));
    MAG = sFig01.LUT_Specs.Lens{row,2};
    sFig01.hEb_Mag.setText(sprintf('%2.2f',MAG));
    
    APT = sFig01.hCb_Apt.getSelectedItem;
    DOF = 2*COC*APT*(MAG+1)/MAG^2;
    sFig01.hSb_Dof.setText(sprintf('%2.3f',DOF));
    
    Dist = str2double(char(sFig01.hSb_Distance.getText));
    OVL  = 100 - (str2double(char(sFig01.hCb_Overlap.getSelectedItem)));
    
    numF = ceil(Dist/(DOF*OVL/100));
    
    DLY  = str2double(char(sFig01.hEb_Delay.getText));    
    SS   = sFig01.hCb_SS.getSelectedItem;
    TIME = numF*(DLY+SS)/60;
    
    sFig01.hSb_Frames.setText(num2str(numF))
    sFig01.hSb_Time.setText(sprintf('%3.1f',TIME))
    
end


%% TEST SHOT
function sFig01 = Test(event,source,hFig01)
    
    sFig01 = getappdata(hFig01,'sFig01');
    SS     = sFig01.hCb_SS.getSelectedItem;
    
    %%%%% TAKE IMAGE %%%%%   
    TakePicture(SS,sFig01)
    
end


%% RUN SEQUENCE
function sFig01 = RunSequence(event,source,hFig01)
    
    sFig01 = getappdata(hFig01,'sFig01');
    SM     = sFig01.X_SM;
    XPos   = sFig01.XPos;
    XStart = sFig01.XStart;
    XStop  = sFig01.XStop;
    
    DOF  = str2double(char(sFig01.hSb_Dof.getText));
    Dist = str2double(char(sFig01.hSb_Distance.getText));
    OVL  = 100 - (str2double(char(sFig01.hCb_Overlap.getSelectedItem)));
    DLY  = str2double(char(sFig01.hEb_Delay.getText));    
    SS   = sFig01.hCb_SS.getSelectedItem;
    numF = ceil(Dist/(DOF*OVL/100));
    TIME = numF*(DLY+SS)/60;
    
    sFig01.hSb_Frames.setText(num2str(numF))
    sFig01.hSb_Time.setText(sprintf('%3.1f',TIME))
    
    %%%%% GO TO START %%%%%
    Steps = XStart - XPos;
    move(SM,Steps);
    XPos = XPos + Steps;
    sFig01.hEb_XPos.setText(num2str(XPos));
    
    pause(DLY)
    
    %%%%%%%%%%%%%%%%%%%%%%%%%%
    %%%%% START SEQUENCE %%%%%
    %%%%%%%%%%%%%%%%%%%%%%%%%%
    Steps = XStop - XStart;
    numS  = floor(Steps/numF);
   
    for i = 1:numF

        %%%%% TAKE IMAGE %%%%%
        TakePicture(SS,sFig01)
                
        pause(DLY)

        %%%% MOVE TABLE %%%%%
        move(SM,numS);
        XPos = XPos + numS;
        sFig01.hEb_XPos.setText(num2str(XPos))
        drawnow
        pause(DLY)
        
        if sFig01.Stop == 1
            sFig01.Stop = 0;
            
            %%%%% SAVE %%%%%
            sFig01.XPos = XPos;
            setappdata(hFig01,'sFig01',sFig01);
            return
        end   
    end

    %%%%% TAKE IMAGE %%%%%
    TakePicture(SS,sFig01)
       
    %%%%% GO BACK TO START %%%%%
    Steps = XStart - XPos;
    move(SM,Steps);
    XPos = XPos + Steps;
    sFig01.hEb_XPos.setText(num2str(XPos));

    release(SM)
    msgbox('Sequence Done','SUCCESS','help')
    
    %%%%% SAVE %%%%%
    sFig01.XPos = XPos;
    setappdata(hFig01,'sFig01',sFig01);
    
end


%% Take a Picture
function TakePicture(SS,sFig01)

    writeDigitalPin(sFig01.UNO,'D8',1);  % Focus
    pause(0.01)
    writeDigitalPin(sFig01.UNO,'D9',1);  % Release
    
    pause(SS)
    
    writeDigitalPin(sFig01.UNO,'D8',0);  % Reset
    pause(0.01)
    writeDigitalPin(sFig01.UNO,'D9',0);  % Reset

    
end


%% EXIT
function onExit(~,~,sFig01) % replaced h,e with ~
    
    try
        release(sFig01.X_SM);
    catch
    end
    
    delete(gcf);
    drawnow;

    try
        close all
    catch
        % ignore
    end
end
FD_G01_DesignMATLAB
Helper function that creates all the GUI objects (figure, panels, buttons, fields,...)
function sFig01 = FD_G01_Design(hFig01,sFig01)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% DESIGN FUNCTION FOR MODULE 1 %%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% This Function creates all objects the Macrophotography GUI 
% updates the handles of the sFig structure array
%
% INPUT : Figure Handle sFig
%         Handles structure for all objects sFig
%
% OUTPUT: updated Handles structure for all objects sFig

    LUT_Specs = sFig01.LUT_Specs;
    Tab       = 1;

    %%%%%%%%%%%%%%%%%%%%%%%%%
    %%% TAB 2 - BTQ %%%%%%%%%
    %%%%%%%%%%%%%%%%%%%%%%%%%

    mPnl(1,Tab) = uipanel('Units','normalized','Position',[0.005 0.505 0.600 0.490],'Tag','mPnl01','Parent',hFig01,...
                          'BorderType','line','BorderWidth',3,...
                          'BackgroundColor',sFig01.BGC,'ForegroundColor',sFig01.FGCEdit,'HighlightColor',sFig01.FGCEdit,...
                          'UserData',Tab,'Title','  SETUP  ','FontSize',12,'FontWeight','bold'); 
    mPnl(2,Tab) = uipanel('Units','normalized','Position',[0.615 0.505 0.380 0.490],'Tag','mPnl02','Parent',hFig01,...
                          'BorderType','line','BorderWidth',3,...
                          'BackgroundColor',sFig01.BGC,'ForegroundColor',sFig01.FGCEdit,'HighlightColor',sFig01.FGCEdit,...
                          'UserData',Tab,'Title','  CAMERA SETTINGS  ','FontSize',12,'FontWeight','bold'); 
    mPnl(3,Tab) = uipanel('Units','normalized','Position',[0.005 0.005 0.600 0.490],'Tag','mPnl03','Parent',hFig01,...
                          'BorderType','line','BorderWidth',3,...
                          'BackgroundColor',sFig01.BGC,'ForegroundColor',sFig01.FGCEdit,'HighlightColor',sFig01.FGCEdit,...
                          'UserData',Tab,'Title','  TABLE CONTROL  ','FontSize',12,'FontWeight','bold');     
    mPnl(4,Tab) = uipanel('Units','normalized','Position',[0.615 0.005 0.380 0.490],'Tag','mPnl04','Parent',hFig01,...
                          'BorderType','line','BorderWidth',3,...
                          'BackgroundColor',sFig01.BGC,'ForegroundColor',sFig01.FGCEdit,'HighlightColor',sFig01.FGCEdit,...
                          'UserData',Tab,'Title','  SHOOTING SEQUENCE  ','FontSize',12,'FontWeight','bold'); 
    
    
    %%%%%%%%%%%%%%%%%%%%%%%%                       
    %%% mPnl(1,Tab) %%%%%%%%                     
    %%%%%%%%%%%%%%%%%%%%%%%%                       

    Panel = 1;
        
    DpR = 1;
    SMS = 200;
    RES = sprintf('%3.4f',DpR/SMS);
    
    %%% Create Layout %%%
    numR     = 6;   % Number of Rows
    numC     = 3;   % Number of Columns
    PosX{1}  = [0.050,0.200;...
                0.250,0.250;
                0.550,0.250];
    YOBase   = 0.05;   % Base of Objects
    YOTop    = 0.95;   % Top of Objects
    YSpacing = 0.02;   % Spacing Between Objects    
    Height   = (YOTop - YOBase - YSpacing*(numR-1))/numR;
    
    PosY{1} = zeros(numR,2);
    for i = 1:numR
        PosY{1}(i,1) = YOBase + YSpacing*(i-1) + Height*(i-1);
        PosY{1}(i,2) = Height;
    end
    PosY{1} = flipud(PosY{1});
    
    LUT      = cell(1,numC);
    LUT{1} = [{'Label'},{'Board :'},       {'Board'};...
              {'Label'},{'COM :'},         {'COM'};...
              {'Label'},{'Libraries :'},   {'Libraries'};...
              {'Label'},{'Distance/360 :'},{'DpR'};...
              {'Label'},{'Steps/360 :'},   {'Steps'};...
              {'Label'},{'Resolution :'},  {'Resolution'}];
    LUT{2} = [{'PopUp'},{LUT_Specs.Board},{'Board'};...
              {'PopUp'},{LUT_Specs.COM},  {'COM'};...
              {'PopUp'},{sFig01.ALibs},   {'Libraries'};...
              {'Edit'}, {num2str(DpR)},   {'DpR'};...
              {'Edit'}, {num2str(SMS)},   {'SMS'};...
              {'Calc'}, {RES},            {'RES'}];
    LUT{3} = [{'Push'}, {'Connect'},{'Connect'};...
              {'     '},{''},       {'COM'};...
              {'     '},{''},       {'Libraries'};...
              {'Label'},{'mm'},     {'DpR'};...
              {'Label'},{'Steps'},  {'SMSteps'};...
              {'Label'},{'mm/Step'},{'RES'}];
                
    for j = 1:numC
        for i = 1:numR
            switch LUT{j}{i,1}
                case 'Label'
                    jLabel = com.mathworks.mwswing.MJLabel(LUT{j}{i,2});
                    jLabel.setFont(java.awt.Font('MS Sans Serif',java.awt.Font.BOLD,14))
                    jLabel.setBackground(java.awt.Color(sFig01.BGC(1),sFig01.BGC(2),sFig01.BGC(3)));
                    jLabel.setBorder([]);
                    jLabel.setVerticalAlignment(0);
                    jLabel = javaObjectEDT(jLabel);  % ensure component is auto-delegated to EDT
                    [h,c]  = javacomponent(jLabel,[],mPnl(Panel,Tab)); 
                    set(c,'Units','Normalized','Position',[PosX{1}(j,1) PosY{1}(i,1) PosX{1}(j,2) PosY{1}(i,2)],'Parent',mPnl(Panel,Tab));
                    
                case 'Calc'
                    hTag  = ['hEb_',LUT{j}{i,3}];
                    jEdit = com.mathworks.mwswing.MJTextField(LUT{j}{i,2});
                    jEdit.setFont(java.awt.Font('MS Sans Serif',java.awt.Font.BOLD,14))
                    jEdit.setName(hTag)
                    jEdit.setHorizontalAlignment(jEdit.CENTER);
                    jEdit.setBackground(java.awt.Color(sFig01.BGC(1),sFig01.BGC(2),sFig01.BGC(3)));
                    jEdit.setForeground(java.awt.Color(sFig01.FGCCalc(1),sFig01.FGCCalc(2),sFig01.FGCCalc(3)));
                    jEdit = javaObjectEDT(jEdit);  % ensure component is auto-delegated to EDT
                    [h,c] = javacomponent(jEdit,[],mPnl(Panel,Tab)); 
                    set(c,'Units','Normalized','Position',[PosX{1}(j,1) PosY{1}(i,1) PosX{1}(j,2) PosY{1}(i,2)],'Parent',mPnl(Panel,Tab));
                    
                    sFig01.(hTag) = h;
                    
                case 'Edit'
                    hTag  = ['hEb_',LUT{j}{i,3}];
                    jEdit = com.mathworks.mwswing.MJTextField(LUT{j}{i,2});
                    jEdit.setFont(java.awt.Font('MS Sans Serif',java.awt.Font.BOLD,14))
                    jEdit.setName(hTag)
                    jEdit.setHorizontalAlignment(jEdit.CENTER);
                    jEdit.setBackground(java.awt.Color(sFig01.BGCEdit(1),sFig01.BGCEdit(2),sFig01.BGCEdit(3)));
                    jEdit.setForeground(java.awt.Color(sFig01.FGCEdit(1),sFig01.FGCEdit(2),sFig01.FGCEdit(3)));
                    jEdit = javaObjectEDT(jEdit);  % ensure component is auto-delegated to EDT
                    [h,c] = javacomponent(jEdit,[],mPnl(Panel,Tab)); 
                    set(c,'Units','Normalized','Position',[PosX{1}(j,1) PosY{1}(i,1) PosX{1}(j,2) PosY{1}(i,2)],'Parent',mPnl(Panel,Tab));
                    
                    sFig01.(hTag) = h;
                    
                case 'PopUp'
                    hTag   = ['hCb_',LUT{j}{i,3}];
                    jCombo = com.mathworks.mwswing.MJComboBox(LUT{j}{i,2});
                    jCombo.setFont(java.awt.Font('MS Sans Serif',java.awt.Font.BOLD,14))
                    jCombo.setName(hTag)
                    jCombo.setForeground(java.awt.Color(sFig01.FGCEdit(1),sFig01.FGCEdit(2),sFig01.FGCEdit(3)));
                    jCombo = javaObjectEDT(jCombo);  % ensure component is auto-delegated to EDT
                    [h,c]  = javacomponent(jCombo,[],mPnl(Panel,Tab)); 
                    set(c,'Units','Normalized','Position',[PosX{1}(j,1) PosY{1}(i,1) PosX{1}(j,2) PosY{1}(i,2)],'Parent',mPnl(Panel,Tab));
                    
                    sFig01.(hTag) = h;
                    
                case 'Push'
                    hTag        = ['hBtp_',LUT{j}{i,3}];
                    jPushButton = com.mathworks.mwswing.MJButton(LUT{j}{i,2});  % see Page 101
                    jPushButton.setFont(java.awt.Font('MS Sans Serif',java.awt.Font.BOLD,16))
                    jPushButton.setName(hTag)
                    jPushButton.setHorizontalAlignment(jPushButton.CENTER);
                    jPushButton.setVerticalAlignment(jPushButton.CENTER);
                    jPushButton.setToolTipText('Stop Process');
                    jPushButton = javaObjectEDT(jPushButton);  % ensure component is auto-delegated to EDT
                    [h,c] = javacomponent(jPushButton,[],mPnl(Panel,Tab)); 
                    set(c,'Units','Normalized','Position',[PosX{1}(j,1) PosY{1}(i,1) PosX{1}(j,2) PosY{1}(i,2)],'Parent',mPnl(Panel,Tab));
                    
                    sFig01.(hTag) = h;
            end
        end
    end
    
    
    
    %%%%%%%%%%%%%%%%%%%%%%%%                       
    %%% mPnl(2,Tab) %%%%%%%%                     
    %%%%%%%%%%%%%%%%%%%%%%%%                       

    Panel = 2;
    
    %%% Create Layout %%%
    numR     = 7;   % Number of Rows
    numC     = 3;   % Number of Columns
    PosX{2}  = [0.050,0.250;...
                0.320,0.400;
                0.740,0.100];
    YOBase   = 0.05;   % Base of Objects
    YOTop    = 0.95;   % Top of Objects
    YSpacing = 0.02;   % Spacing Between Objects    
    Height   = (YOTop - YOBase - YSpacing*(numR-1))/numR;
    
    PosY{2} = zeros(numR,2);
    for i = 1:numR
        PosY{2}(i,1) = YOBase + YSpacing*(i-1) + Height*(i-1);
        PosY{2}(i,2) = Height;
    end
    PosY{2} = flipud(PosY{2});
    
    LUT      = cell(1,numC);
    LUT{1} = [{'Label'},{'Camera :'},       {'Cam'};...
              {'Label'},{'Lens :'},         {'Lens'};...
              {'Label'},{'Magnification :'},{'Mag'};...
              {'Label'},{'Shutter Speed :'},{'SS'};...
              {'Label'},{'Aperture :'},     {'Apt'};...
              {'Label'},{'ISO :'},          {'ISO'};...
              {'Label'},{'DOF (est.) :'},   {'Dof'}];
    LUT{2} = [{'PopUp'},{LUT_Specs.Cam(:,1)}, {'Cam'}, {'NoEdit'};...
              {'PopUp'},{LUT_Specs.Lens(:,1)},{'Lens'},{'NoEdit'};...
              {'Edit'},{'1'},                 {'Mag'}, {'Edit'};...
              {'PopUp'},{LUT_Specs.SS},       {'SS'},  {'Edit'};...
              {'PopUp'},{LUT_Specs.Apt},      {'Apt'}, {'NoEdit'};...
              {'PopUp'},{LUT_Specs.ISO},      {'ISO'}, {'NoEdit'};...
              {'Static'},{'0.5'},             {'Dof'}, {'NoEdit'}];
    LUT{3} = [{'Label'},{''},      {'Cam'};...
              {'Label'},{''},      {'Lens'};...
              {'Label'},{': 1'},   {'Mag'};...
              {'Label'},{'secs'},  {'SS'};...
              {'Label'},{'f/stop'},{'Apt'};...
              {'Label'},{'ISO'},   {'ISO'};...
              {'Label'},{'mm'},    {'Dof'}];
                
    for j = 1:numC
        for i = 1:numR
            switch LUT{j}{i,1}
                case 'Label'
                    jLabel = com.mathworks.mwswing.MJLabel(LUT{j}{i,2});
                    jLabel.setFont(java.awt.Font('MS Sans Serif',java.awt.Font.BOLD,14))
                    jLabel.setBackground(java.awt.Color(sFig01.BGC(1),sFig01.BGC(2),sFig01.BGC(3)));
                    jLabel.setBorder([]);
                    jLabel.setVerticalAlignment(0);
                    jLabel = javaObjectEDT(jLabel);  % ensure component is auto-delegated to EDT
                    [h,c]  = javacomponent(jLabel,[],mPnl(Panel,Tab)); 
                    set(c,'Units','Normalized','Position',[PosX{2}(j,1) PosY{2}(i,1) PosX{2}(j,2) PosY{2}(i,2)],'Parent',mPnl(Panel,Tab));

                case 'Static'
                    hTag   = ['hSb_',LUT{j}{i,3}];
                    jLabel = com.mathworks.mwswing.MJLabel(LUT{j}{i,2});
                    jLabel.setFont(java.awt.Font('MS Sans Serif',java.awt.Font.BOLD,14))
                    jLabel.setBackground(java.awt.Color(sFig01.BGC(1),sFig01.BGC(2),sFig01.BGC(3)));
                    jLabel.setBorder([]);
                    jLabel.setHorizontalAlignment(jLabel.RIGHT);
                    jLabel.setVerticalAlignment(0);
                    jLabel = javaObjectEDT(jLabel);  % ensure component is auto-delegated to EDT
                    [h,c]  = javacomponent(jLabel,[],mPnl(Panel,Tab)); 
                    set(c,'Units','Normalized','Position',[PosX{2}(j,1) PosY{2}(i,1) PosX{2}(j,2) PosY{2}(i,2)],'Parent',mPnl(Panel,Tab));
                    
                    sFig01.(hTag) = h;
                    
                case 'Calc'
                    hTag  = ['hEb_',LUT{j}{i,3}];
                    jEdit = com.mathworks.mwswing.MJTextField(LUT{j}{i,2});
                    jEdit.setFont(java.awt.Font('MS Sans Serif',java.awt.Font.BOLD,14))
                    jEdit.setName(hTag)
                    jEdit.setHorizontalAlignment(jEdit.CENTER);
                    jEdit.setBackground(java.awt.Color(sFig01.BGC(1),sFig01.BGC(2),sFig01.BGC(3)));
                    jEdit.setForeground(java.awt.Color(sFig01.FGCCalc(1),sFig01.FGCCalc(2),sFig01.FGCCalc(3)));
                    jEdit = javaObjectEDT(jEdit);  % ensure component is auto-delegated to EDT
                    [h,c] = javacomponent(jEdit,[],mPnl(Panel,Tab)); 
                    set(c,'Units','Normalized','Position',[PosX{2}(j,1) PosY{2}(i,1) PosX{2}(j,2) PosY{2}(i,2)],'Parent',mPnl(Panel,Tab));
                    
                    sFig01.(hTag) = h;
                    
                case 'Edit'
                    hTag  = ['hEb_',LUT{j}{i,3}];
                    jEdit = com.mathworks.mwswing.MJTextField(LUT{j}{i,2});
                    jEdit.setFont(java.awt.Font('MS Sans Serif',java.awt.Font.BOLD,14))
                    jEdit.setName(hTag)
                    jEdit.setHorizontalAlignment(jEdit.RIGHT);
                    jEdit.setBackground(java.awt.Color(sFig01.BGCEdit(1),sFig01.BGCEdit(2),sFig01.BGCEdit(3)));
                    jEdit.setForeground(java.awt.Color(sFig01.FGCEdit(1),sFig01.FGCEdit(2),sFig01.FGCEdit(3)));
                    jEdit = javaObjectEDT(jEdit);  % ensure component is auto-delegated to EDT
                    [h,c] = javacomponent(jEdit,[],mPnl(Panel,Tab)); 
                    set(c,'Units','Normalized','Position',[PosX{2}(j,1) PosY{2}(i,1) PosX{2}(j,2) PosY{2}(i,2)],'Parent',mPnl(Panel,Tab));
                    
                    sFig01.(hTag) = h;
                    
                case 'PopUp'
                    hTag   = ['hCb_',LUT{j}{i,3}];
                    jCombo = com.mathworks.mwswing.MJComboBox(LUT{j}{i,2});
                    jCombo.setFont(java.awt.Font('MS Sans Serif',java.awt.Font.BOLD,14))
                    jCombo.setName(hTag)
                    jCombo.setForeground(java.awt.Color(sFig01.FGCEdit(1),sFig01.FGCEdit(2),sFig01.FGCEdit(3)));
                    jCombo = javaObjectEDT(jCombo);  % ensure component is auto-delegated to EDT
                    [h,c]  = javacomponent(jCombo,[],mPnl(Panel,Tab)); 
                    set(c,'Units','Normalized','Position',[PosX{2}(j,1) PosY{2}(i,1) PosX{2}(j,2) PosY{2}(i,2)],'Parent',mPnl(Panel,Tab));
                    
                    sFig01.(hTag) = h;
            end
        end
    end
    
    
    %%%%%%%%%%%%%%%%%%%%%%%%                       
    %%% mPnl(3,Tab) %%%%%%%%                     
    %%%%%%%%%%%%%%%%%%%%%%%%                       

    Panel = 3;
    
    %%% Create Layout %%%
    numR     = 4;   % Number of Rows
    numC     = 7;   % Number of Columns
    PosX{3}  = [0.050,0.100;...
                0.160,0.080;
                0.245,0.080;
                0.330,0.080;
                0.415,0.080;
                0.530,0.120;
                0.650,0.165];
    YOBase   = PosY{2}(numR,1);   % Base of Objects
    YOTop    = 0.95;   % Top of Objects
    YSpacing = 0.02;   % Spacing Between Objects    
    Height   = (YOTop - YOBase - YSpacing*(numR-1))/numR;
    
    PosY{3} = zeros(numR,2);
    for i = 1:numR
        PosY{3}(i,1) = YOBase + YSpacing*(i-1) + Height*(i-1);
        PosY{3}(i,2) = Height;
    end
    PosY{3} = flipud(PosY{3});
    
    LUT    = cell(1,numC);
    LUT{1} = [{'Label'},{'X-Axis :'},{'XAxis'},{''};...
              {'Label'},{'Y-Axis :'},{'YAxis'},{''}];
    LUT{2} = [{'Toggle'},{'<<'},{'XFFWD'},{'continous Forward'};...
              {'Toggle'},{'<<'},{'YFFWD'},{'continous Left'}];
    LUT{3} = [{'Push'},{'<'},{'XFWD'},{'single Forward'};...
              {'Push'},{'<'},{'YFWD'},{'single Left'}];
    LUT{4} = [{'Push'},{'>'},{'XREV'},{'single Reverse'};...
              {'Push'},{'>'},{'YREV'},{'single Right'}];
    LUT{5} = [{'Toggle'},{'>>'},{'XFREV'},{'continous Reverse'};...
              {'Toggle'},{'>>'},{'YFREV'},{'continous Right'}];
    LUT{6} = [{'Label'},{'X-Current :'},{'XAxis'},{''};...
              {'Label'},{'Y-Current :'},{'YAxis'},{''}];
    LUT{7} = [{'Calc'},{'0'}, {'XPos'},{'X Position'};...
              {'Calc'},{'0'}, {'YPos'},{'Y Position'}];
                
    for j = 1:numC
        for i = 1:numR - 2
            switch LUT{j}{i,1}
                case 'Label'
                    jLabel = com.mathworks.mwswing.MJLabel(LUT{j}{i,2});
                    jLabel.setFont(java.awt.Font('MS Sans Serif',java.awt.Font.BOLD,14))
                    jLabel.setBackground(java.awt.Color(sFig01.BGC(1),sFig01.BGC(2),sFig01.BGC(3)));
                    jLabel.setBorder([]);
                    jLabel.setVerticalAlignment(0);
                    jLabel = javaObjectEDT(jLabel);  % ensure component is auto-delegated to EDT
                    [h,c]  = javacomponent(jLabel,[],mPnl(Panel,Tab)); 
                    set(c,'Units','Normalized','Position',[PosX{3}(j,1) PosY{3}(i,1) PosX{3}(j,2) PosY{3}(i,2)],'Parent',mPnl(Panel,Tab));
                    
                case 'Calc'
                    hTag  = ['hEb_',LUT{j}{i,3}];
                    jEdit = com.mathworks.mwswing.MJTextField(LUT{j}{i,2});
                    jEdit.setFont(java.awt.Font('MS Sans Serif',java.awt.Font.BOLD,14))
                    jEdit.setName(hTag)
                    jEdit.setHorizontalAlignment(jEdit.CENTER);
                    jEdit.setBackground(java.awt.Color(sFig01.BGC(1),sFig01.BGC(2),sFig01.BGC(3)));
                    jEdit.setForeground(java.awt.Color(sFig01.FGCCalc(1),sFig01.FGCCalc(2),sFig01.FGCCalc(3)));
                    jEdit.setToolTipText(LUT{j}{i,4});
                    jEdit = javaObjectEDT(jEdit);  % ensure component is auto-delegated to EDT
                    [h,c] = javacomponent(jEdit,[],mPnl(Panel,Tab)); 
                    set(c,'Units','Normalized','Position',[PosX{3}(j,1) PosY{3}(i,1) PosX{3}(j,2) PosY{3}(i,2)],'Parent',mPnl(Panel,Tab));
                    
                    sFig01.(hTag) = h;
                    
                case 'Push'
                    hTag        = ['hBtp_',LUT{j}{i,3}];
                    jPushButton = com.mathworks.mwswing.MJButton(LUT{j}{i,2});  % see Page 101
                    jPushButton.setFont(java.awt.Font('MS Sans Serif',java.awt.Font.BOLD,16))
                    jPushButton.setName(hTag)
                    jPushButton.setHorizontalAlignment(jPushButton.CENTER);
                    jPushButton.setVerticalAlignment(jPushButton.CENTER);
                    jPushButton.setToolTipText(LUT{j}{i,4});
                    jPushButton = javaObjectEDT(jPushButton);  % ensure component is auto-delegated to EDT
                    [h,c] = javacomponent(jPushButton,[],mPnl(Panel,Tab)); 
                    set(c,'Units','Normalized','Position',[PosX{3}(j,1) PosY{3}(i,1) PosX{3}(j,2) PosY{3}(i,2)],'Parent',mPnl(Panel,Tab));
                    
                    sFig01.(hTag) = h;
                    
                 case 'Toggle'
                    hTag          = ['hBtt_',LUT{j}{i,3}];
                    jToggleButton = com.mathworks.mwswing.MJToggleButton(LUT{j}{i,2});  % see Page 101
                    jToggleButton.setFont(java.awt.Font('MS Sans Serif',java.awt.Font.BOLD,16))
                    jToggleButton.setName(hTag)
                    jToggleButton.setHorizontalAlignment(jToggleButton.CENTER);
                    jToggleButton.setVerticalAlignment(jToggleButton.CENTER);
                    jToggleButton.setToolTipText(LUT{j}{i,4});
                    jToggleButton = javaObjectEDT(jToggleButton);  % ensure component is auto-delegated to EDT
                    [h,c] = javacomponent(jToggleButton,[],mPnl(Panel,Tab)); 
                    set(c,'Units','Normalized','Position',[PosX{3}(j,1) PosY{3}(i,1) PosX{3}(j,2) PosY{3}(i,2)],'Parent',mPnl(Panel,Tab));
                    
                    sFig01.(hTag) = h;                    
            end
        end        
    end
    
    
    %%% Create Layout %%%
    numR     = 2;   % Number of Rows
    numC     = 2;   % Number of Columns
    PosX{3}  = [0.160,0.165;
                0.330,0.165];
    PosYN    = PosY{3}(3:end,:);
    Yoff     = Height/2;   
    
    LUT    = cell(1,numC);
    LUT{1} = [{'Push'},{'Set Start'},{'XSetStart',{'Set X Start to Current Position'}};...
              {'Push'},{'Set Stop'},{'XSetStop'},{'Set X Sop to Current Position'}];
    LUT{2} = [{'Calc'},{''},{'XStart'},{'X Start Position'};...
              {'Calc'},{''},{'XStop'},{'X Stop Position'}];
                
    for j = 1:numC
        for i = 1:numR
            switch LUT{j}{i,1}
                case 'Calc'
                    hTag  = ['hEb_',LUT{j}{i,3}];
                    jEdit = com.mathworks.mwswing.MJTextField(LUT{j}{i,2});
                    jEdit.setFont(java.awt.Font('MS Sans Serif',java.awt.Font.BOLD,14))
                    jEdit.setName(hTag)
                    jEdit.setHorizontalAlignment(jEdit.CENTER);
                    jEdit.setBackground(java.awt.Color(sFig01.BGC(1),sFig01.BGC(2),sFig01.BGC(3)));
                    jEdit.setForeground(java.awt.Color(sFig01.FGCCalc(1),sFig01.FGCCalc(2),sFig01.FGCCalc(3)));
                    jEdit.setToolTipText(LUT{j}{i,4});
                    jEdit = javaObjectEDT(jEdit);  % ensure component is auto-delegated to EDT
                    [h,c] = javacomponent(jEdit,[],mPnl(Panel,Tab)); 
                    set(c,'Units','Normalized','Position',[PosX{3}(j,1) PosYN(i,1)-Yoff PosX{3}(j,2) PosYN(i,2)],'Parent',mPnl(Panel,Tab));
                    
                    sFig01.(hTag) = h;
                    
                case 'Push'
                    hTag        = ['hBtp_',LUT{j}{i,3}];
                    jPushButton = com.mathworks.mwswing.MJButton(LUT{j}{i,2});  % see Page 101
                    jPushButton.setFont(java.awt.Font('MS Sans Serif',java.awt.Font.BOLD,16))
                    jPushButton.setName(hTag)
                    jPushButton.setHorizontalAlignment(jPushButton.CENTER);
                    jPushButton.setVerticalAlignment(jPushButton.CENTER);
                    jPushButton.setToolTipText(LUT{j}{i,4});
                    jPushButton = javaObjectEDT(jPushButton);  % ensure component is auto-delegated to EDT
                    [h,c] = javacomponent(jPushButton,[],mPnl(Panel,Tab)); 
                    set(c,'Units','Normalized','Position',[PosX{3}(j,1) PosYN(i,1)-Yoff PosX{3}(j,2) PosYN(i,2)],'Parent',mPnl(Panel,Tab));
                    
                    sFig01.(hTag) = h;
            end
        end        
    end
    
        
    
    %%%%%%%%%%%%%%%%%%%%%%%%
    %%% mPnl(4,Tab) %%%%%%%%                     
    %%%%%%%%%%%%%%%%%%%%%%%%                       

    Panel = 4;
    
    %%% Create Layout %%%
    numR     = 5;   % Number of Rows
    numC     = 3;   % Number of Columns
    PosX{4}  = [0.050,0.250;...
                0.320,0.300;
                0.640,0.100];
    YOBase   = PosY{2}(numR,1);   % Base of Objects
    YOTop    = 0.95;   % Top of Objects
    YSpacing = 0.02;   % Spacing Between Objects    
    Height   = (YOTop - YOBase - YSpacing*(numR-1))/numR;
    
    PosY{4} = zeros(numR,2);
    for i = 1:numR
        PosY{4}(i,1) = YOBase + YSpacing*(i-1) + Height*(i-1);
        PosY{4}(i,2) = Height;
    end
    PosY{4} = flipud(PosY{4});
    
    LUT    = cell(1,numC);
    LUT{1} = [{'Label'},{'Distance :'},     {'Distance'};...
              {'Label'},{'Overlap :'},      {'Overlap'};...
              {'Label'},{'No. of Frames :'},{'Frames'};...
              {'Label'},{'Delay :'},        {'Delay'};...
              {'Label'},{'Run time :'},     {'Delay'}];       
    LUT{2} = [{'Static'}, {'1'},  {'Distance'},{'NoEdit'};...
              {'PopUp'}, {[{'0'};{'10'};{'20'};{'30'};{'40'};{'50'};{'60'}]},{'Overlap'},{'NoEdit'};...
              {'Static'},{'TBD'},  {'Frames'},  {'Edit'};...
              {'Edit'},  {'1'},    {'Delay'},   {'Edit'};...
              {'Static'},{'100'},  {'Time'},    {'NoEdit'}];
    LUT{3} = [{'Label'},{'mm'},  {'Distance'};...
              {'Label'},{'%'},   {'Overlap'};...
              {'Label'},{'n'},   {'Frames'};...
              {'Label'},{'secs'},{'Delay'};...
              {'Label'},{'mins'},{'Time'}];
                
    for j = 1:numC
        for i = 1:numR
            switch LUT{j}{i,1}
                case 'Label'
                    jLabel = com.mathworks.mwswing.MJLabel(LUT{j}{i,2});
                    jLabel.setFont(java.awt.Font('MS Sans Serif',java.awt.Font.BOLD,14))
                    jLabel.setBackground(java.awt.Color(sFig01.BGC(1),sFig01.BGC(2),sFig01.BGC(3)));
                    jLabel.setBorder([]);
                    jLabel.setVerticalAlignment(0);
                    jLabel = javaObjectEDT(jLabel);  % ensure component is auto-delegated to EDT
                    [h,c]  = javacomponent(jLabel,[],mPnl(Panel,Tab)); 
                    set(c,'Units','Normalized','Position',[PosX{4}(j,1) PosY{4}(i,1) PosX{4}(j,2) PosY{4}(i,2)],'Parent',mPnl(Panel,Tab));
                    
                case 'Static'
                    hTag  = ['hSb_',LUT{j}{i,3}];
                    jEdit = com.mathworks.mwswing.MJTextField(LUT{j}{i,2});
                    jEdit.setFont(java.awt.Font('MS Sans Serif',java.awt.Font.BOLD,14))
                    jEdit.setName(hTag)
                    jEdit.setHorizontalAlignment(jEdit.CENTER);
                    jEdit.setBackground(java.awt.Color(sFig01.BGC(1),sFig01.BGC(2),sFig01.BGC(3)));
                    jEdit.setForeground(java.awt.Color(sFig01.FGCCalc(1),sFig01.FGCCalc(2),sFig01.FGCCalc(3)));
                    jEdit = javaObjectEDT(jEdit);  % ensure component is auto-delegated to EDT
                    [h,c] = javacomponent(jEdit,[],mPnl(Panel,Tab)); 
                    set(c,'Units','Normalized','Position',[PosX{4}(j,1) PosY{4}(i,1) PosX{4}(j,2) PosY{4}(i,2)],'Parent',mPnl(Panel,Tab));
                    
                    sFig01.(hTag) = h;
                    
                case 'Edit'
                    hTag  = ['hEb_',LUT{j}{i,3}];
                    jEdit = com.mathworks.mwswing.MJTextField(LUT{j}{i,2});
                    jEdit.setFont(java.awt.Font('MS Sans Serif',java.awt.Font.BOLD,14))
                    jEdit.setName(hTag)
                    jEdit.setHorizontalAlignment(jEdit.CENTER);
                    jEdit.setBackground(java.awt.Color(sFig01.BGCEdit(1),sFig01.BGCEdit(2),sFig01.BGCEdit(3)));
                    jEdit.setForeground(java.awt.Color(sFig01.FGCEdit(1),sFig01.FGCEdit(2),sFig01.FGCEdit(3)));
                    jEdit = javaObjectEDT(jEdit);  % ensure component is auto-delegated to EDT
                    [h,c] = javacomponent(jEdit,[],mPnl(Panel,Tab)); 
                    set(c,'Units','Normalized','Position',[PosX{4}(j,1) PosY{4}(i,1) PosX{4}(j,2) PosY{4}(i,2)],'Parent',mPnl(Panel,Tab));
                    
                    sFig01.(hTag) = h;
                    
                case 'PopUp'
                    hTag   = ['hCb_',LUT{j}{i,3}];
                    jCombo = com.mathworks.mwswing.MJComboBox(LUT{j}{i,2});
                    jCombo.setFont(java.awt.Font('MS Sans Serif',java.awt.Font.BOLD,14))
                    jCombo.setName(hTag)
                    jCombo.setForeground(java.awt.Color(sFig01.FGCEdit(1),sFig01.FGCEdit(2),sFig01.FGCEdit(3)));
                    jCombo = javaObjectEDT(jCombo);  % ensure component is auto-delegated to EDT
                    [h,c]  = javacomponent(jCombo,[],mPnl(Panel,Tab)); 
                    set(c,'Units','Normalized','Position',[PosX{4}(j,1) PosY{4}(i,1) PosX{4}(j,2) PosY{4}(i,2)],'Parent',mPnl(Panel,Tab));
                    
                    sFig01.(hTag) = h;
            end
        end        
    end
    
    jPushButton = com.mathworks.mwswing.MJButton('TEST');  % see Page 101
    jPushButton.setFont(java.awt.Font('MS Sans Serif',java.awt.Font.BOLD,16))
    jPushButton.setName('hBtpTest')
    jPushButton.setHorizontalAlignment(jPushButton.CENTER);
    jPushButton.setVerticalAlignment(jPushButton.CENTER);
    jPushButton.setToolTipText('Take a Test Picture');
    jPushButton = javaObjectEDT(jPushButton);  % ensure component is auto-delegated to EDT
    [hBtpTest,cBtpTest] = javacomponent(jPushButton,[],mPnl(Panel,Tab)); 
    set(cBtpTest,'Units','Normalized','Position',[PosX{4}(1,1) 0.050 PosX{4}(1,2) 0.100],'Parent',mPnl(Panel,Tab));

    jPushButton = com.mathworks.mwswing.MJButton('START');  % see Page 101
    jPushButton.setFont(java.awt.Font('MS Sans Serif',java.awt.Font.BOLD,16))
    jPushButton.setName('hBtpStart')
    jPushButton.setHorizontalAlignment(jPushButton.CENTER);
    jPushButton.setVerticalAlignment(jPushButton.CENTER);
    jPushButton.setToolTipText('Start Process');
    jPushButton = javaObjectEDT(jPushButton);  % ensure component is auto-delegated to EDT
    [hBtpStart,cBtpStart] = javacomponent(jPushButton,[],mPnl(Panel,Tab)); 
    set(cBtpStart,'Units','Normalized','Position',[PosX{4}(2,1) 0.050 PosX{4}(1,2) 0.100],'Parent',mPnl(Panel,Tab));

    jPushButton = com.mathworks.mwswing.MJButton('STOP');  % see Page 101
    jPushButton.setFont(java.awt.Font('MS Sans Serif',java.awt.Font.BOLD,16))
    jPushButton.setName('hBtpStop')
    jPushButton.setHorizontalAlignment(jPushButton.CENTER);
    jPushButton.setVerticalAlignment(jPushButton.CENTER);
    jPushButton.setToolTipText('Stop Process');
    jPushButton = javaObjectEDT(jPushButton);  % ensure component is auto-delegated to EDT
    [hBtpStop,cBtpStop] = javacomponent(jPushButton,[],mPnl(Panel,Tab)); 
    set(cBtpStop,'Units','Normalized','Position',[PosX{4}(3,1) 0.050 PosX{4}(1,2) 0.100],'Parent',mPnl(Panel,Tab));

    %%%%%%%%%%%%%%%%%%%%%%%
    %%%%% SAVE HANDLES %%%%%
    %%%%%%%%%%%%%%%%%%%%%%%%

    sFig01.mPnl      = mPnl;
    sFig01.hBtpTest  = hBtpTest;
    sFig01.hBtpStart = hBtpStart;
    sFig01.hBtpStop  = hBtpStop;
    
end

Schematics

Macro Rail Manual and Parts List
All parts and step-by-step instructions on my setup

Comments

Similar projects you might like

Arduino RS485 DIN Rail Mount

Project tutorial by hwhardsoft

  • 4,859 views
  • 0 comments
  • 4 respects

Don't Buy a GSM Module, Use Your Old Phone!

Project tutorial by Dante Roumega

  • 56,406 views
  • 26 comments
  • 161 respects

Pushing Data to Google Docs

by Gustavo Gonnet

  • 35,383 views
  • 60 comments
  • 96 respects

Arduino and AC Devices - Automatic Lights

Project tutorial by Ahmed Hamdy

  • 28,773 views
  • 10 comments
  • 62 respects

Bluetooth Home Automation

Project tutorial by TATCO

  • 9,117 views
  • 4 comments
  • 20 respects

DIN Rail Mount for Arduino YUN, UNO and Nano

Project showcase by hwhardsoft

  • 5,342 views
  • 2 comments
  • 11 respects
Add projectSign up / Login