MotorWare f2806x Module API Documentation
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 {
57 
61 typedef struct {
62  // Configuration parameters: Can be set only once at system startup
64  int16_t LpfTime_tick;
66 
67  // Config parameters that may be modified
71  bool Sensorless;
72 } ST_VelIdCfg_t; // Structure for SpinTAC Identify configuration
73 
74 
78 typedef struct {
79  // Configuration structure
81  /* Input Variables */
83  // Control bits
84  bool ENB;
85  /* Output Variables */
87  // Estimation Result
90  // Information variables
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 
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 
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 
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 
241  ST_VelId_t *obj = (ST_VelId_t *)handle;
242 
243  return (obj->InertiaEst);
244 } // end of STVELID_getInertiaEstimate function
245 
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 
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 
static void STVELID_setEnable(ST_VELID_Handle handle, bool enb)
Sets the Enable signal (ENB) for SpinTAC Velocity Identify.
ST_VelIdStatus_e
Enumeration for the Velocity Identify Status states.
static _iq24 STVELID_getInertiaEstimate(ST_VELID_Handle handle)
Gets the System Inertia (InertiaEst) from SpinTAC Velocity Identify.
Defines the ST_VelId_t data.
static void STVELID_setGoalSpeed(ST_VELID_Handle handle, _iq24 goalSpeed)
Sets the Goal Speed of inertia identification (cfg.GoalSpeed) for SpinTAC Velocity Identify...
_iq24 Out
control output { unit: [PU], value range: [-cfg.OutMax, cfg.OutMax] }
static void STVELID_setSensorlessFeedback(ST_VELID_Handle handle, bool sensorless)
Sets the feedback type (cfg.Sensorless) for SpinTAC Velocity Identify.
void STVELID_run(ST_VELID_Handle handle)
Runs the SpinTAC Identify function.
static uint16_t STVELID_getErrorID(ST_VELID_Handle handle)
Gets the Error value (ERR_ID) for SpinTAC Velocity Identify.
ST_VelIdStatus_e STATUS
Status { ST_VEL_ID_IDLE, ST_VEL_ID_INIT, ST_VEL_ID_BUSY }.
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.
_iq24 FrictionEst
Friction Coefficient { unit: [PU/(pu/s)], value range: positive _IQ24 value }.
Velocity Identify is in idle state, zero output.
bool ENB
Enable bit { false: enable; true: disable }.
_iq24 RampTime_sec
Torque acceleration ramp time { unit [s], value range: [T_sec, 25.0] }.
static void STVELID_setOutputMaximum(ST_VELID_Handle handle, _iq24 outMax)
Sets the Maximum Output (cfg.OutMax) for SpinTAC Velocity Identify.
static ST_VelIdStatus_e STVELID_getStatus(ST_VELID_Handle handle)
Gets the Status value (STATUS) for SpinTAC Velocity Identify.
static _iq24 STVELID_getTorqueRampTime_sec(ST_VELID_Handle handle)
Gets the Torque Ramp Time (cfg.RampTime_sec) for SpinTAC Velocity Identify.
Velocity Identify is in init state, validating configured parameters.
static _iq24 STVELID_getGoalSpeed(ST_VELID_Handle handle)
Gets the Goal Speed of inertia identification (cfg.GoalSpeed) for SpinTAC Velocity Identify...
Velocity Identify is in busy state, identifying system inertia.
long _iq24
_iq24 TimeOut_sec
Maximum time allowed for inertia estimation process { unit: [s], value range: [1.0, 10.0] }.
struct _ST_VELID_Handle_ * ST_VELID_Handle
static void STVELID_setTimeOut_sec(ST_VELID_Handle handle, _iq24 timeOut)
Sets the Time Out Time (cfg.TimeOut_sec) for SpinTAC Velocity Identify.
Public interface, object, and function definitions related to the SpinTAC Version object...
static void STVELID_setVelocityFeedback(ST_VELID_Handle handle, _iq24 velFdb)
Sets the Velocity Feedback (VelFdb) for SpinTAC Velocity Identify.
int16_t LpfTime_tick
Low pass filter ISR ticks { unit: [ticks], value range: [1, 100] }.
ST_VelIdCfg_t cfg
Configuration substructure.
_iq24 T_sec
Sample time { unit: [s], value range: (0.0, 0.01] }.
static bool STVELID_getEnable(ST_VELID_Handle handle)
Gets the Enable signal (ENB) for SpinTAC Velocity Identify.
_iq24 GoalSpeed
Speed to reach in inertia estimation { unit: [pu/s], value range: (0, 1.0] }.
bool Sensorless
Indicates if the FOC is using a sensorless estimator.
_iq24 OutMax
Control signal limit { unit: [PU], value range: (0, 1.0] }.
static void STVELID_setTorqueReference(ST_VELID_Handle handle, _iq24 out)
Sets the Torque (Iq) Reference (Out) for SpinTAC Velocity Identify.
static _iq24 STVELID_getFrictionEstimate(ST_VELID_Handle handle)
Gets the System Friction (FrictionEst) from SpinTAC Velocity Identify.
_iq24 VelFdb
Velocity feedback { unit: [pu/s], value range: [-1.0, 1.0] }.
Defines the ST_VelIdCfg_t data.
static void STVELID_setTorqueRampTime_sec(ST_VELID_Handle handle, _iq24 rampTime)
Sets the Torque Ramp Time (cfg.RampTime_sec) for SpinTAC Velocity Identify.
ST_VELID_Handle STVELID_init(void *pMemory, const size_t numBytes)
Initializes the SpinTAC Velocity Identify object.
_iq24 InertiaEst
Estimated Inertia { unit: [PU/(pu/s^2)], value range: positive _IQ24 value }.
static _iq24 STVELID_getTorqueReference(ST_VELID_Handle handle)
Gets the Torque (Iq) Reference value (Out) from SpinTAC Velocity Identify.
static void STVELID_setSampleTime_sec(ST_VELID_Handle handle, _iq24 sampleTime)
Sets the Sample Time (cfg.T_sec) for SpinTAC Velocity Identify.
uint16_t ERR_ID
Error ID { 0: no error; others: see error code }.