/*
 * Single axis cyclic movement script
 *
 * Description of the script: 
 *  Does cyclic movement between two border points with set values of acceleration,
 *  deceleration and top speed. The script is similar to the "Cyclic" button in mDrive Direct Control
 *
 * Important:
 *  This script will only be executed in uniaxial mDrive Direct Control mode! 
 *  To run the script, upload it to the mDrive Direct Control software
 */

var first_border = -10; // first border coordinate in mm
var second_border = 10; // second border coordinate in mm
var mm_per_step = 0.005; // steps to distance translation coefficient
var delay = 100; // delay in milliseconds
var calb = new_calibration(mm_per_step, get_engine_settings().MicrostepMode); // create calibration structure
command_stop(); // send STOP command (does immediate stop)
command_zero(); // send ZERO command (sets current position and encoder value to zero)
while (1) { // infinite loop
  command_move_calb(first_border, calb); // move towards one border
  command_wait_for_stop(delay); // wait until controller stops moving
  command_move_calb(second_border, calb); // move towards another border
  command_wait_for_stop(delay); // wait until controller stops moving
}