MotorWare f2806x Module API Documentation

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

spintac_pos_conv.h
Go to the documentation of this file.
1 #ifndef __SPINTAC_POS_CONV_H__
2 #define __SPINTAC_POS_CONV_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_POS_CONV_IDLE=0,
54 ST_POS_CONV_INIT,
55 ST_POS_CONV_BUSY
56 } ST_PosConvStatus_e;
57
61 typedef struct {
62 _iq24 T_sec;
63 _iq24 ROMax_erev;
64 _iq24 ROMin_erev;
65 _iq24 erev_TO_pu_ps;
66 _iq24 PolePairs;
67 _iq24 ROMax_mrev;
68 int16_t LpfTime_tick;
69 // These values are only required for ACIM motors
70 _iq24 SampleTimeOverTimeConst;
71 _iq24 OneOverFreqTimeConst;
72 } ST_PosConvCfg_t;
73
77 typedef struct {
78 /* Configuration variables */
79 ST_PosConvCfg_t cfg;
80 /* Input variables */
81 _iq24 Pos_erev;
82 _iq24 Id;
83 _iq24 Iq;
84 // Control bits
85 bool ENB;
86 /* Output variables */
87 _iq24 Vel;
88 _iq24 VelLpf;
89 _iq24 Pos_mrev;
90 int32_t PosROCounts;
91 _iq24 SlipVel;
92 // Information variables
93 ST_PosConvStatus_e STATUS;
94 uint16_t ERR_ID;
95 /* Internal Variables */
96 uint32_t s0[19];
97 } ST_PosConv_t; // Structure for SpinTAC Position Converter
98
99 typedef struct _ST_POSCONV_Handle_ *ST_POSCONV_Handle; // SpinTAC Position Converter Handle
100
104 static inline void STPOSCONV_setSampleTime_sec(ST_POSCONV_Handle handle, _iq24 sampleTime) {
105 ST_PosConv_t *obj = (ST_PosConv_t *)handle;
106
107 if(obj->STATUS == ST_POS_CONV_IDLE) {
108 obj->cfg.T_sec = sampleTime;
109 }
110
111 return;
112 } // end of STPOSCONV_setSampleTime_sec function
113
118 static inline void STPOSCONV_setERevMaximums_erev(ST_POSCONV_Handle handle, _iq24 eRevROMax, _iq24 eRevROMin) {
119 ST_PosConv_t *obj = (ST_PosConv_t *)handle;
120
121 if(obj->STATUS == ST_POS_CONV_IDLE) {
122 obj->cfg.ROMax_erev = eRevROMax;
123 obj->cfg.ROMin_erev = eRevROMin;
124 }
125
126 return;
127 } // end of STPOSCONV_setERevMaximums_erev function
128
134 static inline void STPOSCONV_setUnitConversion(ST_POSCONV_Handle handle, float_t baseFreq, float_t sampleTime, uint16_t polePairs) {
135 ST_PosConv_t *obj = (ST_PosConv_t *)handle;
136
137 if(obj->STATUS == ST_POS_CONV_IDLE) {
138 obj->cfg.erev_TO_pu_ps = _IQ24(1.0 / (baseFreq * sampleTime));
139 obj->cfg.PolePairs = _IQ24(polePairs);
140 }
141
142 return;
143 } // end of STPOSCONV_setUnitConversion function
144
148 static inline void STPOSCONV_setMRevMaximum_mrev(ST_POSCONV_Handle handle, _iq24 mRevROMax) {
149 ST_PosConv_t *obj = (ST_PosConv_t *)handle;
150
151 if(obj->STATUS == ST_POS_CONV_IDLE) {
152 obj->cfg.ROMax_mrev = mRevROMax;
153 }
154
155 return;
156 } // end of STPOSCONV_setMRevMaximum_mrev function
157
161 static inline void STPOSCONV_setLowPassFilterTime_tick(ST_POSCONV_Handle handle, int16_t lpfTime) {
162 ST_PosConv_t *obj = (ST_PosConv_t *)handle;
163
164 if(obj->STATUS == ST_POS_CONV_IDLE) {
165 obj->cfg.LpfTime_tick = lpfTime;
166 }
167
168 return;
169 } // end of STPOSCONV_setLowPassFilterTime_tick function
170
177 static inline void STPOSCONV_setupSlipCompensator(ST_POSCONV_Handle handle, float_t sampleTime, float_t baseFreq, float_t rotorResistance, float_t statorInductance) {
178 ST_PosConv_t *obj = (ST_PosConv_t *)handle;
179
180 if(obj->STATUS == ST_POS_CONV_IDLE) {
181 obj->cfg.SampleTimeOverTimeConst = _IQ24(sampleTime * (rotorResistance/statorInductance));
182 obj->cfg.OneOverFreqTimeConst = _IQ24((1.0 / baseFreq) * (rotorResistance/statorInductance));
183 }
184
185 return;
186 } // end of STPOSCONV_setupSlipCompensator function
187
191 static inline void STPOSCONV_setElecAngle_erev(ST_POSCONV_Handle handle, _iq24 posERev) {
192 ST_PosConv_t *obj = (ST_PosConv_t *)handle;
193
194 obj->Pos_erev = posERev;
195
196 return;
197 } // end of STPOSCONV_setElecAngle_erev function
198
202 static inline void STPOSCONV_setCurrentVector(ST_POSCONV_Handle handle, MATH_vec2 *pIdqIn) {
203 ST_PosConv_t *obj = (ST_PosConv_t *)handle;
204
205 obj->Id = pIdqIn->value[0];
206 obj->Iq = pIdqIn->value[1];
207
208 return;
209 } // end of STPOSCONV_setCurrentVector function
210
214 static inline _iq24 STPOSCONV_getVelocity(ST_POSCONV_Handle handle) {
215 ST_PosConv_t *obj = (ST_PosConv_t *)handle;
216
217 return(obj->Vel);
218 } // end of STPOSCONV_getVelocity function
219
223 static inline _iq24 STPOSCONV_getVelocityFiltered(ST_POSCONV_Handle handle) {
224 ST_PosConv_t *obj = (ST_PosConv_t *)handle;
225
226 return(obj->VelLpf);
227 } // end of STPOSCONV_getVelocityFiltered function
228
232 static inline _iq24 STPOSCONV_getPosition_mrev(ST_POSCONV_Handle handle) {
233 ST_PosConv_t *obj = (ST_PosConv_t *)handle;
234
235 return(obj->Pos_mrev);
236 } // end of STPOSCONV_getPosition_mrev function
237
241 static inline int32_t STPOSCONV_getPositionRollOver(ST_POSCONV_Handle handle) {
242 ST_PosConv_t *obj = (ST_PosConv_t *)handle;
243
244 return(obj->PosROCounts);
245 } // end of STPOSCONV_getPositionRollOver function
246
250 static inline _iq24 STPOSCONV_getSlipVelocity(ST_POSCONV_Handle handle) {
251 ST_PosConv_t *obj = (ST_PosConv_t *)handle;
252
253 return(obj->SlipVel);
254 } // end of STPOSCONV_getSlipVelocity function
255
259 static inline void STPOSCONV_setEnable(ST_POSCONV_Handle handle, bool enb) {
260 ST_PosConv_t *obj = (ST_PosConv_t *)handle;
261
262 obj->ENB = enb;
263
264 return;
265 } // end of STPOSCONV_setEnable function
266
270 static inline bool STPOSCONV_getEnable(ST_POSCONV_Handle handle) {
271 ST_PosConv_t *obj = (ST_PosConv_t *)handle;
272
273 return (obj->ENB);
274 } // end of STPOSCONV_getEnable function
275
279 static inline ST_PosConvStatus_e STPOSCONV_getStatus(ST_POSCONV_Handle handle) {
280 ST_PosConv_t *obj = (ST_PosConv_t *)handle;
281
282 return (obj->STATUS);
283 } // end of STPOSCONV_getStatus function
284
288 static inline uint16_t STPOSCONV_getErrorID(ST_POSCONV_Handle handle) {
289 ST_PosConv_t *obj = (ST_PosConv_t *)handle;
290
291 return (obj->ERR_ID);
292 } // end of STPOSCONV_getErrorID function
293
298 ST_POSCONV_Handle STPOSCONV_init(void *pMemory, const size_t numBytes);
299
302 void STPOSCONV_run(ST_POSCONV_Handle handle); // SpinTAC Position Converter function
304 #endif //__SPINTAC_POS_CONV_H__
ST_PosConv_t::Pos_mrev
_iq24 Pos_mrev
Position { unit: [MRev] }.
Definition: spintac_pos_conv.h:89
ST_PosConvCfg_t::PolePairs
_iq24 PolePairs
Conversion ratio from mechanical revolution to electrical revolution { Pole Pairs }...
Definition: spintac_pos_conv.h:66
STPOSCONV_setSampleTime_sec
static void STPOSCONV_setSampleTime_sec(ST_POSCONV_Handle handle, _iq24 sampleTime)
Sets the Sample Time (cfg.T) for SpinTAC Position Converter.
Definition: spintac_pos_conv.h:104
STPOSCONV_setupSlipCompensator
static void STPOSCONV_setupSlipCompensator(ST_POSCONV_Handle handle, float_t sampleTime, float_t baseFreq, float_t rotorResistance, float_t statorInductance)
Sets up the Slip Compensator (only for ACIM) for SpinTAC Position Converter.
Definition: spintac_pos_conv.h:177
STPOSCONV_init
ST_POSCONV_Handle STPOSCONV_init(void *pMemory, const size_t numBytes)
Initializes the SpinTAC Position Converter object.
ST_PosConvStatus_e
ST_PosConvStatus_e
Enumeration for the Position Convert Status states.
Definition: spintac_pos_conv.h:51
STPOSCONV_setLowPassFilterTime_tick
static void STPOSCONV_setLowPassFilterTime_tick(ST_POSCONV_Handle handle, int16_t lpfTime)
Sets the Lowpass Time (cfg.LpfTime_tick) for SpinTAC Position Converter.
Definition: spintac_pos_conv.h:161
ST_PosConvCfg_t::erev_TO_pu_ps
_iq24 erev_TO_pu_ps
Conversion ratio from electrical revolution to user unit.
Definition: spintac_pos_conv.h:65
STPOSCONV_getPosition_mrev
static _iq24 STPOSCONV_getPosition_mrev(ST_POSCONV_Handle handle)
Gets the Position (Pos_mrev) for SpinTAC Position Converter.
Definition: spintac_pos_conv.h:232
_MATH_vec2_
Defines a two element vector.
Definition: 32b/math.h:248
ST_PosConvCfg_t::SampleTimeOverTimeConst
_iq24 SampleTimeOverTimeConst
Scalar value used in the Slip Compensator (only needed for ACIM) { value range: positive _IQ24 value ...
Definition: spintac_pos_conv.h:70
ST_PosConv_t::SlipVel
_iq24 SlipVel
Speed of the magnetic slip (only for ACIM) { unit: [ERev/s] }.
Definition: spintac_pos_conv.h:91
ST_PosConvCfg_t::LpfTime_tick
int16_t LpfTime_tick
Low pass filter ISR ticks { unit: [ticks], value range: [1, 100] }.
Definition: spintac_pos_conv.h:68
ST_PosConv_t::VelLpf
_iq24 VelLpf
Speed filtered { unit: [pu/s] }.
Definition: spintac_pos_conv.h:88
STPOSCONV_setUnitConversion
static void STPOSCONV_setUnitConversion(ST_POSCONV_Handle handle, float_t baseFreq, float_t sampleTime, uint16_t polePairs)
Sets the Unit Conversions for SpinTAC Position Converter.
Definition: spintac_pos_conv.h:134
ST_POS_CONV_BUSY
Position Converter is in busy state, converting position and velocity signals.
Definition: spintac_pos_conv.h:55
ST_PosConv_t::ENB
bool ENB
Enable bit { false: disable; true: enable }.
Definition: spintac_pos_conv.h:85
STPOSCONV_getStatus
static ST_PosConvStatus_e STPOSCONV_getStatus(ST_POSCONV_Handle handle)
Gets the Status value (STATUS) for SpinTAC Position Converter.
Definition: spintac_pos_conv.h:279
STPOSCONV_run
void STPOSCONV_run(ST_POSCONV_Handle handle)
Performs Position Roll Over Addition.
STPOSCONV_getEnable
static bool STPOSCONV_getEnable(ST_POSCONV_Handle handle)
Gets the Enable signal (ENB) for SpinTAC Position Converter.
Definition: spintac_pos_conv.h:270
_IQ24
#define _IQ24(A)
Definition: 32b/IQmathLib.h:275
STPOSCONV_setEnable
static void STPOSCONV_setEnable(ST_POSCONV_Handle handle, bool enb)
Sets the Enable signal (ENB) for SpinTAC Position Converter.
Definition: spintac_pos_conv.h:259
ST_PosConv_t::STATUS
ST_PosConvStatus_e STATUS
Status { ST_POS_CONV_IDLE, ST_POS_CONV_INIT,ST_POS_CONV_BUSY }.
Definition: spintac_pos_conv.h:93
ST_POS_CONV_IDLE
Position Converter is in idle state, zero output.
Definition: spintac_pos_conv.h:53
STPOSCONV_getVelocityFiltered
static _iq24 STPOSCONV_getVelocityFiltered(ST_POSCONV_Handle handle)
Gets the Velocity Filtered (VelLpf) for SpinTAC Position Converter.
Definition: spintac_pos_conv.h:223
STPOSCONV_setCurrentVector
static void STPOSCONV_setCurrentVector(ST_POSCONV_Handle handle, MATH_vec2 *pIdqIn)
Sets the Current Vector (IdqIn) (only needed for ACIM) for SpinTAC Position Converter.
Definition: spintac_pos_conv.h:202
STPOSCONV_getVelocity
static _iq24 STPOSCONV_getVelocity(ST_POSCONV_Handle handle)
Gets the Velocity (Vel) for SpinTAC Position Converter.
Definition: spintac_pos_conv.h:214
_MATH_vec2_::value
_iq value[2]
Definition: 32b/math.h:251
ST_PosConv_t::Pos_erev
_iq24 Pos_erev
Electrical angle { unit: [ERev] }.
Definition: spintac_pos_conv.h:81
ST_PosConvCfg_t::OneOverFreqTimeConst
_iq24 OneOverFreqTimeConst
Scalar value used in the Slip Compensator (only needed for ACIM) { value range: positive _IQ24 value ...
Definition: spintac_pos_conv.h:71
_iq24
long _iq24
Definition: 32b/IQmathLib.h:230
ST_PosConv_t
Defines the ST_PosConv_t data.
Definition: spintac_pos_conv.h:77
ST_PosConvCfg_t::ROMax_erev
_iq24 ROMax_erev
Maximum bound for electrical revolution { unit: [ERev] }.
Definition: spintac_pos_conv.h:63
ST_PosConvCfg_t::ROMin_erev
_iq24 ROMin_erev
Minimum bound for electrical revolution { unit: [ERev] }.
Definition: spintac_pos_conv.h:64
ST_PosConv_t::Id
_iq24 Id
the Id current (only needed for ACIM) { unit: [PU] }
Definition: spintac_pos_conv.h:82
STPOSCONV_getPositionRollOver
static int32_t STPOSCONV_getPositionRollOver(ST_POSCONV_Handle handle)
Gets the Position RollOver Counts (PosROCounts) for SpinTAC Position Converter.
Definition: spintac_pos_conv.h:241
spintac_version.h
Public interface, object, and function definitions related to the SpinTAC Version object...
ST_PosConv_t::cfg
ST_PosConvCfg_t cfg
Definition: spintac_pos_conv.h:79
ST_PosConv_t::ERR_ID
uint16_t ERR_ID
Error ID { 0: no error; others: see error code }.
Definition: spintac_pos_conv.h:94
ST_PosConv_t::PosROCounts
int32_t PosROCounts
Position rollover counts.
Definition: spintac_pos_conv.h:90
ST_PosConv_t::Vel
_iq24 Vel
Speed unfiltered { unit: [pu/s] }.
Definition: spintac_pos_conv.h:87
ST_POS_CONV_INIT
Position Converter is in init state, validating configured parameters.
Definition: spintac_pos_conv.h:54
STPOSCONV_getErrorID
static uint16_t STPOSCONV_getErrorID(ST_POSCONV_Handle handle)
Gets the Error value (ERR_ID) for SpinTAC Position Converter.
Definition: spintac_pos_conv.h:288
ST_PosConvCfg_t::ROMax_mrev
_iq24 ROMax_mrev
Position Rollover bound { unit: [MRev] }.
Definition: spintac_pos_conv.h:67
ST_PosConvCfg_t
Defines the ST_PosConvCfg_t data.
Definition: spintac_pos_conv.h:61
ST_PosConvCfg_t::T_sec
_iq24 T_sec
Sample Time { unit: [s], value range: (0, 0.01] }.
Definition: spintac_pos_conv.h:62
STPOSCONV_setERevMaximums_erev
static void STPOSCONV_setERevMaximums_erev(ST_POSCONV_Handle handle, _iq24 eRevROMax, _iq24 eRevROMin)
Sets the Electrical Revolution Maximum (cfg.ERevROMax) & Minimum (cfg.ERevROMin) for SpinTAC Position...
Definition: spintac_pos_conv.h:118
STPOSCONV_setElecAngle_erev
static void STPOSCONV_setElecAngle_erev(ST_POSCONV_Handle handle, _iq24 posERev)
Sets the Electrical Angle (Pos_erev) for SpinTAC Position Converter.
Definition: spintac_pos_conv.h:191
STPOSCONV_getSlipVelocity
static _iq24 STPOSCONV_getSlipVelocity(ST_POSCONV_Handle handle)
Gets the Slip Velocity (SlipVel) (only for ACIM) for SpinTAC Position Converter.
Definition: spintac_pos_conv.h:250
ST_POSCONV_Handle
struct _ST_POSCONV_Handle_ * ST_POSCONV_Handle
Definition: spintac_pos_conv.h:99
float_t
float float_t
Defines the portable data type for 32 bit, signed floating-point data.
Definition: types.h:121
STPOSCONV_setMRevMaximum_mrev
static void STPOSCONV_setMRevMaximum_mrev(ST_POSCONV_Handle handle, _iq24 mRevROMax)
Sets the Mechanical Revolution Maximum (cfg.ROMax_mrev) for SpinTAC Position Converter.
Definition: spintac_pos_conv.h:148
ST_PosConv_t::Iq
_iq24 Iq
the Iq current (only needed for ACIM) { unit: [PU] }
Definition: spintac_pos_conv.h:83