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

📄 ampparam.cpp

📁 美国COPLEY驱动器,程序开发工具之一.
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/***************************************************************************/

/***************************************************************************/
/**
  Set the method used for homing the drive.

  @param method The home method to set
  @param extended If the 'method' parameter is set to CHM_EXTENDED, then 
         this value will be written to the extended homing parameter on the
	 amplifier.  For any other homing method this parameter is ignored.
  @return A pointer to an error object, or NULL on success
  */
/***************************************************************************/
const Error *Amp::SetHomeMethod( COPLEY_HOME_METHOD method, uint16 extended )
{
   const Error *err;

   if( method == CHM_EXTENDED )
      err = sdo.Dnld16( OBJID_HOME_METHOD_EXT, 0, extended );
   else
      err = sdo.Dnld8( OBJID_HOME_METHOD, 0, (int8)method );

   if( !err ) lastHomeMethod = method;
   return err;
}

/***************************************************************************/
/**
  Get the selected homing method.
  @param method The home method will be returned here.
  @param extended If this pointer is non-null, then the extended homing 
           method value will be returned here.  If this pointer is null,
	   then it will be ignored.
  @return A pointer to an error object, or NULL on success
  */
/***************************************************************************/
const Error *Amp::GetHomeMethod( COPLEY_HOME_METHOD &method, uint16 *extended )
{
   int8 i;
   const Error *err = sdo.Upld8( OBJID_HOME_METHOD, 0, i );
   method = (COPLEY_HOME_METHOD)i;
   if( err || !extended ) return err;

   return sdo.Upld16( OBJID_HOME_METHOD_EXT, 0, *extended );
}

/***************************************************************************/
/**
  Set the home offset value.  This offset is the difference between the location
  of the homing sensor (as defined by the homing method), and the actual zero
  position.  Once the home location has been found, the amplifier will use this 
  offset to determine where the zero position location is.  

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

  @param value the value to set
  @return A pointer to an error object, or NULL on success
  */
/***************************************************************************/
const Error *Amp::SetHomeOffset( uunit value )
{
   return sdo.Dnld32( OBJID_HOME_OFFSET, 0, PosUser2Load(value) );
}

/***************************************************************************/
/**
  Get the home offset 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::GetHomeOffset( uunit &value )
{ 
   int32 v;
   const Error *err = sdo.Upld32( OBJID_HOME_OFFSET, 0, v ); 
   value = PosLoad2User( v );
   return err;
}

/***************************************************************************/
/**
  Set the home velocity used to move to a home switch.  This velocity will be used
  for any move in the home routine that can be done at relatively high speed.  A 
  second slower velocity can also be programed for the parts of the home routine
  that are speed sensitive.

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

  @param value the value to set
  @return A pointer to an error object, or NULL on success
  */
/***************************************************************************/
const Error *Amp::SetHomeVelFast( uunit value )
{
   int32 v = VelUser2Load(value);
   if( v < 0 ) return &AmpError::badHomeParam;

   return sdo.Dnld32( OBJID_HOME_VEL, 1, v ); 
}

/***************************************************************************/
/**
  Get the home velocity used to move to a home switch.  This velocity is used
  for any home moves that may be made at a high velocity without effecting the
  quality of the home sensor detection.

  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::GetHomeVelFast( uunit &value )
{
   int32 v;
   const Error *err = sdo.Upld32( OBJID_HOME_VEL, 1, v );
   value = VelLoad2User( v );
   return err;
}

/***************************************************************************/
/**
  Set the home velocity used to find a switch edge.  This velocity will be used 
  for any move in the home routine which is speed sensitive.  This typically is a 
  move in which the edge of a sensor is being searched for.

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

  @param value the value to set
  @return A pointer to an error object, or NULL on success
  */
/***************************************************************************/
const Error *Amp::SetHomeVelSlow( uunit value )
{
   int32 v = VelUser2Load(value);
   if( v < 0 ) return &AmpError::badHomeParam;

   return sdo.Dnld32( OBJID_HOME_VEL, 2, v ); 
}

/***************************************************************************/
/**
  Get the home velocity used to find a switch edge.

  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::GetHomeVelSlow( uunit &value )
{
   int32 v;
   const Error *err = sdo.Upld32( OBJID_HOME_VEL, 2, v );
   value = VelLoad2User( v );
   return err;
}

/***************************************************************************/
/**
  Set the home acceleration.  This acceleration value will be used for all 
  moves that are part of the home routine.

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

  @param value the value to set
  @return A pointer to an error object, or NULL on success
  */
/***************************************************************************/
const Error *Amp::SetHomeAccel( uunit value  )
{ 
   int32 v = AccUser2Load(value);
   if( v < 0 ) return &AmpError::badHomeParam;

   return sdo.Dnld32( OBJID_HOME_ACC, 0, v ); 
}

/***************************************************************************/
/**
  Get the home acceleration.

  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::GetHomeAccel( uunit &value )
{
   int32 v;
   const Error *err = sdo.Upld32( OBJID_HOME_ACC, 0, v );
   value = AccLoad2User( v );
   return err;
}

/***************************************************************************/
/**
  Get the last home adjustment amount.

  The value returned is distance that the home position was adjusted by on the last
  successful home opperation.

  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::GetHomeAdjustment( uunit &value )
{
   int32 v;
   const Error *err = sdo.Upld32( OBJID_HOME_ADJUST, 0, v );
   value = PosLoad2User( v );
   return err;
}

/***************************************************************************/
/**
  Set the home current.  The home current value is only used when homing to a
  hard stop.  This parameter is specified in units of 0.01 Amps (i.e. a value
  of 123 would be 1.23 Amps).

  @param value the value to set
  @return A pointer to an error object, or NULL on success
  */
/***************************************************************************/
const Error *Amp::SetHomeCurrent( int16 value  )
{ 
   return sdo.Dnld16( OBJID_HOME_CRNT, 0, value ); 
}

/***************************************************************************/
/**
  Get the home current.  The homing current is returned in 0.01 Amp units
  (i.e. a value of 123 would be 1.23 Amps).

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

/***************************************************************************/
/**
  Set the home delay.  The home delay value is only used when homing to a
  hard stop.  This parameter is specified in units of milliseconds.

  @param value the value to set
  @return A pointer to an error object, or NULL on success
  */
/***************************************************************************/
const Error *Amp::SetHomeDelay( int16 value  )
{ 
   return sdo.Dnld16( OBJID_HOME_DELAY, 0, value ); 
}

/***************************************************************************/
/**
  Get the home current.  The homing delay is returned in units of milliseconds.

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

/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
/*
                         Position capture control
*/
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/

/**
  Set the position capture configuration.

  The position capture mechanism in the amplifier allows the motor 
  position to be captured by some event.  The position can be captured
  by a transition on the encoder index signal, or by a transition on 
  a general purpose input pin which has been configured as a 'home' 
  input.

  Note that support for capturing position on a home input pin was
  added in version 4.77 firmware.  Earlier versions of firmware will
  return an error if an attempt is made to configure that capture.
 */
const Error *Amp::SetPosCaptureCfg( POS_CAPTURE_CFG cfg )
{
   return sdo.Dnld16( OBJID_CAP_CTRL, 0, (uint16)cfg );
}

/**
  Read the current configuration of the position capture mechanism.
  */
const Error *Amp::GetPosCaptureCfg( POS_CAPTURE_CFG &cfg )
{
   uint16 value;
   const Error *err = sdo.Upld16( OBJID_CAP_CTRL, 0, value );
   cfg = (POS_CAPTURE_CFG)value;
   return err;
}

/**
  Read the current status of the position capture mechanism.
  */
const Error *Amp::GetPosCaptureStat( POS_CAPTURE_STAT &stat )
{
   uint16 value;
   const Error *err = sdo.Upld16( OBJID_CAP_STAT, 0, value );
   stat = (POS_CAPTURE_STAT)value;
   return err;
}

/**
  Get the most recently captured encoder index position.
  */
const Error *Amp::GetIndexCapture( int32 &value )
{
   return sdo.Upld32( OBJID_CAP_NDX, 0, value );
}

⌨️ 快捷键说明

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