![]() |
Open FFBoard
Open source force feedback firmware
|
#include <TMC4671.h>
Classes | |
| class | TMC_ExternalEncoderUpdateThread |
Public Member Functions | |
| const ClassIdentifier | getInfo () |
| const ClassType | getClassType () override |
| returns the used classchooser selection id of this instance | |
| TMC4671 (SPIPort &spiport, OutputPin cspin, uint8_t address=1) | |
| void | setHwType (uint8_t type) |
| void | setAddress (uint8_t address) |
| uint8_t | getSpiAddr () |
| bool | setSpiAddr (uint8_t chan) |
| virtual | ~TMC4671 () |
| bool | initialize () |
| void | initializeWithPower () |
| void | Run () |
| bool | motorReady () |
| bool | hasPower () |
| int32_t | getTmcVM () |
| bool | isSetUp () |
| uint32_t | readReg (uint8_t reg) |
| void | writeReg (uint8_t reg, uint32_t dat) |
| void | writeRegAsync (uint8_t reg, uint32_t dat) |
| void | updateReg (uint8_t reg, uint32_t dat, uint32_t mask, uint8_t shift) |
| void | setMotorType (MotorType motor, uint16_t poles) |
| void | runOpenLoop (uint16_t ud, uint16_t uq, int32_t speed, int32_t accel, bool torqueMode=false) |
| void | setOpenLoopSpeedAccel (int32_t speed, uint32_t accel) |
| bool | calibrateAdcOffset (uint16_t time=500) |
| void | setup_ABN_Enc (TMC4671ABNConf encconf) |
| void | setup_AENC (TMC4671AENCConf encconf) |
| void | setup_HALL (TMC4671HALLConf hallconf) |
| void | bangInitEnc (int16_t power) |
| void | estimateABNparams () |
| void | estimateExtEnc () |
| bool | checkEncoder () |
| void | calibrateAenc () |
| void | calibrateEncoder () |
| void | setEncoderType (EncoderType_TMC type) |
| uint32_t | getEncCpr () |
| void | setAdcOffset (uint32_t adc_I0_offset, uint32_t adc_I1_offset) |
| void | setAdcScale (uint32_t adc_I0_scale, uint32_t adc_I1_scale) |
| void | setupFeedForwardTorque (int32_t gain, int32_t constant) |
| void | setupFeedForwardVelocity (int32_t gain, int32_t constant) |
| void | setFFMode (FFMode mode) |
| void | setSequentialPI (bool sequential) |
| void | setBiquadFlux (const TMC4671Biquad &filter) |
| void | setBiquadTorque (const TMC4671Biquad &filter) |
| void | setBiquadPos (const TMC4671Biquad &filter) |
| void | setBiquadVel (const TMC4671Biquad &filter) |
| void | setTorqueFilter (TMC4671Biquad_conf &conf) |
| bool | pingDriver () |
| std::pair< uint32_t, std::string > | getTmcType () |
| void | changeState (TMC_ControlState newState, bool force=false) |
| bool | externalEncoderAllowed () |
| void | setExternalEncoderAllowed (bool allow) |
| float | getPwmFreq () |
| void | setPwmFreq (float freq) |
| void | setBBM (uint8_t bbml, uint8_t bbmh) |
| void | timerElapsed (TIM_HandleTypeDef *htim) |
| void | setPositionExt (int32_t pos) |
| void | stopMotor () |
| void | startMotor () |
| void | emergencyStop (bool reset) |
| void | turn (int16_t power) |
| int16_t | controlFluxDissipate () |
| void | setTorque (int16_t torque) |
| void | setTargetPos (int32_t pos) |
| int32_t | getTargetPos () |
| void | setTargetVelocity (int32_t vel) |
| int32_t | getTargetVelocity () |
| int32_t | getVelocity () |
| int16_t | getTorque () |
| void | setFlux (int16_t flux) |
| int16_t | getFlux () |
| void | setFluxTorque (int16_t flux, int16_t torque) |
| void | setFluxTorqueFF (int16_t flux, int16_t torque) |
| std::pair< int32_t, int32_t > | getActualTorqueFlux () |
| int32_t | getActualFlux () |
| int32_t | getActualTorque () |
| void | rampFlux (uint16_t target, uint16_t time_ms) |
| bool | checkAdc () |
| float | getTemp () |
| TMC_ControlState | getState () |
| void | setPhiEtype (PhiE type) |
| PhiE | getPhiEtype () |
| void | setPhiE_ext (int16_t phiE) |
| int16_t | getPhiE () |
| int16_t | getPhiEfromExternalEncoder () |
| int16_t | getPhiE_Enc () |
| void | setGpioMode (TMC_GpioMode mode) |
| uint8_t | getGpioPins () |
| void | setGpioPins (uint8_t pins) |
| void | setPosSel (PosSelection psel) |
| void | setVelSel (VelSelection vsel, uint8_t mode=0) |
| void | setMotionMode (MotionMode mode, bool force=false) |
| MotionMode | getMotionMode () |
| void | setUdUq (int16_t ud, int16_t uq) |
| void | setBrakeLimits (uint16_t low, uint16_t high) |
| bool | reachedPosition (uint16_t tolerance) |
| void | setPids (TMC4671PIDConf pids) |
| TMC4671PIDConf | getPids () |
| void | setLimits (TMC4671Limits limits) |
| TMC4671Limits | getLimits () |
| void | setUqUdLimit (uint16_t limit) |
| void | setTorqueLimit (uint16_t limit) |
| void | setPidPrecision (TMC4671PidPrecision setting) |
| Encoder * | getEncoder () override |
| void | setEncoder (std::shared_ptr< Encoder > &encoder) override |
| bool | hasIntegratedEncoder () override |
| bool | usingExternalEncoder () |
| int32_t | getPos () override |
| int32_t | getPosAbs () override |
| void | setPos (int32_t pos) override |
| void | setTmcPos (int32_t pos) |
| uint32_t | getCpr () |
| void | setCpr (uint32_t cpr) |
| EncoderType | getEncoderType () override |
| uint32_t | posToEnc (uint32_t pos) |
| uint32_t | encToPos (uint32_t enc) |
| void | exti (uint16_t GPIO_Pin) |
| bool | findEncoderIndex (int32_t speed=10, uint16_t power=2500, bool offsetPhiM=false, bool zeroCount=false) |
| bool | autohome () |
| void | zeroAbnUsingPhiM (bool offsetPhiE=false) |
| StatusFlags | readFlags (bool maskedOnly=true) |
| void | setStatusMask (StatusFlags mask) |
| void | setStatusMask (uint32_t mask) |
| void | setStatusFlags (uint32_t flags) |
| void | setStatusFlags (StatusFlags flags) |
| void | setEncoderIndexFlagEnabled (bool enabled, bool zeroEncoder=false) |
| void | statusCheck () |
| void | saveFlash () override |
| void | restoreFlash () override |
| uint16_t | encodeEncHallMisc () |
| void | restoreEncHallMisc (uint16_t val) |
| void | beginSpiTransfer (SPIPort *port) |
| void | endSpiTransfer (SPIPort *port) |
| CommandStatus | command (const ParsedCommand &cmd, std::vector< CommandReply > &replies) |
| void | registerCommands () |
| virtual std::string | getHelpstring () |
Public Member Functions inherited from MotorDriver | |
| MotorDriver () | |
| virtual | ~MotorDriver () |
Public Member Functions inherited from ChoosableClass | |
| virtual | ~ChoosableClass () |
| uint16_t | getSelectionID () |
Public Member Functions inherited from PersistentStorage | |
| PersistentStorage () | |
| virtual | ~PersistentStorage () |
| void | restoreFlashDelayed () |
Public Member Functions inherited from Encoder | |
| Encoder () | |
| virtual | ~Encoder () |
| virtual float | getPos_f () |
| virtual float | getPosAbs_f () |
Public Member Functions inherited from CommandHandler | |
| CommandHandler (const char *clsname, uint16_t clsid, uint8_t instance=0) | |
| virtual | ~CommandHandler () |
| virtual bool | hasCommands () |
| virtual void | setCommandsEnabled (bool enable) |
| void | registerCommands () |
| virtual CommandStatus | internalCommand (const ParsedCommand &cmd, std::vector< CommandReply > &replies) |
| virtual std::string | getCommandsHelpstring () |
| virtual std::string | getCsvHelpstring () |
| virtual uint8_t | getCommandHandlerInstance () |
| void | broadcastCommandReply (CommandReply reply, uint32_t cmdId, CMDtype type) |
| void | sendCommandReplyAsync (CommandReply reply, uint32_t cmdId, CMDtype type, CommandInterface *interface=nullptr) |
| virtual uint16_t | getCommandHandlerID () |
| virtual CmdHandlerInfo * | getCommandHandlerInfo () |
| virtual bool | isValidCommandId (uint32_t cmdid, uint32_t ignoredFlags=0, uint32_t requiredFlag=0) |
| virtual CmdHandlerCommanddef * | getCommandFromName (const std::string &cmd, uint32_t ignoredFlags=0) |
| virtual CmdHandlerCommanddef * | getCommandFromId (const uint32_t id, uint32_t ignoredFlags=0) |
| template<typename ID> | |
| void | registerCommand (const char *cmd, const ID cmdid, const char *help=nullptr, uint32_t flags=0) |
| virtual void | postCmdhandlerInit () |
| template<typename ID> | |
| void | overrideCommandFlags (const ID cmdid, uint32_t flagmask=0) |
Public Member Functions inherited from SPIDevice | |
| SPIDevice (SPIPort &port, OutputPin csPin) | |
| SPIDevice (SPIPort &port, SPIConfig &spiConfig) | |
| virtual | ~SPIDevice () |
| void | assertChipSelect () |
| void | clearChipSelect () |
| virtual bool | updateCSPin (OutputPin &csPin) |
| virtual void | spiTxCompleted (SPIPort *port) |
| virtual void | spiRxCompleted (SPIPort *port) |
| virtual void | spiTxRxCompleted (SPIPort *port) |
| virtual void | spiRequestError (SPIPort *port) |
| virtual SPIConfig * | getSpiConfig () |
Public Member Functions inherited from ExtiHandler | |
| ExtiHandler () | |
| virtual | ~ExtiHandler () |
Public Member Functions inherited from cpp_freertos::Thread | |
| Thread (const std::string Name, uint16_t StackDepth, UBaseType_t Priority) | |
| Thread (const char *Name, uint16_t StackDepth, UBaseType_t Priority) | |
| Thread (uint16_t StackDepth, UBaseType_t Priority) | |
| bool | Start () |
| virtual | ~Thread () |
| TaskHandle_t | GetHandle () |
| void | Suspend () |
| void | Resume () |
| void | ResumeFromISR () |
| void | Notify () |
| void | NotifyFromISR () |
| uint32_t | WaitForNotification (TickType_t Timeout=portMAX_DELAY) |
| UBaseType_t | GetPriority () |
| UBaseType_t | GetPriorityFromISR () |
| void | SetPriority (UBaseType_t NewPriority) |
| std::string | GetName () |
| char * | GetName () |
Public Member Functions inherited from TimerHandler | |
| TimerHandler () | |
| virtual | ~TimerHandler () |
Static Public Member Functions | |
| static TMC4671MotConf | decodeMotFromInt (uint16_t val) |
| static uint16_t | encodeMotToInt (TMC4671MotConf mconf) |
Static Public Member Functions inherited from ChoosableClass | |
| static bool | isCreatable () |
Static Public Member Functions inherited from PersistentStorage | |
| static std::vector< PersistentStorage * > & | getFlashHandlers () |
| static void | restoreFlashStartupCb () |
Static Public Member Functions inherited from CommandHandler | |
| static void | logSerial (std::string string) |
| Send a log formatted sequence. | |
| static void | logSerialDebug (std::string string) |
| Send a log formatted sequence if debug is on. | |
| static bool | logsEnabled () |
| static void | setLogsEnabled (bool enabled) |
| static uint32_t | getClassIdFromName (const char *name) |
| static const char * | getClassNameFromId (const uint32_t id) |
| static CommandHandler * | getHandlerFromHandlerId (const uint16_t cmdhandlerID) |
| static CommandHandler * | getHandlerFromId (const uint16_t id, const uint8_t instance=0xFF) |
| static CommandHandler * | getHandlerFromClassName (const char *name, const uint8_t instance=0xFF) |
| static std::vector< CommandHandler * > | getHandlersFromClassName (const char *name) |
| static std::vector< CommandHandler * > | getHandlersFromId (const uint16_t id) |
| static bool | isInHandlerList (CommandHandler *handler) |
| static std::string | getAllHelpstrings () |
| static std::vector< CommandHandler * > & | getCommandHandlers () |
| template<typename TVal> | |
| static CommandStatus | handleGetSet (const ParsedCommand &cmd, std::vector< CommandReply > &replies, TVal &value) |
| template<typename TVal, class cls, class cls1> | |
| static CommandStatus | handleGetSetFunc (const ParsedCommand &cmd, std::vector< CommandReply > &replies, TVal &value, void(cls1::*setfunc)(TVal), cls *obj) |
| template<typename TVal, class cls, class cls1, class cls2> | |
| static CommandStatus | handleGetFuncSetFunc (const ParsedCommand &cmd, std::vector< CommandReply > &replies, TVal(cls1::*getfunc)(), void(cls2::*setfunc)(TVal), cls *obj) |
| template<typename TVal, class cls, class cls1> | |
| static CommandStatus | handleGetFuncSet (const ParsedCommand &cmd, std::vector< CommandReply > &replies, TVal &value, TVal(cls1::*getfunc)(), cls *obj) |
Static Public Member Functions inherited from cpp_freertos::Thread | |
| static void | Yield () |
| static void | StartScheduler () |
| static void | EndScheduler () |
Public Attributes | |
| TMC4671MainConfig | conf |
| bool | emergency = false |
| bool | estopTriggered = false |
| int16_t | nextFlux = 0 |
| int16_t | idleFlux = 0 |
| uint16_t | maxOffsetFlux = 0 |
| int16_t | bangInitPower = 5000 |
| const float | fluxDissipationLimit = 1000 |
| TMC4671PIDConf | curPids |
| TMC4671Limits | curLimits |
| TMC4671PidPrecision | pidPrecision |
| TMC4671ABNConf | abnconf |
| TMC4671HALLConf | hallconf |
| TMC4671AENCConf | aencconf |
| bool | flagCheckInProgress = false |
| StatusFlags | statusFlags = {0} |
| StatusFlags | statusMask = {0} |
| TMC4671FlashAddrs | flashAddrs |
| bool | allowSlowSPI = true |
Static Public Attributes | |
| static ClassIdentifier | info |
Static Public Attributes inherited from MotorDriver | |
| static ClassIdentifier | info ={.name = "None" , .id=CLSID_MOT_NONE, .visibility = ClassVisibility::visible} |
| static const std::vector< class_entry< MotorDriver > > | all_drivers |
Static Public Attributes inherited from ChoosableClass | |
| static ClassIdentifier | info |
Static Public Attributes inherited from Encoder | |
| static ClassIdentifier | info ={.name = "None" , .id=CLSID_ENCODER_NONE, .visibility = ClassVisibility::visible} |
| static const std::vector< class_entry< Encoder > > | all_encoders |
Static Public Attributes inherited from CommandHandler | |
| static bool | logEnabled = true |
Static Public Attributes inherited from ExtiHandler | |
| static std::vector< ExtiHandler * > | extiHandlers |
Static Public Attributes inherited from TimerHandler | |
| static std::vector< TimerHandler * > | timerHandlers |
Static Protected Attributes | |
| static std::span< const TMC4671HardwareTypeConf > | tmc4671_hw_configs = tmc4671_hw_configs_array |
Static Protected Attributes inherited from PersistentStorage | |
| static bool | startupComplete = false |
Private Types | |
| enum class | TMC4671_commands : uint32_t { cpr , mtype , encsrc , tmcHwType , encalign , poles , acttrq , pwmlim , torqueP , torqueI , fluxP , fluxI , velocityP , velocityI , posP , posI , tmctype , pidPrec , phiesrc , fluxoffset , seqpi , tmcIscale , encdir , temp , reg , svpwm , fullCalibration , calibrated , abnindexenabled , findIndex , getState , encpol , combineEncoder , invertForce , vmTmc , extphie , torqueFilter_mode , torqueFilter_f , torqueFilter_q , pidautotune , fluxbrake , pwmfreq } |
Private Member Functions | |
| void | initAdc (uint16_t mdecA, uint16_t mdecB, uint32_t mclkA, uint32_t mclkB) |
| void | setPwm (uint8_t val, uint16_t maxcnt, uint8_t bbmL, uint8_t bbmH) |
| void | setPwm (TMC_PwmMode val) |
| void | setPwmMaxCnt (uint16_t maxcnt) |
| void | setSvPwm (bool enable) |
| void | encInit () |
| void | encoderIndexHit () |
| void | saveAdcParams () |
| void | calibFailCb () |
| void | encoderInit () |
| void | errorCallback (const Error &error, bool cleared) |
| bool | pidAutoTune () |
| void | replyHardwareVersions (const std::span< const TMC4671HardwareTypeConf > &versions, std::vector< CommandReply > &replies) |
| void | setUpExtEncTimer () |
Private Member Functions inherited from ErrorHandler | |
| ErrorHandler () | |
| virtual | ~ErrorHandler () |
Friends | |
| class | TMCDebugBridge |
Additional Inherited Members | |
Protected Member Functions inherited from CommandHandler | |
| void | setInstance (uint8_t instance) |
| virtual void | addCommandHandler () |
| virtual void | removeCommandHandler () |
| void | registerCommand_INT (const char *cmd, const uint32_t cmdid, const char *help=nullptr, uint32_t flags=0) |
| void | overrideCommandFlags_INT (const uint32_t cmdid, uint32_t flagmask=CMDFLAG_GET|CMDFLAG_GETADR) |
Protected Member Functions inherited from SPIDevice | |
| virtual void | setSpiConfig (SPIConfig config) |
Protected Member Functions inherited from cpp_freertos::Thread | |
| virtual void | Cleanup () |
| void | Delay (const TickType_t Delay) |
| void | DelayUntil (const TickType_t Period) |
| void | ResetDelayUntil () |
| bool | Wait (ConditionVariable &Cv, Mutex &CvLock, TickType_t Timeout=portMAX_DELAY) |
Static Protected Member Functions inherited from CommandHandler | |
| static std::vector< uint16_t > & | getCommandHandlerIds () |
Protected Attributes inherited from MotorDriver | |
| std::shared_ptr< Encoder > | drvEncoder = std::make_shared<Encoder>() |
Protected Attributes inherited from ChoosableClass | |
| uint16_t | selectionId |
| Should only be written by ClassChooser during creation. | |
Protected Attributes inherited from PersistentStorage | |
| bool | restoreDelayedFlag = false |
Protected Attributes inherited from Encoder | |
| uint32_t | cpr = 0 |
Protected Attributes inherited from CommandHandler | |
| bool | commandsEnabled = true |
| std::vector< CmdHandlerCommanddef > | registeredCommands |
| CmdHandlerInfo | cmdHandlerInfo |
Protected Attributes inherited from SPIDevice | |
| SPIPort & | spiPort |
| SPIConfig | spiConfig |
Static Private Member Functions inherited from ErrorHandler | |
| static void | addError (const Error &error) |
| static void | clearError (const Error &error) |
| static void | clearError (ErrorCode errorcode) |
| static void | clearTemp () |
| static void | clearAll () |
| static std::span< Error > | getErrors () |
| static void | sortErrors () |
Static Private Attributes inherited from ErrorHandler | |
| static std::vector< ErrorHandler * > | errorHandlers |
| static std::array< Error, ERRORHANDLER_MAXERRORS > | errors |
|
strongprivate |
Definition at line 49 of file TMC4671.cpp.
|
virtual |
Definition at line 81 of file TMC4671.cpp.
| bool TMC4671::autohome | ( | ) |
Definition at line 767 of file TMC4671.cpp.
| void TMC4671::bangInitEnc | ( | int16_t | power | ) |
Aligns ABN encoders by forcing an angle with high current and calculating the offset Will start at the current phiE to minimize any extra movements (useful if motor was turned in openloop mode before already)
| power | Maximum current reached during flux ramp |
Definition at line 962 of file TMC4671.cpp.
|
virtual |
Reimplemented from SPIDevice.
Definition at line 2556 of file TMC4671.cpp.
|
private |
Definition at line 1425 of file TMC4671.cpp.
| bool TMC4671::calibrateAdcOffset | ( | uint16_t | time = 500 | ) |
Calibrates the ADC by disabling the power stage and sampling a mean value. Takes time!
Definition at line 1364 of file TMC4671.cpp.
| void TMC4671::calibrateAenc | ( | ) |
Moves the motor to find out analog encoder scalings and offsets
Definition at line 1051 of file TMC4671.cpp.
| void TMC4671::calibrateEncoder | ( | ) |
Definition at line 651 of file TMC4671.cpp.
|
inline |
Definition at line 785 of file TMC4671.cpp.
| bool TMC4671::checkAdc | ( | ) |
Samples the adc and checks if it returns a neutral value
Definition at line 377 of file TMC4671.cpp.
| bool TMC4671::checkEncoder | ( | ) |
Steps the motor a few times to check if the encoder follows correctly
Definition at line 1172 of file TMC4671.cpp.
|
virtual |
| [in] | cmd | The parsed command to be executed. |
| [out] | replies | A vector to return one or multiple reply objects into. Replies to the interface will be generated based on the reply objects. A string reply may not contain start, end and separation markers: [,],| Other characters are allowed. |
Reimplemented from CommandHandler.
Definition at line 2795 of file TMC4671.cpp.
| int16_t TMC4671::controlFluxDissipate | ( | ) |
Calculates a flux value based on the internal and external voltage difference to dissipate energy without a brake resistor
Definition at line 1718 of file TMC4671.cpp.
|
static |
Definition at line 2633 of file TMC4671.cpp.
|
virtual |
Request an emergency stop if something critical happened or the emergency button is triggered Should stop the motor immediately in a safe way.
Reimplemented from MotorDriver.
Definition at line 1688 of file TMC4671.cpp.
|
private |
| uint16_t TMC4671::encodeEncHallMisc | ( | ) |
Definition at line 2650 of file TMC4671.cpp.
|
static |
Definition at line 2642 of file TMC4671.cpp.
|
private |
Definition at line 2624 of file TMC4671.cpp.
|
private |
Definition at line 1434 of file TMC4671.cpp.
| uint32_t TMC4671::encToPos | ( | uint32_t | enc | ) |
Converts encoder counts to phiM
Definition at line 1945 of file TMC4671.cpp.
|
virtual |
Reimplemented from SPIDevice.
Definition at line 2559 of file TMC4671.cpp.
|
privatevirtual |
Reimplemented from ErrorHandler.
Definition at line 3162 of file TMC4671.cpp.
| void TMC4671::estimateABNparams | ( | ) |
Moves the rotor and estimates polarity and direction of the encoder Polarity is found by measuring the n pulse. If polarity was found to be reversed during the test direction will be reversed again to account for that
Definition at line 2296 of file TMC4671.cpp.
| void TMC4671::estimateExtEnc | ( | ) |
Similar to the ABN calibration this moved the motor and measures the encoder direction
Definition at line 2349 of file TMC4671.cpp.
| bool TMC4671::externalEncoderAllowed | ( | ) |
Definition at line 2016 of file TMC4671.cpp.
|
virtual |
Reimplemented from ExtiHandler.
Definition at line 2618 of file TMC4671.cpp.
| bool TMC4671::findEncoderIndex | ( | int32_t | speed = 10, |
| uint16_t | power = 2500, | ||
| bool | offsetPhiM = false, | ||
| bool | zeroCount = false ) |
Rotates motor until the ABN index is found
Definition at line 828 of file TMC4671.cpp.
| int32_t TMC4671::getActualFlux | ( | ) |
Returns measured flux
Definition at line 2490 of file TMC4671.cpp.
| int32_t TMC4671::getActualTorque | ( | ) |
Returns measured torque
Definition at line 2499 of file TMC4671.cpp.
| std::pair< int32_t, int32_t > TMC4671::getActualTorqueFlux | ( | ) |
Returns measured flux and torque as a pair Flux is first, torque second item
Definition at line 2480 of file TMC4671.cpp.
|
inlineoverridevirtual |
returns the used classchooser selection id of this instance
Type of this class. Mainclass, motordriver... Should be implemented by the parent class so it is not in the info struct
Reimplemented from MotorDriver.
|
virtual |
Gets the amount of counts per full rotation of the encoder
Reimplemented from Encoder.
Definition at line 1919 of file TMC4671.cpp.
| uint32_t TMC4671::getEncCpr | ( | ) |
Definition at line 1581 of file TMC4671.cpp.
|
overridevirtual |
Returns the encoder of this motor driver. Either the integrated encoder or an external encoder assigned to this motor driver passed externally
Reimplemented from MotorDriver.
Definition at line 1848 of file TMC4671.cpp.
|
overridevirtual |
Returns the type of the encoder. Must override this and NOT return NONE in other classes
Reimplemented from Encoder.
Definition at line 1952 of file TMC4671.cpp.
| int16_t TMC4671::getFlux | ( | ) |
Definition at line 2061 of file TMC4671.cpp.
| uint8_t TMC4671::getGpioPins | ( | ) |
Reads the state of the 8 gpio pins
Definition at line 1808 of file TMC4671.cpp.
|
inlinevirtual |
Returns a description of this class
Reimplemented from CommandHandler.
|
virtual |
Reimplemented from MotorDriver.
Definition at line 87 of file TMC4671.cpp.
| TMC4671Limits TMC4671::getLimits | ( | ) |
Definition at line 2156 of file TMC4671.cpp.
| MotionMode TMC4671::getMotionMode | ( | ) |
Definition at line 1622 of file TMC4671.cpp.
| int16_t TMC4671::getPhiE | ( | ) |
Definition at line 951 of file TMC4671.cpp.
| int16_t TMC4671::getPhiE_Enc | ( | ) |
Reads phiE directly from the encoder selection instead of the current phiE selection
Definition at line 1155 of file TMC4671.cpp.
| int16_t TMC4671::getPhiEfromExternalEncoder | ( | ) |
Definition at line 939 of file TMC4671.cpp.
| PhiE TMC4671::getPhiEtype | ( | ) |
Definition at line 1603 of file TMC4671.cpp.
| TMC4671PIDConf TMC4671::getPids | ( | ) |
Definition at line 2108 of file TMC4671.cpp.
|
overridevirtual |
Returns the encoder position as raw counts
Reimplemented from Encoder.
Definition at line 1897 of file TMC4671.cpp.
|
overridevirtual |
Returns absolute positions without offsets for absolute encoders. Otherwise it returns getPos
Reimplemented from Encoder.
Definition at line 1903 of file TMC4671.cpp.
| float TMC4671::getPwmFreq | ( | ) |
Returns the PWM loop frequency in Hz Depends on hardware clock and pwm counter setting. Default 25kHz
Definition at line 2435 of file TMC4671.cpp.
| uint8_t TMC4671::getSpiAddr | ( | ) |
| TMC_ControlState TMC4671::getState | ( | ) |
Definition at line 781 of file TMC4671.cpp.
| int32_t TMC4671::getTargetPos | ( | ) |
Definition at line 908 of file TMC4671.cpp.
| int32_t TMC4671::getTargetVelocity | ( | ) |
Definition at line 924 of file TMC4671.cpp.
| float TMC4671::getTemp | ( | ) |
Reads a temperature from a thermistor connected to AGPI_B Not calibrated perfectly!
Definition at line 352 of file TMC4671.cpp.
| std::pair< uint32_t, std::string > TMC4671::getTmcType | ( | ) |
Returns a string with the name and version of the chip
Definition at line 1825 of file TMC4671.cpp.
| int32_t TMC4671::getTmcVM | ( | ) |
Returns estimated VM in mV measured by TMC
Definition at line 234 of file TMC4671.cpp.
| int16_t TMC4671::getTorque | ( | ) |
Definition at line 2051 of file TMC4671.cpp.
| int32_t TMC4671::getVelocity | ( | ) |
Definition at line 927 of file TMC4671.cpp.
|
overridevirtual |
If returned true it signals that this motor driver contains its own encoder and does not require an external encoder
Reimplemented from MotorDriver.
Definition at line 1866 of file TMC4671.cpp.
| bool TMC4671::hasPower | ( | ) |
Definition at line 195 of file TMC4671.cpp.
|
private |
Definition at line 2463 of file TMC4671.cpp.
| bool TMC4671::initialize | ( | ) |
Sets all parameters of the driver at startup. Only has to be called once when the driver is detected restoreFlash() should be called before this to restore settings!
Definition at line 247 of file TMC4671.cpp.
| void TMC4671::initializeWithPower | ( | ) |
Definition at line 388 of file TMC4671.cpp.
| bool TMC4671::isSetUp | ( | ) |
Definition at line 201 of file TMC4671.cpp.
|
virtual |
Reimplemented from MotorDriver.
Definition at line 426 of file TMC4671.cpp.
|
private |
Iterative tuning function for tuning the torque mode PI values
Enter phieExt & torque mode Zero I, default P Ramp up flux P until 50% of target, then lower increments until targetflux_p is reached Increase I until oscillation is found. Back off a bit
Definition at line 671 of file TMC4671.cpp.
| bool TMC4671::pingDriver | ( | ) |
Check if driver is responding
Definition at line 226 of file TMC4671.cpp.
| uint32_t TMC4671::posToEnc | ( | uint32_t | pos | ) |
Definition at line 1948 of file TMC4671.cpp.
| void TMC4671::rampFlux | ( | uint16_t | target, |
| uint16_t | time_ms ) |
Ramps flux from current value to a target value over a specified duration
Definition at line 2085 of file TMC4671.cpp.
| bool TMC4671::reachedPosition | ( | uint16_t | tolerance | ) |
Definition at line 797 of file TMC4671.cpp.
| StatusFlags TMC4671::readFlags | ( | bool | maskedOnly = true | ) |
Reads status flags
| maskedOnly | Masks flags by previously set flag mask that would trigger an interrupt. False to read all flags |
Definition at line 2568 of file TMC4671.cpp.
| uint32_t TMC4671::readReg | ( | uint8_t | reg | ) |
Definition at line 2507 of file TMC4671.cpp.
| void TMC4671::registerCommands | ( | ) |
Definition at line 2747 of file TMC4671.cpp.
|
private |
Appends a formatted reply with currently available hardware version configs
Definition at line 2738 of file TMC4671.cpp.
| void TMC4671::restoreEncHallMisc | ( | uint16_t | val | ) |
Definition at line 2676 of file TMC4671.cpp.
|
overridevirtual |
Restores saved parameters Call initialize() to apply some of the settings
Reimplemented from PersistentStorage.
Definition at line 145 of file TMC4671.cpp.
|
virtual |
Implementation of your actual thread code. You must override this function.
Implements cpp_freertos::Thread.
Definition at line 430 of file TMC4671.cpp.
| void TMC4671::runOpenLoop | ( | uint16_t | ud, |
| uint16_t | uq, | ||
| int32_t | speed, | ||
| int32_t | accel, | ||
| bool | torqueMode = false ) |
Definition at line 1633 of file TMC4671.cpp.
|
private |
Writes ADC offsets into flash
Definition at line 135 of file TMC4671.cpp.
|
overridevirtual |
Called when the user uses the "save" command and presses the save button in the configurator Automatically called by the command parser thread for every class that inherits from PersistentStorage
Reimplemented from PersistentStorage.
Definition at line 107 of file TMC4671.cpp.
| void TMC4671::setAdcOffset | ( | uint32_t | adc_I0_offset, |
| uint32_t | adc_I1_offset ) |
Definition at line 1961 of file TMC4671.cpp.
| void TMC4671::setAdcScale | ( | uint32_t | adc_I0_scale, |
| uint32_t | adc_I1_scale ) |
Definition at line 1969 of file TMC4671.cpp.
| void TMC4671::setAddress | ( | uint8_t | address | ) |
Definition at line 93 of file TMC4671.cpp.
| void TMC4671::setBBM | ( | uint8_t | bbml, |
| uint8_t | bbmh ) |
Definition at line 2404 of file TMC4671.cpp.
| void TMC4671::setBiquadFlux | ( | const TMC4671Biquad & | filter | ) |
Applies a biquad filter to the flux target Set nullptr to disable
Definition at line 2171 of file TMC4671.cpp.
| void TMC4671::setBiquadPos | ( | const TMC4671Biquad & | filter | ) |
Applies a biquad filter to the pos target Set nullptr to disable
Definition at line 2192 of file TMC4671.cpp.
| void TMC4671::setBiquadTorque | ( | const TMC4671Biquad & | filter | ) |
Applies a biquad filter to the torque target Set nullptr to disable
Definition at line 2234 of file TMC4671.cpp.
| void TMC4671::setBiquadVel | ( | const TMC4671Biquad & | filter | ) |
Applies a biquad filter to the actual measured velocity Set nullptr to disable
Definition at line 2213 of file TMC4671.cpp.
| void TMC4671::setBrakeLimits | ( | uint16_t | low, |
| uint16_t | high ) |
Sets the raw brake resistor limits. Centered at 0x7fff Set both 0xffff to deactivate
Definition at line 2286 of file TMC4671.cpp.
| void TMC4671::setCpr | ( | uint32_t | cpr | ) |
Definition at line 1930 of file TMC4671.cpp.
|
overridevirtual |
Can pass an external encoder if driver has no integrated encoder This allows a driver to get an external encoder assigned if it requires one and has the capability of using external encoders
Reimplemented from MotorDriver.
Definition at line 1856 of file TMC4671.cpp.
| void TMC4671::setEncoderIndexFlagEnabled | ( | bool | enabled, |
| bool | zeroEncoder = false ) |
Enables or disables the encoder index interruption on the flag pin depending on the selected encoder
Definition at line 882 of file TMC4671.cpp.
| void TMC4671::setEncoderType | ( | EncoderType_TMC | type | ) |
Changes the encoder type and calls init methods for the encoder types. Setup the specific parameters (abnconf, aencconf...) first.
Definition at line 1520 of file TMC4671.cpp.
| void TMC4671::setExternalEncoderAllowed | ( | bool | allow | ) |
Definition at line 2003 of file TMC4671.cpp.
| void TMC4671::setFFMode | ( | FFMode | mode | ) |
Definition at line 1990 of file TMC4671.cpp.
| void TMC4671::setFlux | ( | int16_t | flux | ) |
Definition at line 2055 of file TMC4671.cpp.
| void TMC4671::setFluxTorque | ( | int16_t | flux, |
| int16_t | torque ) |
Definition at line 2064 of file TMC4671.cpp.
| void TMC4671::setFluxTorqueFF | ( | int16_t | flux, |
| int16_t | torque ) |
Definition at line 2075 of file TMC4671.cpp.
| void TMC4671::setGpioMode | ( | TMC_GpioMode | mode | ) |
Changes the mode of the 8 GPIO pins Banks A and B can be mapped independently to inputs or outputs, as a DS adc interface or by default as a secondary debug SPI port
Definition at line 1782 of file TMC4671.cpp.
| void TMC4671::setGpioPins | ( | uint8_t | pins | ) |
Changes the state of gpio pins that are mapped as output lower 4 bits bank A, upper 4 bits bank B
Definition at line 1816 of file TMC4671.cpp.
| void TMC4671::setHwType | ( | uint8_t | type | ) |
Sets some constants and features depending on the hardware version of the driver
Definition at line 2713 of file TMC4671.cpp.
| void TMC4671::setLimits | ( | TMC4671Limits | limits | ) |
Definition at line 2145 of file TMC4671.cpp.
| void TMC4671::setMotionMode | ( | MotionMode | mode, |
| bool | force = false ) |
Definition at line 1611 of file TMC4671.cpp.
| void TMC4671::setMotorType | ( | MotorType | motor, |
| uint16_t | poles ) |
Definition at line 2024 of file TMC4671.cpp.
| void TMC4671::setOpenLoopSpeedAccel | ( | int32_t | speed, |
| uint32_t | accel ) |
Definition at line 1627 of file TMC4671.cpp.
| void TMC4671::setPhiE_ext | ( | int16_t | phiE | ) |
Definition at line 935 of file TMC4671.cpp.
| void TMC4671::setPhiEtype | ( | PhiE | type | ) |
Definition at line 1593 of file TMC4671.cpp.
| void TMC4671::setPidPrecision | ( | TMC4671PidPrecision | setting | ) |
Definition at line 2132 of file TMC4671.cpp.
| void TMC4671::setPids | ( | TMC4671PIDConf | pids | ) |
Definition at line 2099 of file TMC4671.cpp.
|
overridevirtual |
Changes position using offset from index
Reimplemented from Encoder.
Definition at line 1874 of file TMC4671.cpp.
| void TMC4671::setPositionExt | ( | int32_t | pos | ) |
Definition at line 931 of file TMC4671.cpp.
| void TMC4671::setPosSel | ( | PosSelection | psel | ) |
Changes the position sensor source
Definition at line 1763 of file TMC4671.cpp.
|
private |
Sets pwm mode:
0 = pwm off
1 = pwm off, HS low, LS high
2 = pwm off, HS high, LS low
3 = pwm off
4 = pwm off
5 = pwm LS only
6 = pwm HS only
7 = pwm on centered, FOC mode
Definition at line 2400 of file TMC4671.cpp.
|
private |
Definition at line 2411 of file TMC4671.cpp.
| void TMC4671::setPwmFreq | ( | float | freq | ) |
Changes the PWM frequency to a desired frequency Possible values depend on the hwclock. At 25MHz the lowest possible frequency is 24.1kHz
Definition at line 2455 of file TMC4671.cpp.
|
private |
Changes PWM frequency Max value 4095, minimum 255
Definition at line 2444 of file TMC4671.cpp.
| void TMC4671::setSequentialPI | ( | bool | sequential | ) |
Definition at line 1998 of file TMC4671.cpp.
| bool TMC4671::setSpiAddr | ( | uint8_t | chan | ) |
| void TMC4671::setStatusFlags | ( | StatusFlags | flags | ) |
Definition at line 2589 of file TMC4671.cpp.
| void TMC4671::setStatusFlags | ( | uint32_t | flags | ) |
Definition at line 2585 of file TMC4671.cpp.
| void TMC4671::setStatusMask | ( | StatusFlags | mask | ) |
Definition at line 2577 of file TMC4671.cpp.
| void TMC4671::setStatusMask | ( | uint32_t | mask | ) |
Definition at line 2581 of file TMC4671.cpp.
|
private |
Enable or disable space vector pwm for 3 phase motors Normally active but should be disabled if the motor has no isolated star point
Definition at line 2422 of file TMC4671.cpp.
| void TMC4671::setTargetPos | ( | int32_t | pos | ) |
Enables position mode and sets a target position
Definition at line 901 of file TMC4671.cpp.
| void TMC4671::setTargetVelocity | ( | int32_t | vel | ) |
Enables velocity mode and sets a velocity target
Definition at line 917 of file TMC4671.cpp.
| void TMC4671::setTmcPos | ( | int32_t | pos | ) |
Changes position in tmc register
Definition at line 1892 of file TMC4671.cpp.
| void TMC4671::setTorque | ( | int16_t | torque | ) |
Definition at line 2045 of file TMC4671.cpp.
| void TMC4671::setTorqueFilter | ( | TMC4671Biquad_conf & | conf | ) |
Changes the torque biquad filter
Definition at line 2255 of file TMC4671.cpp.
| void TMC4671::setTorqueLimit | ( | uint16_t | limit | ) |
Definition at line 2126 of file TMC4671.cpp.
| void TMC4671::setUdUq | ( | int16_t | ud, |
| int16_t | uq ) |
Definition at line 1654 of file TMC4671.cpp.
| void TMC4671::setup_ABN_Enc | ( | TMC4671ABNConf | encconf | ) |
Definition at line 1294 of file TMC4671.cpp.
| void TMC4671::setup_AENC | ( | TMC4671AENCConf | encconf | ) |
Definition at line 1318 of file TMC4671.cpp.
| void TMC4671::setup_HALL | ( | TMC4671HALLConf | hallconf | ) |
Definition at line 1335 of file TMC4671.cpp.
|
private |
Definition at line 3128 of file TMC4671.cpp.
| void TMC4671::setupFeedForwardTorque | ( | int32_t | gain, |
| int32_t | constant ) |
Definition at line 1977 of file TMC4671.cpp.
| void TMC4671::setupFeedForwardVelocity | ( | int32_t | gain, |
| int32_t | constant ) |
Definition at line 1983 of file TMC4671.cpp.
| void TMC4671::setUqUdLimit | ( | uint16_t | limit | ) |
Limits the PWM value
Definition at line 2121 of file TMC4671.cpp.
| void TMC4671::setVelSel | ( | VelSelection | vsel, |
| uint8_t | mode = 0 ) |
Changes the velocity sensor source (RPM if PhiM source used)
| mode | 0 = fixed frequency sampling (~4369.067Hz), 1 = PWM sync time difference measurement |
Definition at line 1772 of file TMC4671.cpp.
|
virtual |
Enable the motor driver
Reimplemented from MotorDriver.
Definition at line 1669 of file TMC4671.cpp.
| void TMC4671::statusCheck | ( | ) |
Reads and resets all status flags and executes depending on status flags
Definition at line 2596 of file TMC4671.cpp.
|
virtual |
Disable the motor driver
Reimplemented from MotorDriver.
Definition at line 1658 of file TMC4671.cpp.
|
virtual |
Reimplemented from TimerHandler.
Definition at line 3115 of file TMC4671.cpp.
|
virtual |
Sets a torque in positive or negative direction For ADC linearity reasons under 25000 is recommended
Reimplemented from MotorDriver.
Definition at line 1732 of file TMC4671.cpp.
| void TMC4671::updateReg | ( | uint8_t | reg, |
| uint32_t | dat, | ||
| uint32_t | mask, | ||
| uint8_t | shift ) |
Definition at line 2549 of file TMC4671.cpp.
| void TMC4671::writeReg | ( | uint8_t | reg, |
| uint32_t | dat ) |
Definition at line 2521 of file TMC4671.cpp.
| void TMC4671::writeRegAsync | ( | uint8_t | reg, |
| uint32_t | dat ) |
Definition at line 2533 of file TMC4671.cpp.
| void TMC4671::zeroAbnUsingPhiM | ( | bool | offsetPhiE = false | ) |
Definition at line 807 of file TMC4671.cpp.
|
friend |
| TMC4671ABNConf TMC4671::abnconf |
| TMC4671AENCConf TMC4671::aencconf |
|
private |
| TMC4671MainConfig TMC4671::conf |
|
private |
| TMC4671Limits TMC4671::curLimits |
|
private |
| TMC4671PIDConf TMC4671::curPids |
|
private |
|
private |
|
private |
|
private |
| TMC4671FlashAddrs TMC4671::flashAddrs |
| TMC4671HALLConf TMC4671::hallconf |
|
private |
|
static |
|
private |
|
private |
|
private |
|
private |
| TMC4671PidPrecision TMC4671::pidPrecision |
|
private |
|
private |
|
private |
| StatusFlags TMC4671::statusFlags = {0} |
| StatusFlags TMC4671::statusMask = {0} |
|
staticprotected |
|
private |