📄 cml_amp.h
字号:
private:
/// Total number of segments in the cache
uint16 ct;
/// Index of the oldest segment in the cache
uint16 top;
/// ID of the oldest segment in the cache
uint16 oldest;
/// Holds copies of the cached segments
uint8 cache[ PVTCACHESIZE ][8];
/// Holds position info for each segment.
uunit pos[ PVTCACHESIZE ];
};
/***************************************************************************/
/**
Trapezoidal profile parameters. This structure holds all the parameters
necessary to perform a trapezoidal profile move.
*/
/***************************************************************************/
struct ProfileConfigTrap
{
/// For absolute moves this is an absolute position,
/// for relative moves it's a distance to move.
///
/// This parameter is specified in "user units". See
/// Amp::SetCountsPerUnit for details.
uunit pos;
/// Velocity limit for move.
///
/// This parameter is specified in "user units". See
/// Amp::SetCountsPerUnit for details.
uunit vel;
/// Acceleration limit for move.
///
/// This parameter is specified in "user units". See
/// Amp::SetCountsPerUnit for details.
uunit acc;
/// Deceleration limit for move.
///
/// Note that if this parameter is not set, then the
/// acceleration value will be used for deceleration.
///
/// This parameter is specified in "user units". See
/// Amp::SetCountsPerUnit for details.
uunit dec;
/// Default constructor. Simply set all parameters to zero.
ProfileConfigTrap( void )
{
pos = vel = acc = dec = 0;
}
};
/***************************************************************************/
/**
S-curve profile parameters. This structure holds all the parameters
necessary to perform a s-curve (jerk limited) profile move.
*/
/***************************************************************************/
struct ProfileConfigScurve
{
/// For absolute moves this is an absolute position,
/// for relative moves it's a distance to move.
///
/// This parameter is specified in "user units". See
/// Amp::SetCountsPerUnit for details.
uunit pos;
/// Velocity limit for move.
///
/// This parameter is specified in "user units". See
/// Amp::SetCountsPerUnit for details.
uunit vel;
/// Acceleration limit for move.
///
/// This parameter is specified in "user units". See
/// Amp::SetCountsPerUnit for details.
uunit acc;
/// Jerk limit for move.
///
/// This parameter is specified in "user units". See
/// Amp::SetCountsPerUnit for details.
uunit jrk;
/// Default constructor. Simply set all parameters to zero.
ProfileConfigScurve( void )
{
pos = vel = acc = jrk = 0;
}
};
/***************************************************************************/
/**
Velocity profile parameters. This structure holds all the parameters
necessary to perform a velocity profile move.
*/
/***************************************************************************/
struct ProfileConfigVel
{
/// Direction of motion. If >= 0, then move in the positive direction
/// If < 0, then move in the negative direction.
uunit dir;
/// Velocity limit for move.
///
/// This parameter is specified in "user units". See
/// Amp::SetCountsPerUnit for details.
uunit vel;
/// Acceleration limit for move.
///
/// This parameter is specified in "user units". See
/// Amp::SetCountsPerUnit for details.
uunit acc;
/// Deceleration limit for move.
///
/// This parameter is specified in "user units". See
/// Amp::SetCountsPerUnit for details.
uunit dec;
/// Default constructor. Simply set all parameters to zero.
ProfileConfigVel( void )
{
dir = vel = acc = dec = 0;
}
};
/***************************************************************************/
/**
Copley Controls amplifier object.
This object represents a Copley Controls amplifier on the CANopen network.
The Amp object can be used directly for fairly easy control of an amplifier
on the CANopen network. The object provides easy to use methods for setting
and getting amplifier parameter blocks. It also handles many of the details
of both point to point moves and the transfer of complex PVT profiles.
In addition, the standard Amp object provides several virtual functions
which can be used in derived classes to signal the derived object on
state changes or emergency conditions.
*/
/***************************************************************************/
class Amp: public CopleyNode
{
public:
/***************************************************************************/
/** \name Amplifier initialization
*/
/***************************************************************************/
//@{
/// Default constructor. Init() must be called before
/// the Amp object may be used.
Amp(){ myLink = 0; }
Amp( CanOpen &co, int16 nodeID );
Amp( CanOpen &co, int16 nodeID, AmpSettings &settings );
virtual ~Amp();
const Error *Init( CanOpen &co, int16 nodeID );
const Error *Init( CanOpen &co, int16 nodeID, AmpSettings &settings );
const Error *ReInit( void );
const Error *Reset( void );
//@}
/***************************************************************************/
/** \name Amplifier modes & status info
*/
/***************************************************************************/
//@{
const Error *SetAmpMode( AMP_MODE mode );
const Error *GetAmpMode( AMP_MODE &mode );
const Error *Disable( bool wait=true );
const Error *Enable( bool wait=true );
bool IsHardwareEnabled( void );
bool IsSoftwareEnabled( void );
bool IsReferenced( void );
const Error *CheckStateForMove( void );
const Error *ClearFaults( AMP_FAULT mask = (AMP_FAULT)-1 );
const Error *GetFaults( AMP_FAULT &value );
const Error *SetFaultMask( AMP_FAULT &value );
const Error *GetFaultMask( AMP_FAULT &value );
const Error *GetEventStatus( EVENT_STATUS &stat );
const Error *GetEventSticky( EVENT_STATUS &stat );
const Error *GetEventLatch( EVENT_STATUS &stat );
const Error *SetPwmMode( AMP_PWM_MODE mode );
const Error *GetPwmMode( AMP_PWM_MODE &mode );
const Error *SetPhaseMode( AMP_PHASE_MODE mode );
const Error *GetPhaseMode( AMP_PHASE_MODE &mode );
//@}
/***************************************************************************/
/** \name Motor & Amplifier state information
*/
/***************************************************************************/
//@{
const Error *GetPositionActual( uunit &value );
const Error *SetPositionActual( uunit value );
const Error *GetPositionMotor( uunit &value );
const Error *SetPositionMotor( uunit value );
const Error *GetPositionCommand( uunit &value );
const Error *GetPositionError( uunit &value );
const Error *GetVelocityActual( uunit &value );
const Error *GetVelocityLoad( uunit &value );
const Error *GetVelocityCommand( uunit &value );
const Error *GetVelocityLimited( uunit &value );
const Error *GetCurrentActual( int16 &value );
const Error *GetCurrentCommand( int16 &value );
const Error *GetCurrentLimited( int16 &value );
const Error *GetTrajectoryVel( uunit &value );
const Error *GetTrajectoryAcc( uunit &value );
const Error *GetPhaseAngle( int16 &value );
const Error *GetHallState( int16 &value );
const Error *GetRefVoltage( int16 &value );
const Error *GetHighVoltage( int16 &value );
const Error *GetAmpTemp( int16 &value );
const Error *GetAnalogEncoder( int16 &sin, int16 &cos );
const Error *GetMotorCurrent( int16 &u, int16 &v );
//@}
/***************************************************************************/
/** \name Input & Output pin control
*/
/***************************************************************************/
//@{
const Error *SetIoConfig( AmpIoCfg &cfg );
const Error *GetIoConfig( AmpIoCfg &cfg );
const Error *GetInputs( uint16 &value, bool viaSDO = false );
const Error *WaitInputEvent( Event &e, int32 timeout, uint32 &match );
const Error *WaitInputHigh( uint32 inputs, int32 timeout = -1 );
const Error *WaitInputLow( uint32 inputs, int32 timeout = -1 );
const Error *SetIoPullup( uint16 value );
const Error *GetIoPullup( uint16 &value );
const Error *SetInputConfig( int8 pin, INPUT_PIN_CONFIG cfg );
const Error *GetInputConfig( int8 pin, INPUT_PIN_CONFIG &cfg );
const Error *SetInputDebounce( int8 pin, int16 value );
const Error *GetInputDebounce( int8 pin, int16 &value );
const Error *SetOutputConfig( int8 pin, OUTPUT_PIN_CONFIG cfg, uint32 mask1=0, uint32 mask2=0 );
const Error *GetOutputConfig( int8 pin, OUTPUT_PIN_CONFIG &cfg );
const Error *GetOutputConfig( int8 pin, OUTPUT_PIN_CONFIG &cfg, uint32 &mask );
const Error *GetOutputConfig( int8 pin, OUTPUT_PIN_CONFIG &cfg, uint32 &mask1, uint32 &mask2 );
const Error *SetOutputs( uint16 value );
const Error *GetOutputs( uint16 &value );
//@}
/***************************************************************************/
/** \name Position capture
*/
/***************************************************************************/
//@{
const Error *SetPosCaptureCfg( POS_CAPTURE_CFG cfg );
const Error *GetPosCaptureCfg( POS_CAPTURE_CFG &cfg );
const Error *GetPosCaptureStat( POS_CAPTURE_STAT &stat );
const Error *GetIndexCapture( int32 &value );
const Error *GetHomeCapture( int32 &value );
//@}
/***************************************************************************/
/** \name General parameter setup.
*/
/***************************************************************************/
//@{
const Error *GetAmpConfig( AmpConfig &cfg );
const Error *SetAmpConfig( AmpConfig &cfg );
const Error *SaveAmpConfig( AmpConfig &cfg );
const Error *SaveAmpConfig( void );
const Error *LoadFromFile( char *name, int &line );
const Error *GetCanNetworkConfig( CanNetworkConfig &cfg );
const Error *SetCanNetworkConfig( CanNetworkConfig &cfg );
const Error *GetAmpInfo( AmpInfo &info );
const Error *GetMtrInfo( MtrInfo &info );
const Error *SetMtrInfo( MtrInfo &info );
const Error *GetRegenConfig( RegenConfig &cfg );
const Error *SetRegenConfig( RegenConfig &cfg );
//@}
/***************************************************************************/
/** \name Control loop setup
*/
/***************************************************************************/
//@{
const Error *GetPosLoopConfig( PosLoopConfig &cfg );
const Error *SetPosLoopConfig( PosLoopConfig &cfg );
const Error *GetVelLoopConfig( VelLoopConfig &cfg );
const Error *SetVelLoopConfig( VelLoopConfig &cfg );
const Error *GetCrntLoopConfig( CrntLoopConfig &cfg );
const Error *SetCrntLoopConfig( CrntLoopConfig &cfg );
const Error *GetVloopOutputFilter( Filter &f );
const Error *SetVloopOutputFilter( Filter &f );
const Error *GetVloopCommandFilter( Filter &f );
const Error *SetVloopCommandFilter( Filter &f );
//@}
/***************************************************************************/
/** \name Position and velocity windows
*/
/***************************************************************************/
//@{
const Error *SetTrackingWindows( TrackingWindows &cfg );
const Error *GetTrackingWindows( TrackingWindows &cfg );
const Error *SetPositionErrorWindow( uunit value );
const Error *GetPositionErrorWindow( uunit &value );
const Error *SetPositionWarnWindow( uunit value );
const Error *GetPositionWarnWindow( uunit &value );
const Error *SetSettlingWindow( uunit value );
const Error *GetSettlingWindow( uunit &value );
const Error *SetSettlingTime( uint16 value );
const Error *GetSettlingTime( uint16 &value );
const Error *SetVelocityWarnWindow( uunit value );
const Error *GetVelocityWarnWindow( uunit &value );
const Error *SetVelocityWarnTime( uint16 value );
const Error *GetVelocityWarnTime( uint16 &value );
const Error *SetSoftLimits( SoftPosLimit &cfg );
const Error *GetSoftLimits( SoftPosLimit &cfg );
//@}
/***************************************************************************/
/** \name Homing mode.
*/
/***************************************************************************/
//@{
const Error *GoHome( void );
const Error *GoHome( HomeConfig &cfg );
const Error *SetHomeConfig( HomeConfig &cfg );
const Error *GetHomeConfig( HomeConfig &cfg );
const Error *SetHomeMethod( COPLEY_HOME_METHOD method, uint16 extended=0 );
const Error *GetHomeMethod( COPLEY_HOME_METHOD &method, uint16 *extended=0 );
const Error *SetHomeOffset( uunit value );
const Error *GetHomeOffset( uunit &value );
const Error *SetHomeVelFast( uunit value );
const Error *GetHomeVelFast( uunit &value );
const Error *SetHomeVelSlow( uunit value );
const Error *GetHomeVelSlow( uunit &value );
const Error *SetHomeAccel( uunit value );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -