1. Make sure to be connected to JPL VPN if not on JPL network already when opening matlab.
  2. Make sure the following are on your matlab path and saved.


Read in a MSIM XML config file as matlab structure

CobraConfigStruct = loadCfgXml
CobraConfigStruct = loadCfgXml('Dropbox\PFS_EM\TEST_RESULTS\TargetConvergence\06_24_14_08_51_13_TargetRun','dmpAdj_msimMaps_062314_1.xml')

Plot a motor map from config file


Make MSIM XML from a current config structure in Matlab


Get a field value from the Kinematics structure of a Cobra Config structure

L2 = getARMval(CobraConfigStruct,7,'Link2_Link_Length')

Set a field value from the Kinematics structure of a Cobra Config structure

CobraConfigStruct = setARMval(CobraConfigStruct,7,'Link2_Link_Length',35.323)


  1. Take a manual image with MSIM and save it.
  2. Open the image in ImageJ and measure the coordinates by hand of each image. For the Y-coordinate, subtract the measured value from 2048 to get MSIM Y-coordinate since imageJ is flipped from MSIM.
  3. Enter the coordinates of the fiducials into the script 2014_05_29_FiducialMeasurements.lst.
    1. Example of 3 Fiducials:
      cmd_setHornMethodFiducialCoordinate  96,1644, 10
      cmd_setHornMethodFiducialCoordinate  1645,143, 10
      cmd_setHornMethodFiducialCoordinate  1258,519, 10
    2. The last argument (10) is the radius around your provided center with which to declare found centroids that fiducial.
  4. Execute the script in MSIM. It will take 100 pictures and save the centroids it finds for the fiducials you entered to a log.
  5. Open the Dropbox\PFS_EM\SVN\MATLAB\fiducialStudy.m script and edit the input section
    1. Give it the paths of the Centroid_log.txt files that msim creates
    2. Modify the CobraConfigTemplate.xml starting database so that repos field contains the rough fiducial locations found previously.
    3. Either input the path and filename of the starting XML or uncomment the version which prompts you with the dialog
  6. Run the fiducialStudy script
    1. Save the resulting XML when prompted to do so.
  7. In matlab, look at the newCfg.ARM_DATA.refpos array. This contains the horns corrected average positions of the fiducials in the data you provided originally. Take these and modify future MSIM scripts to use them.

Frequency Sweep/Calibration

  1. Make sure mSim is closed or at a minimum not connected to the motors
  2. Open up New Scale Pathway Software
  3. Connect to motors (ensure total number of axes connected matches what you expect...s/b 18)
  4. Click to the Axis Attributes Tab
  5. Ensure that the boxes for Immediate Update and Auto Freq. Adjust are checked (lower right of the window)
  6. hit ALT+S to bring up the frequency sweep calibration window
  7. Verify that the step interval is set to 2.5msec (or something pretty close)
  8. Click the Rev, then the Fwd button for "Perform Sweep - with both phases..."
    1. Ensure that there is an appropriate peak identified for the motor and not the frequency at the far right of the range
      1. Stage 1 should be in the 58-64kHz range
      2. Stage 2 should be in the 87-95kHz range
  9. Save the sweep results as a .csv file in the dropbox folder: "Dropbox\PFS_EM\TEST_RESULTS\Frequency Sweeps\07_18_14_10_16_00" where the folder is the date/time
  10. Close the window and move to the next axis with the "View Axis" drop down

On-Time Tuning

  1. Put filters on camera lens
    1. THETA FILTERS: ND060 + ND030 + ND120
  2. Check that LEDs are triggered off of camera
  3. Start MSIM fresh to make sure no bias or dark frame voodoo is in there
  4. Manually move all non-cabled up cobras out of the way of the ones under interest
  5. Generate ROM Scripts using Matlab script:
    1. If you don't already have a dark frame saved to go along with the exposures selected in the ontimeTuning script, take them now and save them with the convention that follows this example for 20seconds: 20sDarkImage_64.fits The ontime MSIM scripts will have a command in them which is based on your exposure value and looks for an appropriately named dark image like this
    2. Edit the ROM Script filenames, they shall follow the convention: YYYYMMDD_(theta/phi)(Fwd/Rev)_onTimeTuning.lst (Example: 20140609_thetaFwd_onTimeTuning.lst)
    3. The ontimes to test and other parameters in the ontimeTuning script hopefully do not need adjustment, but they are described within in case.
  6. Execute ROM Scripts with MSIM
    1. Each one of these will create its own test directory with the suffix "onTimeTuning"
    2. Look at the cntrStrk image with ImageJ and make sure that all the positioners are going around at least 200deg or so to get a good circle fit. If they are not, some might be stuck or hitting other positioners and they should be checked to see if their neighbors can be put in a better position.
    3. The quality of the center streaks can be tuned by increasing or decreasing their speed by adjusting the cntrStrkOt variable.
  7. Go to the Images directory of each onTimeTuning directory with matlab (it should be your current folder) and execute the command:
    1. The chooseOntimes shouldn't need modification, but tunable parameters are listed at the top of the script here: Dropbox\PFS_EM\SVN\MATLAB\chooseOntimes.m
  8. A figure will appear asking you to verify that all positioners are identified by the center streaks. Click yes if you see all the centers (red stars) and good streaks for them (>180deg or around there for phi). You can click the other two buttons to halve or double the b/w threshold. Eventually you need to click yes to proceed.
  9. Once you proceed, you'll be asked identify which MSIM PIDs go with which streaks. Enter just the pid number and click ok for each one. The selected centers are shown with a green circle.
  10. After the MSIM PIDs have been assigned, a figure will appear with two subplots. The right plot contains the next streak with first ontime. Hit enter to make it the current streak and que up the next one. Keep hitting enter until you can see that the next streak does not change from the current one and that the positioner makes it's full range of motion or close enough. This may be difficult to tell with phi. Once the two look the same, check the box at the lower left to select the ontime for the streak in the left subplot. Hit enter and it will begin this process again for the next positioner. Keep going until they're all done and the XML dialog appears.
  11. Select the XML you want to start with. This should be the current one you are working with if you have done other ontime tests or if this is the first ontime test you've done and there is no xml file yet, choose the template here: Dropbox\PFS_EM\SVN\MATLAB\CobraConfigTemplate.xml
  12. Next the save XML dialog will appear. Save the new XML containing your selected ontimes and centers if this was theta data. Save it in the Images directory of the test directory for the ontime data. Should be your current working directory in MATLAB already. Format filename like "ThetaFwdOnTimes_062514".

Theta Center and Link Length Metrology

  1. FILTERS: ND060 + ND030 + ND120
  2. Check that the LEDs are triggered from the IO Board
  3. Edit the center script to use the ontimes found from theta and phi forward ontime tuning. Change the number of tests to 1 for loops 1 and 3 so that you can run a couple test images to make sure there is a good spread of centroids.
  4. Run the script and look at the images. Adjust number of steps for specific positioners in the center script to either get tighter or wider spread of centroids around the circumference.
  5. Change the number of tests back to 30 or however many you want to run on each stage in loops 1 and 3.
  6. After test is complete, go to the images directory in Matlab.
  7. Execute the command to find theta centers and save the results:
    1. A dialog appears asking you to select the latest config xml. This is likely the one from the last ontime test if you are at that step.
    2. When the script finishes, there should a mat file created called s1cntrs_*.mat.
  8. Execute the command
    1. A dialog appears asking you to select the latest config xml. This is likely the one from the last ontime test if you are at that step.
    2. After all plots have been created, save the new xml as s1centers_date.xml
  9. Get the phi centroids now by executing
    1. This will create a s2cntrs_*.mat file containing the centroids
  10. Now execute
    1. Load the xml created in previous step from theta data
    2. Save the resulting xml as "Links_Centers_date.xml"

Motor Map Creation with MSIM

  1. Check that filters are off the camera lens and that the LED is set to trigger off of the camera
  2. Load the XML into MSIM that has the link lengths/centers created earlier (see next section on loading XML into MSIM)
  3. Run the motor mapping script in MSIM: 2014_06_22_msimMotMap.lst
  4. Navigate to log directory of the MSIM test directory with Matlab
  5. Edit the inputs section of Dropbox\PFS_EM\SVN\MATLAB\processMsimMaps.m
  6. Execute the MSIM motor mapping matlab script:
    1. A dialog appears and asks you for the original XML used in running the motor map data. IMPORANT to get this right as the cobra orientations will be wrong if you choose an XML different than what was used when the MSIM script ran.
    2. After creating the maps and displaying figures comparing them against the previous ones, a dialog will appear and ask you to specify a name for a new XML file.

Loading XML into MSIM

  1. Move the XML file into the MSIM xml folder: D:\DevCodePft\Main\user\xml_files (There should be a link to this under Sage's Libraries)
  2. Load the XML file with MSIM and save it.(Commands can be found in MSIM under: Commands -> Database Commands) Verify in the MSIM log that this goes ok.
    cmd_load_Xml_file_to_Database  yourXmlFilenameWithNoXmlExtension
  3. Restart MSIM

Running Targets

  1. Open and edit the inputs for the target generation script in Matlab to make targets: \Dropbox\PFS_EM\SVN\MATLAB\targGenerator.m
  2. Change the matlab directory to where you want the target files generated
  3. Run the script
  4. Move the resulting TargetList_mId_#_pId_#.txt files to D:\PfsTests\Targets IMPORTANT: Dont overwrite existing ones. Create an archive folder and move them there first
  5. Restart MSIM
  6. Open the latest target script in Dropbox\PFS_EM\SVN\MSIM and edit it to have the right positioners
    1. Also check that fiducial definitions are correct and motor polarity's are right

Target Convergence Analysis

  1. Copy MSIM target log dir on testbed computer (eg: D:\PfsTests\06_16_14_10_36_21_TargetRun\Log) to the drobox test results target convergence folder (Dropbox\PFS_EM\TEST_RESULTS\TargetConvergence\). Rename the log directory in dropbox to have the same name as the mother directory on testbed computer (eg: 06_16_14_10_36_21_TargetRun). This directory will now be referred to as the test directory here.
  2. Move the appropriate CobraConfig xml (the most recent file in explorer:Libraries->xmlfiles) used by MSIM into the test directory.
    1. Since this is getting complicated to track, for now we shall keep track of which configs are used for which tests on this page: EMTestReports. Make sure to update it after running this.
  3. Change the matlab current folder to the test directory in dropbox.
  4. Execute the following command to run the target analysis script:
  5. When prompted, select the appropriate xml which was used for the MSIM test. The one you moved into test directory.
  6. Run the script and mat files will be saved to the same log directory as the log txt files are in.

Target Convergence Comparisons

  1. Change the matlab current folder to Dropbox\PFS_EM\TEST_RESULTS\TargetConvergenceRun the target convergence analysis on data you wish to compare. The mat files from that script are needed for this comparison.
  2. Open the convergence comparison matlab script in that folder: convCompare.m
  3. Edit the INPUTS section so that the dataDirs array contains the folder names of test data you wish to compare. These must all contain the results of analyzeTargetConvergence script.
  4. Run the script.
  5. The convergence comparison figure will automatically be saved in the last folder of the dataDirs array, so make sure that is in order.

Motor Map Update

  1. Do a TargetConvergenceAnalysis as described above.
  2. Add your new test directory to the list of directories in the beginning of updateMotorMapsFromTargetData.m
  3. Uncomment all directories that contain data you want to include in the analysis.
  4. Run the script with your latest xml and take a thorough look at the results. Look for extreme map values and decide whether it is realistic and ok for the positioner to have these values.
  5. Follow the Loading XML into MSIM procedure above.

Motor Map Global Adjustment

  1. Change matlab current folder to the directory containing results of analyzeTargetRun. (eg. Dropbox\PFS_EM\TEST_RESULTS\TargetConvergence\06_16_14_10_36_21_TargetRun\)
  2. Execute the command
  3. A dialog appears asking you to provide the original data config xml. This should exist already in the current directory, so select it. If not, go find it. This XML contains the original motor maps which will be modified by this script based on the error vs request data.
  4. Script should execute now and create and save figures as well as modify the motor maps from the original XML you just provided.
  5. After script is finished, a dialog will appear asking where to save the new XML config file with adjusted maps. Save it in the same directory and name it the same as the orignal but with suffix 'adj1' or adj2, etc depending on how many adjustments this is for it. To clarify, if the original raw map was called msimMaps_062314_1.xml and the one used for this test data was msimMaps_062314_1_adj1.xml because you already ran this once before, then the new modified config should be called msimMaps_062314_1_adj2.xml.
  6. Since this is getting complicated to track, for now we shall keep track of which configs are used for which tests on this page: EMTestReports. Make sure to update it after running this.

Exporting XML from MSIM

NOTE: The exported XML file will not contain several sets of data necessary for some matlab scripts. This includes fiducial positions and min/max joint angles.
  1. From MSIM dialog send the following command with the argument name according to what you want the XML saved as. Don't include the xml extension.
cmd_save_Database_to_xml_file  yourxmlfilename

Focus measurement

  1. Generate focus/tilt targets
    1. In MATLAB navigate to the appropriate folder in: Dropbox\PFS_EM\TEST_RESULTS\Targets
    2. Edit
      and change the stage identifier to either 'theta' or 'phi' depending on which targets you wish to generate
    3. Run
    4. Move the resulting targets to
      NOTE: If needed, archive the target files that are already there before copying over new targets
  2. Prepare MSIM
    1. If needed, load the appropriate .xml database into MSIM (see above for instructions)
    2. Re-start MSIM
    3. Connect the motor drivers
      2. Click "Connect" button
      3. Click "Load" button
      4. Select the appropriate configuration file (most likely it is the most recent one created)
      5. In the Command Processor Dialog window load the appropriate target script, i.e.
      6. Edit the script as necessary to ensure that motor polarities are set properly or any non-functional cobras are removed from the script. Save the resulting script with a new name.
    1. Switch LED controllers to TRIG mode.
    2. Click "Send" in command processor dialog
    3. After the targets have been converged upon or the maximum number of iterations are reached the script will pause
    1. Switch LED controllers to CW mode.
    2. Using ENSEMBLE MOTION COMPOSER, move XY stage to first position (MOVE X XF Y YF )
    3. Use jog buttons to find fiber image. Move in +X direction so only two spots are showing. RECORD (Xi, Yi)
    4. Move XY stage to final position
    5. Use jog buttons to find fiber image. Move in -X direction so only two spots are showing. RECORD (Xf, Yf)
    6. Hit the "play" button to run "LinearMove.ab"
    7. Manually enter Xi and Yi. Xf and Yf will be filled with the position of the stages when LinearMove starts. Stage moves to (Xi,Yi) after Yi is entered. Scan starts after stage velocity is entered.
    8. Run scan a few times to check camera/fiber alignment. Adjust Yi and Yf as necessary
    9. Take video in "uEye Cockpit". Focus camera has ID 5, load a focus parameter set [directory?]. The "Film Reel" icon opens the setup for video capture.
    10. Hit RECORD before entering stage velocity!
    11. In a text file record meta data for each measurement set that includes {xi,yi}, {xf,yf}, mSim output log folder name, General comments (i.e. if any positioners are not fully visible)
    12. After scans are done, enter "0" to quit/home "LinearMove.ab"
    13. Switch LED controllers to TRIG mode.
    14. Ensure the XY stage has been homed so that it is not obstructing the view of any of the fibers
    15. Click "CP Stopped" button in the mSim Command Processor Dialog Window. This will start the target convergence for the next location.
    16. Once target convergence is complete repeat this section until all 12 sets of measurements have been made.
    1. Create a similar folder in Dropbox that follows this format:
    2. Copy the "mId_#_pId_#.txt files from:
      to the Dropbox folder created in the previous step.
    3. Repeat as necessary for all folders/files created during the text.
Edit | Attach | Watch | Print version | History: r27 < r26 < r25 < r24 < r23 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r27 - 2016-04-06 - JohannesGross
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback