/*
 * Step script
 *
 * Description of the script: 
 *  In the script, there is a departure to the leftmost position and then a certain number of shifts occur until the right position is reached. Each position is recorded in a .csv file.
 *
 * Note:
 *  This is a rather difficult script to learn, since it uses a large number of commands and structures.
 * 
 * Important: 
 *  The script is similar to the "for_calb_step" script, only in this script the offset occurs at the step mode
 *  This script will only be executed in uniaxial mDrive Direct Control mode!
 *  To run the script, upload it to the mDrive Direct Control software
 */

command_home(); // send HOME command (find home position)
command_wait_for_stop(100); 
command_zero();
command_wait_for_stop(100); 
var edge = get_edges_settings();
var first_border = edge.LeftBorder;
var second_board = edge.RightBorder;
var count = 10;
var f = new_file("E:/a.csv"); // Choose a file name and path
f.open(); // Open a file
f.seek( 0 ); // Seek to the beginning of the file

var delay = 2000;
command_move(first_border); // Move to the starting position
command_wait_for_stop(delay); // Wait until controller stops moving
var i = 1;
var time = 0;
var shift = 6;
var step = (second_board - first_border)/shift;
 f.write(0+ ","  +  get_status().CurPosition + "," +  get_status().uCurPosition+ "," + "\n" ); // Get current position, potentiometer value and date and write them to file
do {
  time = i*delay;
  command_movr(step, 0); // Move to the next position
  command_wait_for_stop(delay); // Wait until controller stops moving
  f.write(time + ","  +  get_status().CurPosition + "," +  get_status().uCurPosition+ "," + "\n" ); // Get current position, potentiometer value and date and write them to file
  i = i+1;
} while (i < shift )
f.close(); // Close the file
