MotorWare f2806x Module API Documentation

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

spintac_vel_id.h
Go to the documentation of this file.
1 #ifndef __SPINTAC_VEL_ID_H__
2 #define __SPINTAC_VEL_ID_H__
3 /* --COPYRIGHT--,BSD
4 * Copyright (c) 2012, LineStream Technologies Incorporated
5 * Copyright (c) 2012, Texas Instruments Incorporated
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * * Neither the names of Texas Instruments Incorporated, LineStream
20 * Technologies Incorporated, nor the names of its contributors may be
21 * used to endorse or promote products derived from this software without
22 * specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
26 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
28 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
31 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
32 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
33 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
34 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 * --/COPYRIGHT--*/
36
43
45
46
47 #include "spintac_version.h"
48
51 typedef enum
52 {
53 ST_VEL_ID_IDLE=0,
54 ST_VEL_ID_INIT,
55 ST_VEL_ID_BUSY
56 } ST_VelIdStatus_e;
57
61 typedef struct {
62 // Configuration parameters: Can be set only once at system startup
63 _iq24 T_sec;
64 int16_t LpfTime_tick;
65 _iq24 TimeOut_sec;
66
67 // Config parameters that may be modified
68 _iq24 GoalSpeed;
69 _iq24 OutMax;
70 _iq24 RampTime_sec;
71 bool Sensorless;
72 } ST_VelIdCfg_t; // Structure for SpinTAC Identify configuration
73
74
78 typedef struct {
79 // Configuration structure
80 ST_VelIdCfg_t cfg;
81 /* Input Variables */
82 _iq24 VelFdb;
83 // Control bits
84 bool ENB;
85 /* Output Variables */
86 _iq24 Out;
87 // Estimation Result
88 _iq24 InertiaEst;
89 _iq24 FrictionEst;
90 // Information variables
91 ST_VelIdStatus_e STATUS;
92 uint16_t ERR_ID;
93 /* Internal variables */
94 uint32_t s0[9];
95 } ST_VelId_t; // Structure for SpinTAC Identify
96
97 typedef struct _ST_VELID_Handle_ *ST_VELID_Handle; // SpinTAC Velocity Identify Handle
98
102 static inline void STVELID_setSampleTime_sec(ST_VELID_Handle handle, _iq24 sampleTime) {
103 ST_VelId_t *obj = (ST_VelId_t *)handle;
104
105 if(obj->STATUS == ST_VEL_ID_IDLE) {
106 obj->cfg.T_sec = sampleTime;
107 }
108
109 return;
110 } // end of STVELID_setSampleTime_sec function
111
115 static inline void STVELID_setOutputMaximum(ST_VELID_Handle handle, _iq24 outMax) {
116 ST_VelId_t *obj = (ST_VelId_t *)handle;
117
118 if(obj->STATUS == ST_VEL_ID_IDLE) {
119 obj->cfg.OutMax = outMax;
120 }
121
122 return;
123 } // end of STVELID_setOutputMaximum function
124
128 static inline void STVELID_setGoalSpeed(ST_VELID_Handle handle, _iq24 goalSpeed) {
129 ST_VelId_t *obj = (ST_VelId_t *)handle;
130
131 obj->cfg.GoalSpeed = goalSpeed;
132
133 return;
134 } // end of STVELID_setGoalSpeed function
135
139 static inline _iq24 STVELID_getGoalSpeed(ST_VELID_Handle handle) {
140 ST_VelId_t *obj = (ST_VelId_t *)handle;
141
142 return(obj->cfg.GoalSpeed);
143 } // end of STVELID_getGoalSpeed function
144
148 static inline void STVELID_setLowPassFilterTime_tick(ST_VELID_Handle handle, int16_t lpfTime) {
149 ST_VelId_t *obj = (ST_VelId_t *)handle;
150
151 if(obj->STATUS == ST_VEL_ID_IDLE) {
152 obj->cfg.LpfTime_tick = lpfTime;
153 }
154
155 return;
156 } // end of STVELID_setLowPassFilterTime_tick function
157
161 static inline void STVELID_setTimeOut_sec(ST_VELID_Handle handle, _iq24 timeOut) {
162 ST_VelId_t *obj = (ST_VelId_t *)handle;
163
164 if(obj->STATUS == ST_VEL_ID_IDLE) {
165 obj->cfg.TimeOut_sec = timeOut;
166 }
167
168 return;
169 } // end of STVELID_setTimeOut_sec function
170
174 static inline void STVELID_setTorqueRampTime_sec(ST_VELID_Handle handle, _iq24 rampTime) {
175 ST_VelId_t *obj = (ST_VelId_t *)handle;
176
177 if(obj->STATUS == ST_VEL_ID_IDLE) {
178 obj->cfg.RampTime_sec = rampTime;
179 }
180
181 return;
182 } // end of STVELID_setTorqueRampTime_sec function
183
187 static inline _iq24 STVELID_getTorqueRampTime_sec(ST_VELID_Handle handle) {
188 ST_VelId_t *obj = (ST_VelId_t *)handle;
189
190 return(obj->cfg.RampTime_sec);
191 } // end of STVELID_getTorqueRampTime_sec function
192
196 static inline void STVELID_setSensorlessFeedback(ST_VELID_Handle handle, bool sensorless) {
197 ST_VelId_t *obj = (ST_VelId_t *)handle;
198
199 if(obj->STATUS == ST_VEL_ID_IDLE) {
200 obj->cfg.Sensorless = sensorless;
201 }
202
203 return;
204 } // end of STVELID_setTorqueRampTime_sec function
205
209 static inline void STVELID_setVelocityFeedback(ST_VELID_Handle handle, _iq24 velFdb) {
210 ST_VelId_t *obj = (ST_VelId_t *)handle;
211
212 obj->VelFdb = velFdb;
213
214 return;
215 } // end of STVELID_setVelocityFeedback function
216
220 static inline _iq24 STVELID_getTorqueReference(ST_VELID_Handle handle) {
221 ST_VelId_t *obj = (ST_VelId_t *)handle;
222
223 return (obj->Out);
224 } // end of STVELID_getTorqueReference function
225
229 static inline void STVELID_setTorqueReference(ST_VELID_Handle handle, _iq24 out) {
230 ST_VelId_t *obj = (ST_VelId_t *)handle;
231
232 obj->Out = out;
233
234 return;
235 } // end of STVELID_setTorqueReference function
236
240 static inline _iq24 STVELID_getInertiaEstimate(ST_VELID_Handle handle) {
241 ST_VelId_t *obj = (ST_VelId_t *)handle;
242
243 return (obj->InertiaEst);
244 } // end of STVELID_getInertiaEstimate function
245
249 static inline _iq24 STVELID_getFrictionEstimate(ST_VELID_Handle handle) {
250 ST_VelId_t *obj = (ST_VelId_t *)handle;
251
252 return (obj->FrictionEst);
253 } // end of STVELID_getFrictionEstimate function
254
258 static inline void STVELID_setEnable(ST_VELID_Handle handle, bool enb) {
259 ST_VelId_t *obj = (ST_VelId_t *)handle;
260
261 obj->ENB = enb;
262
263 return;
264 } // end of STVELID_setEnable function
265
269 static inline bool STVELID_getEnable(ST_VELID_Handle handle) {
270 ST_VelId_t *obj = (ST_VelId_t *)handle;
271
272 return (obj->ENB);
273 } // end of STVELID_getEnable function
274
278 static inline ST_VelIdStatus_e STVELID_getStatus(ST_VELID_Handle handle) {
279 ST_VelId_t *obj = (ST_VelId_t *)handle;
280
281 return (obj->STATUS);
282 } // end of STVELID_getStatus function
283
287 static inline uint16_t STVELID_getErrorID(ST_VELID_Handle handle) {
288 ST_VelId_t *obj = (ST_VelId_t *)handle;
289
290 return (obj->ERR_ID);
291 } // end of STVELID_getErrorID function
292
297 ST_VELID_Handle STVELID_init(void *pMemory, const size_t numBytes);
298
301 void STVELID_run(ST_VELID_Handle handle);
302
304 #endif //__SPINTAC_VEL_ID_H__
305
STVELID_setEnable
static void STVELID_setEnable(ST_VELID_Handle handle, bool enb)
Sets the Enable signal (ENB) for SpinTAC Velocity Identify.
Definition: spintac_vel_id.h:258
ST_VelIdStatus_e
ST_VelIdStatus_e
Enumeration for the Velocity Identify Status states.
Definition: spintac_vel_id.h:51
STVELID_getInertiaEstimate
static _iq24 STVELID_getInertiaEstimate(ST_VELID_Handle handle)
Gets the System Inertia (InertiaEst) from SpinTAC Velocity Identify.
Definition: spintac_vel_id.h:240
ST_VelId_t
Defines the ST_VelId_t data.
Definition: spintac_vel_id.h:78
STVELID_setGoalSpeed
static void STVELID_setGoalSpeed(ST_VELID_Handle handle, _iq24 goalSpeed)
Sets the Goal Speed of inertia identification (cfg.GoalSpeed) for SpinTAC Velocity Identify...
Definition: spintac_vel_id.h:128
ST_VelId_t::Out
_iq24 Out
control output { unit: [PU], value range: [-cfg.OutMax, cfg.OutMax] }
Definition: spintac_vel_id.h:86
STVELID_setSensorlessFeedback
static void STVELID_setSensorlessFeedback(ST_VELID_Handle handle, bool sensorless)
Sets the feedback type (cfg.Sensorless) for SpinTAC Velocity Identify.
Definition: spintac_vel_id.h:196
STVELID_run
void STVELID_run(ST_VELID_Handle handle)
Runs the SpinTAC Identify function.
STVELID_getErrorID
static uint16_t STVELID_getErrorID(ST_VELID_Handle handle)
Gets the Error value (ERR_ID) for SpinTAC Velocity Identify.
Definition: spintac_vel_id.h:287
ST_VelId_t::STATUS
ST_VelIdStatus_e STATUS
Status { ST_VEL_ID_IDLE, ST_VEL_ID_INIT, ST_VEL_ID_BUSY }.
Definition: spintac_vel_id.h:91
STVELID_setLowPassFilterTime_tick
static void STVELID_setLowPassFilterTime_tick(ST_VELID_Handle handle, int16_t lpfTime)
Sets the Low Pass Filter Time Constant (cfg.LpfTime_tick) for SpinTAC Velocity Identify.
Definition: spintac_vel_id.h:148
ST_VelId_t::FrictionEst
_iq24 FrictionEst
Friction Coefficient { unit: [PU/(pu/s)], value range: positive _IQ24 value }.
Definition: spintac_vel_id.h:89
ST_VEL_ID_IDLE
Velocity Identify is in idle state, zero output.
Definition: spintac_vel_id.h:53
ST_VelId_t::ENB
bool ENB
Enable bit { false: enable; true: disable }.
Definition: spintac_vel_id.h:84
ST_VelIdCfg_t::RampTime_sec
_iq24 RampTime_sec
Torque acceleration ramp time { unit [s], value range: [T_sec, 25.0] }.
Definition: spintac_vel_id.h:70
STVELID_setOutputMaximum
static void STVELID_setOutputMaximum(ST_VELID_Handle handle, _iq24 outMax)
Sets the Maximum Output (cfg.OutMax) for SpinTAC Velocity Identify.
Definition: spintac_vel_id.h:115
STVELID_getStatus
static ST_VelIdStatus_e STVELID_getStatus(ST_VELID_Handle handle)
Gets the Status value (STATUS) for SpinTAC Velocity Identify.
Definition: spintac_vel_id.h:278
STVELID_getTorqueRampTime_sec
static _iq24 STVELID_getTorqueRampTime_sec(ST_VELID_Handle handle)
Gets the Torque Ramp Time (cfg.RampTime_sec) for SpinTAC Velocity Identify.
Definition: spintac_vel_id.h:187
ST_VEL_ID_INIT
Velocity Identify is in init state, validating configured parameters.
Definition: spintac_vel_id.h:54
STVELID_getGoalSpeed
static _iq24 STVELID_getGoalSpeed(ST_VELID_Handle handle)
Gets the Goal Speed of inertia identification (cfg.GoalSpeed) for SpinTAC Velocity Identify...
Definition: spintac_vel_id.h:139
ST_VEL_ID_BUSY
Velocity Identify is in busy state, identifying system inertia.
Definition: spintac_vel_id.h:55
_iq24
long _iq24
Definition: 32b/IQmathLib.h:230
ST_VelIdCfg_t::TimeOut_sec
_iq24 TimeOut_sec
Maximum time allowed for inertia estimation process { unit: [s], value range: [1.0, 10.0] }.
Definition: spintac_vel_id.h:65
ST_VELID_Handle
struct _ST_VELID_Handle_ * ST_VELID_Handle
Definition: spintac_vel_id.h:97
STVELID_setTimeOut_sec
static void STVELID_setTimeOut_sec(ST_VELID_Handle handle, _iq24 timeOut)
Sets the Time Out Time (cfg.TimeOut_sec) for SpinTAC Velocity Identify.
Definition: spintac_vel_id.h:161
spintac_version.h
Public interface, object, and function definitions related to the SpinTAC Version object...
STVELID_setVelocityFeedback
static void STVELID_setVelocityFeedback(ST_VELID_Handle handle, _iq24 velFdb)
Sets the Velocity Feedback (VelFdb) for SpinTAC Velocity Identify.
Definition: spintac_vel_id.h:209
ST_VelIdCfg_t::LpfTime_tick
int16_t LpfTime_tick
Low pass filter ISR ticks { unit: [ticks], value range: [1, 100] }.
Definition: spintac_vel_id.h:64
ST_VelId_t::cfg
ST_VelIdCfg_t cfg
Configuration substructure.
Definition: spintac_vel_id.h:80
ST_VelIdCfg_t::T_sec
_iq24 T_sec
Sample time { unit: [s], value range: (0.0, 0.01] }.
Definition: spintac_vel_id.h:63
STVELID_getEnable
static bool STVELID_getEnable(ST_VELID_Handle handle)
Gets the Enable signal (ENB) for SpinTAC Velocity Identify.
Definition: spintac_vel_id.h:269
ST_VelIdCfg_t::GoalSpeed
_iq24 GoalSpeed
Speed to reach in inertia estimation { unit: [pu/s], value range: (0, 1.0] }.
Definition: spintac_vel_id.h:68
ST_VelIdCfg_t::Sensorless
bool Sensorless
Indicates if the FOC is using a sensorless estimator.
Definition: spintac_vel_id.h:71
ST_VelIdCfg_t::OutMax
_iq24 OutMax
Control signal limit { unit: [PU], value range: (0, 1.0] }.
Definition: spintac_vel_id.h:69
STVELID_setTorqueReference
static void STVELID_setTorqueReference(ST_VELID_Handle handle, _iq24 out)
Sets the Torque (Iq) Reference (Out) for SpinTAC Velocity Identify.
Definition: spintac_vel_id.h:229
STVELID_getFrictionEstimate
static _iq24 STVELID_getFrictionEstimate(ST_VELID_Handle handle)
Gets the System Friction (FrictionEst) from SpinTAC Velocity Identify.
Definition: spintac_vel_id.h:249
ST_VelId_t::VelFdb
_iq24 VelFdb
Velocity feedback { unit: [pu/s], value range: [-1.0, 1.0] }.
Definition: spintac_vel_id.h:82
ST_VelIdCfg_t
Defines the ST_VelIdCfg_t data.
Definition: spintac_vel_id.h:61
STVELID_setTorqueRampTime_sec
static void STVELID_setTorqueRampTime_sec(ST_VELID_Handle handle, _iq24 rampTime)
Sets the Torque Ramp Time (cfg.RampTime_sec) for SpinTAC Velocity Identify.
Definition: spintac_vel_id.h:174
STVELID_init
ST_VELID_Handle STVELID_init(void *pMemory, const size_t numBytes)
Initializes the SpinTAC Velocity Identify object.
ST_VelId_t::InertiaEst
_iq24 InertiaEst
Estimated Inertia { unit: [PU/(pu/s^2)], value range: positive _IQ24 value }.
Definition: spintac_vel_id.h:88
STVELID_getTorqueReference
static _iq24 STVELID_getTorqueReference(ST_VELID_Handle handle)
Gets the Torque (Iq) Reference value (Out) from SpinTAC Velocity Identify.
Definition: spintac_vel_id.h:220
STVELID_setSampleTime_sec
static void STVELID_setSampleTime_sec(ST_VELID_Handle handle, _iq24 sampleTime)
Sets the Sample Time (cfg.T_sec) for SpinTAC Velocity Identify.
Definition: spintac_vel_id.h:102
ST_VelId_t::ERR_ID
uint16_t ERR_ID
Error ID { 0: no error; others: see error code }.
Definition: spintac_vel_id.h:92