1 #ifndef __SPINTAC_POS_PLAN_H__
2 #define __SPINTAC_POS_PLAN_H__
51 #define ST_POS_PLAN_ACT_DWORDS (5)
52 #define ST_POS_PLAN_COND_DWORDS (3)
54 #define ST_POS_PLAN_VAR_DWORDS (2)
56 #define ST_POS_PLAN_TRAN_DWORDS (7)
58 #define ST_POS_PLAN_STATE_DWORDS (7)
62 #ifndef __ST_PLAN_ENUM__
63 #define __ST_PLAN_ENUM__
132 #endif //__ST_PLAN_ENUM__
134 #ifndef __ST_PLAN_ERROR__
135 #define __ST_PLAN_ERROR__
143 #endif //__ST_PLAN_ERROR__
444 void STPOSPLAN_setCfgTran(
ST_POSPLAN_Handle handle, uint16_t TranIdx, uint16_t FromState, uint16_t ToState,
ST_PlanCond_e AndOr, uint16_t CondIdx1, uint16_t CondIdx2,
_iq24 VelLim,
_iq24 AccLim,
_iq24 DecLim,
_iq20 JrkLim);
458 void STPOSPLAN_getCfgTran(
ST_POSPLAN_Handle handle, uint16_t TranIdx, uint16_t *FromState, uint16_t *ToState,
ST_PlanCond_e *AndOr, uint16_t *CondIdx1, uint16_t *CondIdx2,
_iq24 *VelLim,
_iq24 *AccLim,
_iq24 *DecLim,
_iq20 *JrkLim);
632 void STPOSPLAN_setCfgArray(
ST_POSPLAN_Handle handle, uint32_t *cfgArray,
const size_t numBytes, uint16_t MaxActNum, uint16_t MaxCondNum, uint16_t MaxVarNum, uint16_t MaxTranNum, uint16_t MaxStateNum);
static _iq24 STPOSPLAN_getVelocityLimit(ST_POSPLAN_Handle handle)
Gets the Velocity Limit (VelLim) for SpinTAC Position Plan.
void STPOSPLAN_delCfgCond(ST_POSPLAN_Handle handle, uint16_t CondIdx)
Deletes a Condition from the SpinTAC Position Plan configuration.
ST_PlanCond_e
Enumeration for the Plan Condition options.
uint16_t ERR_idx
Plan component index that caused the error.
static uint16_t STPOSPLAN_getCurrentTransition(ST_POSPLAN_Handle handle)
Gets the Current Transition (CurTran) for SpinTAC Position Plan.
ST_PlanComp_e
Enumeration for the Plan Compare options.
Compares, VarIdx >= Value1 OR VarIdx1 >= VarIdx2.
Transition/Action with either condition satisfied.
static _iq24 STPOSPLAN_getAccelerationLimit(ST_POSPLAN_Handle handle)
Gets the Acceleration Limit (AccLim) for SpinTAC Position Plan.
_iq24 VelLim
Velocity limit { unit: [pu/s], value range: (0.0, 1.0] }.
static uint16_t STPOSPLAN_getCurrentState(ST_POSPLAN_Handle handle)
Gets the Current State (CurState) for SpinTAC Position Plan.
void STPOSPLAN_getCfgActNum(ST_POSPLAN_Handle handle, uint16_t *ActNum)
Returns the number of configured Actions in SpinTAC Position Plan.
void STPOSPLAN_getCfgTranNum(ST_POSPLAN_Handle handle, uint16_t *TranNum)
Returns the number of configured Transitions in SpinTAC Position Plan.
static void STPOSPLAN_setReset(ST_POSPLAN_Handle handle, bool res)
Sets the Reset signal (RES) for SpinTAC Position Plan.
ST_PlanVar_e
Enumeration for the Plan variable types.
ST_PlanError_t CfgError
Error decoding structure.
void STPOSPLAN_run(ST_POSPLAN_Handle handle)
Runs SpinTAC Position Plan calculation.
void STPOSPLAN_addCfgVar(ST_POSPLAN_Handle handle, ST_PlanVar_e Type, _iq24 Value)
Adds a variable to the SpinTAC Position Plan configuration.
Compares, Value1 <= VarIdx <= Value2.
ST_PlanStatus_e
Enumeration for the Plan Status States.
wait state, holding the position reference in idle state
Plan is waiting for a transition condition to be true.
static void STPOSPLAN_setEnable(ST_POSPLAN_Handle handle, bool enb)
Sets the Enable signal (ENB) for SpinTAC Position Plan.
static uint16_t STPOSPLAN_getCfgError(ST_POSPLAN_Handle handle, uint16_t *ERR_idx, uint16_t *ERR_code)
Gets the Configuration Error for SpinTAC Position Plan.
Compares, VarIdx != Value1 OR VarIdx1 != VarIdx2.
static ST_PlanStatus_e STPOSPLAN_getStatus(ST_POSPLAN_Handle handle)
Gets the Status value (STATUS) for SpinTAC Position Plan.
void STPOSPLAN_setCfgCond(ST_POSPLAN_Handle handle, uint16_t CondIdx, uint16_t VarIdx, ST_PlanComp_e Comp, _iq24 Value1, _iq24 Value2)
Modifies a Condition in the SpinTAC Position Plan configuration.
Compares, Value1 > VarIdx > Value2.
void STPOSPLAN_delCfgAct(ST_POSPLAN_Handle handle, uint16_t ActIdx)
Deletes an action from the SpinTAC Position Plan configuration.
void STPOSPLAN_getVar(ST_POSPLAN_Handle handle, uint16_t VarIdx, _iq24 *Value)
Gets the value of a SpinTAC Position Plan variable.
void STPOSPLAN_setCfgHaltState(ST_POSPLAN_Handle handle, int32_t PosStepInt_mrev, _iq24 PosStepFrac_mrev, _iq24 VelLim, _iq24 AccLim, _iq20 JrkLim, int32_t Timer_tick)
Configures the SpinTAC Position Plan Halt state.
void STPOSPLAN_getCfgVar(ST_POSPLAN_Handle handle, uint16_t VarIdx, ST_PlanVar_e *Type, _iq24 *Value)
Returns a variable from the SpinTAC Position Plan configuration.
void STPOSPLAN_getCfgTran(ST_POSPLAN_Handle handle, uint16_t TranIdx, uint16_t *FromState, uint16_t *ToState, ST_PlanCond_e *AndOr, uint16_t *CondIdx1, uint16_t *CondIdx2, _iq24 *VelLim, _iq24 *AccLim, _iq24 *DecLim, _iq20 *JrkLim)
Get a Transition from the SpinTAC Position Plan configuration.
_iq20 JrkLim
Jerk Limit { unit: [pu/s^3], value range: [0.0005, 2000.0] }.
ST_POSPLAN_Handle STPOSPLAN_init(void *pMemory, const size_t numBytes)
Initializes the SpinTAC Position Plan component.
Compares, VarIdx <= Value1 OR VarIdx1 <= VarIdx2.
void STPOSPLAN_setCfg(ST_POSPLAN_Handle handle, _iq24 T_sec, bool LoopENB)
Configures SpinTAC Position Plan.
void STPOSPLAN_setCfgArray(ST_POSPLAN_Handle handle, uint32_t *cfgArray, const size_t numBytes, uint16_t MaxActNum, uint16_t MaxCondNum, uint16_t MaxVarNum, uint16_t MaxTranNum, uint16_t MaxStateNum)
Prepares SpinTAC Position Plan data structure.
static void STPOSPLAN_getPositionStep_mrev(ST_POSPLAN_Handle handle, int32_t *posStepInt_mrev, _iq24 *posStepFrac_mrev)
Gets the Position Step (posStepInt_mrev, posStepFrac_mrev) for SpinTAC Position Plan.
static int32_t STPOSPLAN_getCurrentTimerValue_tick(ST_POSPLAN_Handle handle)
Gets the Current Time Value (Timer_tick) for SpinTAC Position Plan.
static bool STPOSPLAN_getReset(ST_POSPLAN_Handle handle)
Gets the Reset signal (RES) for SpinTAC Position Plan.
Compares, Value1 < VarIdx < Value2.
halt state, return to the position reference in idle state
void STPOSPLAN_getCfgVarNum(ST_POSPLAN_Handle handle, uint16_t *VarNum)
Returns the number of configured Variables in SpinTAC Position Plan.
Transition/Action with no conditions satisfied.
uint16_t ERR_code
Function specific condition that caused the error.
Compares, Value1 > VarIdx >= Value2.
uint16_t CurTran
Current transition of the state machine.
void STPOSPLAN_addCfgCond(ST_POSPLAN_Handle handle, uint16_t VarIdx, ST_PlanComp_e Comp, _iq24 Value1, _iq24 Value2)
Adds a Condition to the SpinTAC Position Plan configuration.
_iq24 AccLim
Acceleration limit { unit: [pu/s^2], value range: [0.001, 120.0] }.
ST_PlanFsmState_e
Enumeration for the Plan FSM states.
void STPOSPLAN_addCfgState(ST_POSPLAN_Handle handle, int32_t PosStepInt_mrev, _iq24 PosStep_Fracmrev, int32_t Timer_tick)
Adds a State to the SpinTAC Position Plan configuration.
static _iq20 STPOSPLAN_getJerkLimit(ST_POSPLAN_Handle handle)
Gets the Jerk Limit (JrkLim) for SpinTAC Position Plan.
ST_PlanFsmState_e FsmState
State of the state machine.
void STPOSPLAN_setVar(ST_POSPLAN_Handle handle, uint16_t VarIdx, _iq24 Value)
Sets the value of a SpinTAC Position Plan variable.
Compares, VarIdx == Value1 OR VarIdx1 == VarIdx2.
Transition/Action with both conditions satisfied.
void STPOSPLAN_setCfgState(ST_POSPLAN_Handle handle, uint16_t StateIdx, int32_t PosStepInt_mrev, _iq24 PosStepFrac_mrev, int32_t Timer_tick)
Modifies a state in the SpinTAC Position Plan configuration.
struct _ST_POSPLAN_Handle_ * ST_POSPLAN_Handle
void STPOSPLAN_getCfgCondNum(ST_POSPLAN_Handle handle, uint16_t *CondNum)
Returns the number of configured Conditions in SpinTAC Position Plan.
void STPOSPLAN_getCfgHaltState(ST_POSPLAN_Handle handle, int32_t *PosStepInt_mrev, _iq24 *PosStepFrac_mrev, _iq24 *VelLim, _iq24 *AccLim, _iq20 *JrkLim, int32_t *Timer_tick)
Gets the SpinTAC Position Plan Halt state.
Compares, Value1 >= VarIdx >= Value2.
ST_PlanActTrgr_e
Enumeration for the Plan Action trigger point types.
Action will be considered when exiting the state.
Compares, VarIdx < Value1 OR VarIdx1 < VarIdx2.
void STPOSPLAN_runTick(ST_POSPLAN_Handle handle)
Runs SpinTAC Position Plan Timing. Call this only from an ISR.
void STPOSPLAN_addCfgTran(ST_POSPLAN_Handle handle, uint16_t FromState, uint16_t ToState, ST_PlanCond_e AndOr, uint16_t CondIdx1, uint16_t CondIdx2, _iq24 VelLim, _iq24 AccLim, _iq24 DecLim, _iq20 JrkLim)
Adds a Transition to the SpinTAC Position Plan configuration.
Compares, Value1 < VarIdx <= Value2.
bool RES
Reset bit { false: not reset; true: reset }.
void STPOSPLAN_addCfgAct(ST_POSPLAN_Handle handle, uint16_t State, ST_PlanCond_e AndOr, uint16_t CondIdx1, uint16_t CondIdx2, uint16_t VarIdx, ST_PlanActOptn_e Opt, _iq24 Value, ST_PlanActTrgr_e EnterExit)
Adds an action to the SpinTAC Position Plan configuration.
Public interface, object, and function definitions related to the SpinTAC Version object...
void STPOSPLAN_getCfg(ST_POSPLAN_Handle handle, _iq24 *T_sec, bool *LoopENB)
Gets the SpinTAC Position Plan configuration.
Compares, Value1 >= VarIdx > Value2.
Action will be considered when entering the state.
void STPOSPLAN_setCfgVarCond(ST_POSPLAN_Handle handle, uint16_t CondIdx, uint16_t VarIdx1, uint16_t VarIdx2, ST_PlanComp_e Comp)
Modifies a Variable Condition to the SpinTAC Position Plan configuration.
void STPOSPLAN_getCfgStateNum(ST_POSPLAN_Handle handle, uint16_t *StateNum)
Returns the number of configured States in SpinTAC Position Plan.
void STPOSPLAN_setCfgTran(ST_POSPLAN_Handle handle, uint16_t TranIdx, uint16_t FromState, uint16_t ToState, ST_PlanCond_e AndOr, uint16_t CondIdx1, uint16_t CondIdx2, _iq24 VelLim, _iq24 AccLim, _iq24 DecLim, _iq20 JrkLim)
Modifies a Transition in the SpinTAC Position Plan configuration.
uint16_t CurState
Current state of the state machine.
Action will set the variable equal to a value.
static ST_PlanFsmState_e STPOSPLAN_getFsmState(ST_POSPLAN_Handle handle)
Gets the State Machine State (FsmState) for SpinTAC Position Plan.
Action will add a value to the variable.
void STPOSPLAN_delCfgState(ST_POSPLAN_Handle handle, uint16_t StateIdx)
Deletes a state from the SpinTAC Position Plan configuration.
int32_t PosStepInt_mrev
Position Step Integer part { unit: [MRev] }.
init state, initialize internal states
Plan is in transition with a motion profile.
Compares, VarIdx > Value1 OR VarIdx1 > VarIdx2.
Transition/Action with first condition satisfied.
void STPOSPLAN_setUnitProfDone(ST_POSPLAN_Handle handle, bool ProDON)
Sets a flag in SpinTAC Position Plan to indicate if the unit profile is complete. ...
ST_PlanActOptn_e
Enumeration for the Plan Action Options.
uint16_t ERR_ID
Error ID { 0: no error; others: see error code }.
void STPOSPLAN_getCfgAct(ST_POSPLAN_Handle handle, uint16_t ActIdx, uint16_t *State, ST_PlanCond_e *AndOr, uint16_t *CondIdx1, uint16_t *CondIdx2, uint16_t *VarIdx, ST_PlanActOptn_e *Opt, _iq24 *Value, ST_PlanActTrgr_e *EnterExit)
Returns an action from the SpinTAC Position Plan configuration.
void STPOSPLAN_getCfgCond(ST_POSPLAN_Handle handle, uint16_t CondIdx, uint16_t *VarIdx, ST_PlanComp_e *Comp, _iq24 *Value1, _iq24 *Value2)
Returns a Condition from the SpinTAC Position Plan configuration.
void STPOSPLAN_reset(ST_POSPLAN_Handle handle)
Resets the SpinAC Position Plan component.
int32_t Timer_tick
State Timer { unit: [tick] }.
void STPOSPLAN_getCfgVarCond(ST_POSPLAN_Handle handle, uint16_t CondIdx, uint16_t *VarIdx1, uint16_t *VarIdx2, ST_PlanComp_e *Comp)
Returns a Variable Condition from the SpinTAC Position Plan configuration.
_iq24 PosStepFrac_mrev
Position Step fraction part { unit: [MRev], value range: (-1.0, 1.0)}.
idle state, holding position
bool ENB
Enable bit { false: disabled; true: enabled }.
Variable type input/output.
void STPOSPLAN_delCfgVarCond(ST_POSPLAN_Handle handle, uint16_t CondIdx)
Deletes a Variable Condition from the SpinTAC Position Plan configuration.
Compares, Value1 <= VarIdx < Value2.
Defines the ST_PosPlan_t data.
void STPOSPLAN_setCfgAct(ST_POSPLAN_Handle handle, uint16_t ActIdx, uint16_t State, ST_PlanCond_e AndOr, uint16_t CondIdx1, uint16_t CondIdx2, uint16_t VarIdx, ST_PlanActOptn_e Opt, _iq24 Value, ST_PlanActTrgr_e EnterExit)
Modifies an action in the SpinTAC Position Plan configuration.
busy state, running state machine
static _iq24 STPOSPLAN_getDecelerationLimit(ST_POSPLAN_Handle handle)
Gets the Deceleration Limit (DecLim) for SpinTAC Position Plan.
void STPOSPLAN_delCfgVar(ST_POSPLAN_Handle handle, uint16_t VarIdx)
Deletes a Variable from the SpinTAC Position Plan configuration.
_iq24 DecLim
Deceleration limit { unit: [pu/s^2], value range: [0.001, 120.0] }.
static bool STPOSPLAN_getEnable(ST_POSPLAN_Handle handle)
Gets the Enable signal (ENB) for SpinTAC Position Plan.
static uint16_t STPOSPLAN_getErrorID(ST_POSPLAN_Handle handle)
Gets the Error value (ERR_ID) for SpinTAC Position Plan.
void STPOSPLAN_delCfgTran(ST_POSPLAN_Handle handle, uint16_t TranIdx)
Deletes a Transition from the SpinTAC Position Plan configuration.
void STPOSPLAN_addCfgVarCond(ST_POSPLAN_Handle handle, uint16_t VarIdx1, uint16_t VarIdx2, ST_PlanComp_e Comp)
Adds a Variable Condition to the SpinTAC Position Plan configuration.
ST_PlanStatus_e STATUS
Plan status { ST_PLAN_IDLE, ST_PLAN_INIT, ST_PLAN_BUSY, ST_PLAN_HALT, ST_PLAN_WAIT}.
Plan is staying in a state until the timer is up.
void STPOSPLAN_setCfgVar(ST_POSPLAN_Handle handle, uint16_t VarIdx, ST_PlanVar_e Type, _iq24 Value)
Modifies a variable in the SpinTAC Position Plan configuration.
void STPOSPLAN_getCfgState(ST_POSPLAN_Handle handle, uint16_t StateIdx, int32_t *PosStepInt_mrev, _iq24 *PosStepFrac_mrev, int32_t *Timer_tick)
Returns a state from the SpinTAC Position Plan configuration.
Defines the ST_PlanError_t data.