📄 cml_amp.h
字号:
const Error *GetHomeAccel( uunit &value );
const Error *SetHomeCurrent( int16 value );
const Error *GetHomeCurrent( int16 &value );
const Error *SetHomeDelay( int16 value );
const Error *GetHomeDelay( int16 &value );
const Error *GetHomeAdjustment( uunit &value );
//@}
/***************************************************************************/
/** \name Quick stop support
*/
/***************************************************************************/
//@{
const Error *QuickStop( void );
const Error *HaltMove( void );
const Error *SetQuickStopDec( uunit value );
const Error *GetQuickStopDec( uunit &value );
const Error *SetHaltMode( HALT_MODE mode );
const Error *GetHaltMode( HALT_MODE &mode );
const Error *SetQuickStop( QUICK_STOP_MODE mode );
const Error *GetQuickStop( QUICK_STOP_MODE &mode );
//@}
/***************************************************************************/
/** \name Point to point move support (position profile mode)
*/
/***************************************************************************/
//@{
const Error *SetupMove( ProfileConfigTrap &cfg );
const Error *SetupMove( ProfileConfigScurve &cfg );
const Error *SetupMove( ProfileConfigVel &cfg );
const Error *DoMove( ProfileConfigTrap &cfg, bool relative = false );
const Error *DoMove( ProfileConfigScurve &cfg, bool relative = false );
const Error *DoMove( ProfileConfigVel &cfg );
const Error *DoMove( uunit pos, bool relative = false );
const Error *StartMove( bool relative = false );
/// Start an absolute point to point move to the specified position.
/// This is identical to calling Amp::DoMove( pos )
/// @param pos The position to move to
/// @return A pointer to an error object, or NULL on success
const Error *MoveAbs( uunit pos ){ return DoMove( pos, false ); }
/// Start a relative point to point move of the specified distance.
/// This is identical to calling Amp::DoMove( dist, true )
/// @param dist The distance to move
/// @return A pointer to an error object, or NULL on success
const Error *MoveRel( uunit dist ){ return DoMove( dist, true ); }
const Error *SetProfileConfig( ProfileConfig &cfg );
const Error *GetProfileConfig( ProfileConfig &cfg );
const Error *SetProfileType( PROFILE_TYPE type );
const Error *GetProfileType( PROFILE_TYPE &type );
const Error *SetTargetPos( uunit value );
const Error *GetTargetPos( uunit &value );
const Error *SetProfileVel( uunit value );
const Error *GetProfileVel( uunit &value );
const Error *SetProfileAcc( uunit value );
const Error *GetProfileAcc( uunit &value );
const Error *SetProfileDec( uunit value );
const Error *GetProfileDec( uunit &value );
const Error *SetProfileJerk( uunit value );
const Error *GetProfileJerk( uunit &value );
//@}
/***************************************************************************/
/** \name Profile velocity mode support
*/
/***************************************************************************/
//@{
const Error *SetTargetVel( uunit value );
const Error *GetTargetVel( uunit &value );
//@}
/***************************************************************************/
/** \name Profile torque mode support
*/
/***************************************************************************/
//@{
const Error *SetTorqueTarget( int16 value );
const Error *GetTorqueTarget( int16 &value );
const Error *GetTorqueDemand( int16 &value );
const Error *GetTorqueActual( int16 &value );
const Error *SetTorqueSlope( int32 value );
const Error *GetTorqueSlope( int32 &value );
const Error *SetTorqueRated( int32 value );
const Error *GetTorqueRated( int32 &value );
//@}
/***************************************************************************/
/** \name PVT (interpolated position) trajectory support
*/
/***************************************************************************/
//@{
const Error *SendTrajectory( Trajectory &trj, bool start=true );
const Error *StartPVT( void );
const Error *GetPvtBuffFree( int16 &n );
const Error *GetPvtSegID( uint16 &id );
const Error *GetPvtBuffStat( uint32 &stat );
const Error *GetPvtSegPos( uunit &pos );
//@}
/***************************************************************************/
/** \name Amplifier event processing
*/
/***************************************************************************/
//@{
const Error *WaitEvent( Event &e, int32 timeout=-1 );
const Error *WaitEvent( Event &e, int32 timeout, AMP_EVENT &match );
const Error *WaitMoveDone( int32 timeout=-1 );
const Error *ClearNodeGuardEvent( void );
const Error *GetEventMask( AMP_EVENT &e );
const Error *GetErrorStatus( bool noComm=false );
//@}
/***************************************************************************/
/** \name Unit conversion functions.
If unit conversions are enabled in CML_Settings.h, then these functions handle
the details of converting from user position, velocity, acceleration & jerk
units to the internal units used by the amplifier.
*/
/***************************************************************************/
//@{
virtual const Error *SetCountsPerUnit( uunit cts );
virtual const Error *GetCountsPerUnit( uunit &cts );
virtual const Error *SetCountsPerUnit( uunit load, uunit mtr );
virtual const Error *GetCountsPerUnit( uunit &load, uunit &mtr );
virtual int32 PosUser2Mtr( uunit pos );
virtual int32 VelUser2Mtr( uunit vel );
virtual int32 AccUser2Mtr( uunit vel );
virtual uunit PosMtr2User( int32 pos );
virtual uunit VelMtr2User( int32 vel );
virtual uunit AccMtr2User( int32 vel );
virtual int32 PosUser2Load( uunit pos );
virtual int32 VelUser2Load( uunit vel );
virtual int32 AccUser2Load( uunit acc );
virtual int32 JrkUser2Load( uunit jrk );
virtual uunit PosLoad2User( int32 pos );
virtual uunit VelLoad2User( int32 vel );
virtual uunit AccLoad2User( int32 acc );
virtual uunit JrkLoad2User( int32 jrk );
//@}
/***************************************************************************/
/** \name Linkage access
Amplifier object may be attached to a Linkage object. In this case, multi-
axis moves may be easily performed through calls to the Linkage object holding
the amplifiers.
*/
/***************************************************************************/
//@{
/// Return a pointer to the linkage that this amplifier is attached to.
/// @return The linkage pointer, or NULL if the Amp is not attached to
/// any linkage object.
class Linkage *GetLinkage( void ){ return myLink; }
//@}
/***************************************************************************/
/** \name Non standard modes of operation.
These functions are used when running in modes other then the standard
CANopen position modes. Note that at present the libraries offer only very
limited support for these modes.
*/
/***************************************************************************/
//@{
const Error *GetFuncGenConfig( FuncGenConfig &cfg );
const Error *SetFuncGenConfig( FuncGenConfig &cfg );
const Error *GetAnalogRefConfig( AnalogRefConfig &cfg );
const Error *SetAnalogRefConfig( AnalogRefConfig &cfg );
const Error *GetPwmInConfig( PwmInConfig &cfg );
const Error *SetPwmInConfig( PwmInConfig &cfg );
const Error *SetCurrentProgrammed( int16 crnt );
const Error *GetCurrentProgrammed( int16 &crnt );
const Error *SetVelocityProgrammed( uunit vel );
const Error *GetVelocityProgrammed( uunit &vel );
const Error *SetMicrostepRate( int16 rate );
const Error *GetMicrostepRate( int16 &rate );
//@}
/***************************************************************************/
/** \name Trace control functions
The amplifier supports an internal 'tracing' mechanism which allows certain
internal variables to be sampled at a fixed rate and stored to internal
memory. This mechanism is used by the CME program to implement the oscilloscope
display of internal amplifier information. The following methods are available
to allow this amplifier feature to be used by CML programs.
*/
/***************************************************************************/
//@{
const Error *GetTraceStatus( AMP_TRACE_STATUS &stat, int16 &samp, int16 &sampMax );
const Error *GetTraceRefPeriod( int32 &per );
const Error *GetTracePeriod( int16 &per );
const Error *SetTracePeriod( int16 per );
const Error *GetTraceTrigger( AMP_TRACE_TRIGGER &type, uint8 &chan, int32 &level, int16 &delay );
const Error *SetTraceTrigger( AMP_TRACE_TRIGGER type, uint8 chan=0, int32 level=0, int16 delay=0 );
const Error *GetTraceMaxChannel( uint8 &max );
const Error *GetTraceChannel( uint8 ndx, AMP_TRACE_VAR &value );
const Error *SetTraceChannel( uint8 ndx, AMP_TRACE_VAR value );
const Error *GetTraceData( int32 *data, int32 &max );
const Error *TraceStart( void );
const Error *TraceStop( void );
//@}
protected:
const Error *GetStatusWord( uint16 &value );
const Error *SetControlWord( uint16 value );
const Error *GetControlWord( uint16 &value );
const Error *ClearEventLatch( EVENT_STATUS stat );
virtual void HandleStateChange( NodeState from, NodeState to );
const Error *FormatPvtSeg( int32 pos, int32 vel, uint8 time, uint8 *buff );
const Error *FormatPtSeg( int32 pos, uint8 time, uint8 *buff );
const Error *SetPvtInitialPos( int32 pos, bool viaSDO = true );
const Error *PvtBufferFlush( bool viaSDO = true );
const Error *PvtBufferPop( uint16 n = 1, bool viaSDO = true );
const Error *PvtClearErrors( uint8 mask, bool viaSDO = true );
/// This is an event map that is used to track amplifier
/// events and state changes
EventMap eventMap;
private:
void operator=( Amp &a ){}
const Error *SetupSynchPDO( AmpSettings &settings );
/// Save software version number
uint16 SwVersionNum;
/// Amplifier hardware type
uint16 hwType;
/// This event map is used to track the current state of
/// the general purpose input pins.
EventMap inputStateMap;
/// This is a copy of the settings object passed to the
/// constructor or Init method. It's used to re-initialize
/// the amplifier.
AmpSettings initialSettings;
/// A transmit PDO that causes the amplifier to send
/// it's status word every time it changes.
TPDO_Status statPdo;
/// Last value sent down to the control word
uint16 lastCtrlWord;
/// Last operation mode sent to node
AMP_MODE lastMode;
/// Upper bits (servo or microstep) of the CANopen control
/// mode to use if not specified.
AMP_MODE canCtrlMethod;
/// True if the amplifier is enabled by software.
bool enabled;
/// Last home method that was set.
COPLEY_HOME_METHOD lastHomeMethod;
/// A transmit PDO used to send PVT buffer count
/// information.
TPDO_PvtBuffStat buffStatPdo;
/// A receive PDO used to transmit PVT segment
/// information to the amplifier
RPDO_Pvt pvtPdo;
/// Used to keep track of integrity counter sent with PVT segments
uint16 pvtSegID;
/// ID number of PVT segment current in use by the amplifier
uint16 pvtSegActive;
// Amplifier's PVT buffer size
uint16 pvtBuffSize;
/// Tracks last position value sent in a PVT segment. This is used
/// to send relative move segments for large positions.
int32 pvtLastPos;
/// If true, I'm pulling trajectory segments out of my cache to handle
/// a segment sequencing error. If false, I'm using new segments.
bool pvtUseCache;
/// If I'm using cached segments, then this is the ID of the next
/// segment I need to pull from the cache.
uint16 pvtCacheID;
/// PVT cache object used to keep track of old PVT segments.
PvtSegCache pvtCache;
/// Points to the currently running PVT trajectory
Trajectory *pvtTrj;
#ifdef CML_ENABLE_USER_UNITS
// Load encoder unit conversion scaling factors
double u2lPos; ///< Used to convert position from user units to load units
double u2lVel; ///< Used to convert velocity from user units to load units
double u2lAcc; ///< Used to convert acceleration from user units to load units
double u2lJrk; ///< Used to convert jerk from user units to load units
double l2uPos; ///< Used to convert position from load units to user units
double l2uVel; ///< Used to convert velocity from load units to user units
double l2uAcc; ///< Used to convert acceleration from load units to user units
double l2uJrk; ///< Used to convert jerk from user load to user units
// Motor encoder unit conversion scaling factors
double u2mPos; ///< Used to convert position from user units to motor units
double u2mVel; ///< Used to convert velocity from user units to motor units
double u2mAcc; ///< Used to convert acceleration from user units to motor units
double m2uPos; ///< Used to convert position from motor units to user units
double m2uVel; ///< Used to convert velocity from motor units to user units
double m2uAcc; ///< Used to convert acceleration from motor units to user units
#endif
void MoveAborted( void );
void PvtStatusUpdate( uint32 status );
friend class TPDO_PvtBuffStat;
friend class TPDO_Status;
// The linkage class which owns this Amp uses this pointer
// to keep track of what linkage the Amp belongs to.
friend class Linkage;
void SetLinkage( class Linkage *l ){ myLink = l; }
class Linkage *myLink;
};
CML_NAMESPACE_END()
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -