SPRUHJ1I January 2013 – October 2021 TMS320F2802-Q1 , TMS320F28026-Q1 , TMS320F28026F , TMS320F28027-Q1 , TMS320F28027F , TMS320F28027F-Q1 , TMS320F28052-Q1 , TMS320F28052F , TMS320F28052F-Q1 , TMS320F28052M , TMS320F28052M-Q1 , TMS320F28054-Q1 , TMS320F28054F , TMS320F28054F-Q1 , TMS320F28054M , TMS320F28054M-Q1 , TMS320F2806-Q1 , TMS320F28062-Q1 , TMS320F28062F , TMS320F28062F-Q1 , TMS320F28068F , TMS320F28068M , TMS320F28069-Q1 , TMS320F28069F , TMS320F28069F-Q1 , TMS320F28069M , TMS320F28069M-Q1
This should be done in the main function of the project ahead of the forever loop. This will load all of the default values into SpinTAC Position Control. This step can be completed by running the functions ST_init and ST_setupPosCtl that are declared in the spintac_position.h header file. If you do not wish to use these two functions, the code example below can be used to configure SpinTAC Position Control component. This configuration of SpinTAC Position Control represents the typical configuration that should work for most motors.
// Initialize SpinTAC Position Control
stPosCtlHandle = STPOSCTL_init(&stPosCtl, sizeof(stPosCtl));
// Setup the maximum current in PU
_iq maxCurrent_PU = _IQ(USER_MOTOR_MAX_CURRENT / USER_IQ_FULL_SCALE_CURRENT_A);
// Instance of the position controller
STPOSCTL_setAxis(stPosCtlHandle, ST_AXIS0);
// Sample time [s], (0, 1)
STPOSCTL_setSampleTime_sec(stPosCtlHandle, _IQ(ST_SAMPLE_TIME));
// System inertia upper (0, 127.9999] and lower (0, InertiaMax] limits [PU/(pu/s^2)]
STPOSCTL_setInertiaMaximums(stPosCtlHandle, _IQ(10.0), _IQ(0.001));
// System velocity limit (0, 1.0] [pu/s]
STPOSCTL_setVelocityMaximum(obj->;posCtlHandle, _IQ24(1.0));
// System control signal high (0, 1] & low [-1, 0) limits [PU]
STPOSCTL_setOutputMaximums(stPosCtlHandle, maxCurrent_PU, -maxCurrent_PU);
// System maximum (0, 1.0] and minimum [-1.0, 0) velocity [pu/s]
STPOSCTL_setVelocityMaximums(stPosCtlHandle, _IQ(1.0), _IQ(-1.0));
// System maximum value for mechanical revolutions [MRev]
STPOSCTL_setPositionRolloverMaximum_mrev(stPosCtlHandle, _IQ24(ST_MREV_ROLLOVER));
// Sets the values used for converting between pu and MRev
STPOSCTL_setUnitConversion(stPosCtlHandle, USER_IQ_FULL_SCALE_FREQ_Hz,
USER_MOTOR_NUM_POLE_PAIRS);
// System maximum allowable error [MRev]
STPOSCTL_setPositionErrorMaximum_mrev(stPosCtlHandle,
_IQ24(ST_POS_ERROR_MAXIMUM_MREV));
// Disturbance type {true: Ramp; false: Square}
STPOSCTL_setRampDisturbanceFlag(stPosCtlHandle, false);
// System upper (0, 0.1/(cfg.T_sec*20)] and lower [0, BwScaleMax] limits for BWScale
STPOSCTL_setBandwidthScaleMaximums(stPosCtlHandle,
_IQ24((0.1) / (ST_SAMPLE_TIME * 20.0)), _IQ24(0.01));
// Enables the feedback filter
STPOSCTL_setFilterEnableFlag(stPosCtlHandle, true);
// System inertia [PU/(pu/s^2)], [InertiaMin, InertiaMax]
STPOSCTL_setInertia(stPosCtlHandle, _IQ(USER_MOTOR_INERTIA));
// Controller bandwidth scale [BwScaleMin, BwScaleMax]
STPOSCTL_setBandwidthScale(stPosCtlHandle, _IQ24(USER_SYSTEM_BANDWIDTH_SCALE));
// Initially ST_PosCtl is not enabled
STPOSCTL_setEnable(stPosCtlHandle, false);
// Initially ST_PosCtl is not in reset
STPOSCTL_setReset(stPosCtlHandle, false);