⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ampparam.cpp

📁 美国COPLEY驱动器,程序开发工具之一.
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/************************************************************/
/*                                                          */
/*  Copley Motion Libraries                                 */
/*                                                          */
/*  Author: Stephen Glow                                    */
/*                                                          */
/*  Copyright (c) 2002-2005 Copley Controls Corp.           */
/*                          http://www.copleycontrols.com   */
/*                                                          */
/************************************************************/

/***************************************************************************/
/** \file
This file contains the AMP object methods used to upload / download various
amplifier parameters.
*/
/***************************************************************************/

#include "CML.h"

CML_NAMESPACE_USE();

#define VERSION( major, minor )    ((major<<8) | minor)

/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
/*
                         Amplifier state info
*/
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/

/***************************************************************************/
/**
  Get the actual position used by the servo loop.  For dual encoder systems,
  this will be the load encoder position.  To get the motor encoder position
  on such a system, use Amp::GetPositionMotor.

  This parameter is specified in "user units".  See Amp::SetCountsPerUnit for details.

  @param value variable that will store the returned value
  @return A pointer to an error object, or NULL on success
  */
/***************************************************************************/
const Error *Amp::GetPositionActual( uunit &value )
{
   int32 v;
   const Error *err = sdo.Upld32( OBJID_POS_LOAD, 0, v );
   value = PosLoad2User( v );
   return err;
}

/***************************************************************************/
/**
  Get the actual motor position.  For single encoder systems, this value is
  identical to the value returned by Amp::GetPositionActual.

  For dual encoder systems, this function returns the actual motor position
  and Amp::GetPositionActual may be used to get the load encoder position.

  @param value variable that will store the returned value
  @return A pointer to an error object, or NULL on success
  */
/***************************************************************************/
const Error *Amp::GetPositionMotor( uunit &value )
{
   int32 v;
   const Error *err = sdo.Upld32( OBJID_POS_MTR, 0, v );
   value = PosMtr2User( v );
   return err;
}

/***************************************************************************/
/**
  Set the actual position.  On dual encoder systems, this will set the load
  encoder position.  Amp::SetPositionMotor may be used to set the motor 
  position on such systems.

  This parameter is specified in "user units".  See Amp::SetCountsPerUnit for details.

  @param value The actual position of the motor.
  @return A pointer to an error object, or NULL on success
  */
/***************************************************************************/
const Error *Amp::SetPositionActual( uunit value )
{
   return sdo.Dnld32( OBJID_POS_LOAD, 0, PosUser2Load(value) );
}

/***************************************************************************/
/**
  Set the actual motor position.  On dual encoder systems, this will set the 
  motor encoder position.  Amp::SetPositionActual may be used to set the load
  position on such systems.

  @param value The actual position of the motor.
  @return A pointer to an error object, or NULL on success
  */
/***************************************************************************/
const Error *Amp::SetPositionMotor( uunit value )
{
   return sdo.Dnld32( OBJID_POS_MTR, 0, PosUser2Mtr(value) );
}

/***************************************************************************/
/**
  Get the instantaneous commanded position.  

  This position is the command input to the servo loop.  The commanded position
  is calculated by the trajectory generator and updated every servo cycle.

  This parameter is specified in "user units".  See Amp::SetCountsPerUnit for details.

  @param value variable that will store the returned value
  @return A pointer to an error object, or NULL on success
  */
/***************************************************************************/
const Error *Amp::GetPositionCommand( uunit &value )
{
   int32 v;
   const Error *err = sdo.Upld32( OBJID_POS_CMD, 0, v );
   value = PosLoad2User( v );
   return err;
}

/***************************************************************************/
/**
  Get the position error.  This is the difference between the position demand 
  value and the actual position.

  This parameter is specified in "user units".  See Amp::SetCountsPerUnit for details.

  @param value variable that will store the returned value
  @return A pointer to an error object, or NULL on success
  */
/***************************************************************************/
const Error *Amp::GetPositionError( uunit &value )
{ 
   int32 v;
   const Error *err = sdo.Upld32( OBJID_POS_ERR, 0, v );
   value = PosLoad2User( v );
   return err;
}

/***************************************************************************/
/**
  Get the actual motor velocity.  The motor velocity is estimated by the
  amplifier based on the change in position seen at the encoder.
  For dual encoder systems, the load encoder veloctiy can be queried using
  the function Amp::GetVelocityLoad.

  This parameter is specified in "user units".  See Amp::SetCountsPerUnit for details.

  @param value variable that will store the returned value
  @return A pointer to an error object, or NULL on success
  */
/***************************************************************************/
const Error *Amp::GetVelocityActual( uunit &value )
{ 
   int32 v;
   const Error *err = sdo.Upld32( OBJID_VEL_MTR, 0, v ); 
   value = VelMtr2User( v );
   return err;
}

/***************************************************************************/
/**
  Get the load encoder velocity.  The load velocity is estimated by the
  amplifier based on the change in position seen at the load encoder.
  For dual encoder systems, the motor encoder veloctiy can be queried using
  the function Amp::GetVelocityActual.

  This parameter is specified in "user units".  See Amp::SetCountsPerUnit for details.

  @param value variable that will store the returned value
  @return A pointer to an error object, or NULL on success
  */
/***************************************************************************/
const Error *Amp::GetVelocityLoad( uunit &value )
{ 
   int32 v;
   const Error *err = sdo.Upld32( OBJID_VEL_LOAD, 0, v ); 
   value = VelLoad2User( v );
   return err;
}

/***************************************************************************/
/**
  Get the commanded velocity.  The commanded velocity is the velocity value
  that is passed to the velocity limiter, and from there to the velocity 
  control loop.  If the amplifier is in position mode (i.e. the position loop
  is active), then this velocity is the output of the position control loop.

  This parameter is specified in "user units".  See Amp::SetCountsPerUnit for details.

  @param value variable that will store the returned value
  @return A pointer to an error object, or NULL on success
  */
/***************************************************************************/
const Error *Amp::GetVelocityCommand( uunit &value )
{ 
   int32 v;
   const Error *err = sdo.Upld32( OBJID_VEL_CMD, 0, v ); 
   value = VelMtr2User( v );
   return err;
}

/***************************************************************************/
/**
  Get the limited velocity.  This velocity is the result of applying the 
  velocity limiter to the commanded velocity (see GetVelocityCommand).

  When the velocity loop is being driven by the position loop, the velocity
  limiter consists of a maximum velocity value only.  When some other source
  is driving the velocity loop, the limiter also includes a maximum acceleration
  and deceleration value.

  This parameter is specified in "user units".  See Amp::SetCountsPerUnit for details.

  @param value variable that will store the returned value
  @return A pointer to an error object, or NULL on success
  */
/***************************************************************************/
const Error *Amp::GetVelocityLimited( uunit &value )
{ 
   int32 v;
   const Error *err = sdo.Upld32( OBJID_VEL_LIM, 0, v ); 
   value = VelMtr2User( v );
   return err;
}

/***************************************************************************/
/**
  Get the actual motor current.  This current is based on the amplifiers current
  sensors, and indicates the portion of current that is being used to generate
  torque in the motor.

  The current is returned in units of 0.01 amps.

  @param value A variable that will store the returned value.
  @return A pointer to an error object, or NULL on success
  */
/***************************************************************************/
const Error *Amp::GetCurrentActual( int16 &value )
{
   return sdo.Upld16( OBJID_CRNT_ACT, 0, value );
}

/***************************************************************************/
/**
  Get the commanded motor current.  This current is the input to the current 
  limiter.  This value is also the output of the velocity loop when the 
  motor is in either position or velocity control mode.  When in current control 
  mode, the commanded current is derived from the control source (analog input, 
  PWM input, function generator, etc).

  The current is returned in units of 0.01 amps.

  @param value A variable that will store the returned value.
  @return A pointer to an error object, or NULL on success
  */
/***************************************************************************/
const Error *Amp::GetCurrentCommand( int16 &value )
{
   return sdo.Upld16( OBJID_CRNT_CMD, 0, value );
}

/***************************************************************************/
/**
  Get the limited motor current.  The commanded current (GetCurrentCommand) is
  passed to a current limiter.  The output of the current limiter is the limited
  current which is passed as an input to the current loop.

  The current is returned in units of 0.01 amps.

  @param value A variable that will store the returned value.
  @return A pointer to an error object, or NULL on success
  */
/***************************************************************************/
const Error *Amp::GetCurrentLimited( int16 &value )
{
   return sdo.Upld16( OBJID_CRNT_LIM, 0, value );
}

/***************************************************************************/
/**
  Get the instantaneous commanded velocity passed out of the trajectory 
  generator.  This velocity is used by the position loop to calculate it's 
  velocity feed forward term.

  This parameter is specified in "user units".  See Amp::SetCountsPerUnit for details.

  @param value variable that will store the returned value
  @return A pointer to an error object, or NULL on success
  */
/***************************************************************************/
const Error *Amp::GetTrajectoryVel( uunit &value )
{ 
   int32 v;
   const Error *err = sdo.Upld32( OBJID_TRJ_VEL, 0, v ); 
   value = VelLoad2User( v );
   return err;
}

/***************************************************************************/
/**
  Get the instantaneous commanded acceleration passed out of the trajectory 
  generator.  This acceleration is used by the position loop to calculate it's 
  acceleration feed forward term.

  This parameter is specified in "user units".  See Amp::SetCountsPerUnit for details.

  @param value variable that will store the returned value
  @return A pointer to an error object, or NULL on success
  */
/***************************************************************************/
const Error *Amp::GetTrajectoryAcc( uunit &value )
{ 
   int32 v;
   const Error *err = sdo.Upld32( OBJID_TRJ_ACC, 0, v ); 
   value = AccLoad2User( v );
   return err;
}

/***************************************************************************/
/**
  Get the motor phase angle.  The phase angle describes the motor's electrical 
  position with respect to it's windings.  It's an internal parameter used by 
  the amplifier to commutate a brushless motor.

  The angle is returned in degrees.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -