settleCriteria.cpp

Configure axis settling criteria.

/* settleCriteria.cpp

 Copyright(c) 1998-2009 by Robotic Systems Integration, Inc. All rights reserved.
 This software contains proprietary and confidential information of Robotic 
 Systems Integration, Inc. (RSI) and its suppliers. Except as may be set forth 
 in the license agreement under which this software is supplied, disclosure, 
 reproduction, or use with controls other than those provided by RSI or suppliers
 for RSI is strictly prohibited without the prior express written consent of 
 Robotic Systems Integration.
 
 This sample code presumes that the user has set the tuning paramters(PID, PIV, etc.) 
 prior to running this program so that the motor can rotate in a stable manner.

 Configure the following characteristics for axis:
 1) Fine Position Tolerance
 2) Coarse Position Tolerance
 3) Velocity Tolerance
 4) Settling Time Tolerance

 Once you execute this sample application, changes in values can be verified from RapidSetup in the
'Position and Trajectory Status.'

 For any questions regarding this sample code please visit our documentation at www.roboticsys.com


 Warning!  This is a sample program to assist in the integration of your motion 
 controller with your application.  It may not contain all of the logic and safety
 features that your application requires.
*/


#include "rsi.h"

using namespace RSI::RapidCode::SynqNet;

#define AXIS_NUMBER             0
#define POSITION_TOLERANCE_FINE       200
#define POSITION_TOLERANCE_COARSE     300
#define VELOCITY_TOLERANCE          12000
#define SETTLING_TIME           5


void PrintResult(Axis *axis, char * Vals)
{
  printf("\r%s", Vals);
  printf("\nPosition Tolerance Fine  :   %lf", axis->PositionToleranceFineGet());
  printf("\nPosition Tolerance Coarse:   %lf", axis->PositionToleranceCoarseGet());
  printf("\nVelocity Tolerance       :   %lf", axis->VelocityToleranceGet());
  printf("\nSettling Time            :   %lf\n\n", axis->SettlingTimeGet());
}


void settleCriteriaMain()
{
  try
  {
    MotionController    *controller ;
    Axis        *axis ;

    // initialize MotionController class
    controller = MotionController::CreateFromBoard(0);  

    // initialize Axis class  
    axis = controller->AxisGet( AXIS_NUMBER);

    axis->AmpEnableSet(false);

    PrintResult(axis, "OLD VALUES \n------------");

      //setting new values to Pos_Tol_Fine, Pos_Tol_Coarse, Vel_Tol, Settling_Time 
    axis->PositionToleranceFineSet(POSITION_TOLERANCE_FINE);
    axis->PositionToleranceCoarseSet(POSITION_TOLERANCE_COARSE);
    axis->VelocityToleranceSet(VELOCITY_TOLERANCE);
    axis->SettlingTimeSet(SETTLING_TIME);

    PrintResult(axis, "NEW Values \n------------");
  }
  catch (RsiError *err)
  {
    printf("%s\n", err->text);
  }
}