MotorWare f2806x Module API Documentation

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

spintac_vel_ctl.h
Go to the documentation of this file.
1 #ifndef __SPINTAC_VEL_CTL_H__
2 #define __SPINTAC_VEL_CTL_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
49 #ifndef __ST_AXIS_ENUM__
50 #define __ST_AXIS_ENUM__
51 typedef enum
54 {
55 ST_AXIS0=0,
56 ST_AXIS1
57 } ST_Axis_e;
58 #endif //__ST_AXIS_ENUM__
59
60 #ifndef __ST_CTL_STATUS_ENUM__
61 #define __ST_CTL_STATUS_ENUM__
62 typedef enum
65 {
66 ST_CTL_IDLE=0,
67 ST_CTL_INIT,
68 ST_CTL_CONF,
69 ST_CTL_BUSY
70 } ST_CtlStatus_e;
71 #endif //__ST_CTL_STATUS_ENUM__
72
76 typedef struct {
77 //System config parameters: Can be set only once at system startup
78 ST_Axis_e Axis;
79 _iq24 T_sec;
80 bool FiltEN;
81 // Config parameters that may be modified
82 _iq24 OutMax;
83 _iq24 OutMin;
84 } ST_VelCtlCfg_t; // Structure for SpinTAC Control-Velocity configuration
85
89 typedef struct {
90 /* Configuration variables */
91 ST_VelCtlCfg_t cfg;
92 /* Input variables */
93 _iq24 VelRef;
94 _iq24 AccRef;
95 _iq24 VelFdb;
96 _iq24 Inertia;
97 _iq24 Friction;
98 _iq20 Bw_radps;
99 // Control bits
100 bool ENB;
101 /* Output variables */
102 _iq24 Out;
103 // Information variables
104 ST_CtlStatus_e STATUS;
105 uint16_t ERR_ID;
106 /* Internal variables */
107 uint32_t s1[10];
108 } ST_VelCtl_t; // Structure for SpinTAC Velocity Control
109
110 typedef struct _ST_VELCTL_Handle_ *ST_VELCTL_Handle; // SpinTAC Velocity Controller Handle
111
115 static inline void STVELCTL_setAxis(ST_VELCTL_Handle handle, ST_Axis_e axis) {
116 ST_VelCtl_t *obj = (ST_VelCtl_t *)handle;
117
118 if(obj->STATUS == ST_CTL_IDLE) {
119 obj->cfg.Axis = axis;
120 }
121
122 return;
123 } // end of STVELCTL_setAxis function
124
128 static inline void STVELCTL_setSampleTime_sec(ST_VELCTL_Handle handle, _iq24 sampleTime) {
129 ST_VelCtl_t *obj = (ST_VelCtl_t *)handle;
130
131 if(obj->STATUS == ST_CTL_IDLE) {
132 obj->cfg.T_sec = sampleTime;
133 }
134
135 return;
136 } // end of STVELCTL_setSampleTime_sec function
137
141 static inline _iq24 STVELCTL_getOutputMaximum(ST_VELCTL_Handle handle) {
142 ST_VelCtl_t *obj = (ST_VelCtl_t *)handle;
143
144 return obj->cfg.OutMax;
145 } // end of STVELCTL_getOutputMaximum function
146
150 static inline _iq24 STVELCTL_getOutputMinimum(ST_VELCTL_Handle handle) {
151 ST_VelCtl_t *obj = (ST_VelCtl_t *)handle;
152
153 return obj->cfg.OutMin;
154 } // end of STVELCTL_getOutputMinimum function
155
160 static inline void STVELCTL_setOutputMaximums(ST_VELCTL_Handle handle, _iq24 outMax, _iq24 outMin) {
161 ST_VelCtl_t *obj = (ST_VelCtl_t *)handle;
162
163 obj->cfg.OutMax = outMax;
164 obj->cfg.OutMin = outMin;
165
166 return;
167 } // end of STVELCTL_setOutputMaximums function
168
172 static inline void STVELCTL_setFilterEnableFlag(ST_VELCTL_Handle handle, bool filterEnable) {
173 ST_VelCtl_t *obj = (ST_VelCtl_t *)handle;
174
175 if(obj->STATUS == ST_CTL_IDLE) {
176 obj->cfg.FiltEN = filterEnable;
177 }
178
179 return;
180 } // end of STVELCTL_setFilterEnableFlag function
181
185 static inline void STVELCTL_setVelocityReference(ST_VELCTL_Handle handle, _iq24 velRef) {
186 ST_VelCtl_t *obj = (ST_VelCtl_t *)handle;
187
188 obj->VelRef = velRef;
189
190 return;
191 } // end of STVELCTL_setVelocityReference function
192
196 static inline _iq24 STVELCTL_getVelocityReference(ST_VELCTL_Handle handle) {
197 ST_VelCtl_t *obj = (ST_VelCtl_t *)handle;
198
199 return(obj->VelRef);
200 } // end of STVELCTL_getVelocityReference function
201
205 static inline void STVELCTL_setAccelerationReference(ST_VELCTL_Handle handle, _iq24 accRef) {
206 ST_VelCtl_t *obj = (ST_VelCtl_t *)handle;
207
208 obj->AccRef = accRef;
209
210 return;
211 } // end of STVELCTL_setAccelerationReference function
212
216 static inline void STVELCTL_setVelocityFeedback(ST_VELCTL_Handle handle, _iq24 velFdb) {
217 ST_VelCtl_t *obj = (ST_VelCtl_t *)handle;
218
219 obj->VelFdb = velFdb;
220
221 return;
222 } // end of STVELCTL_setVelocityFeedback function
223
227 static inline _iq24 STVELCTL_getVelocityFeedback(ST_VELCTL_Handle handle) {
228 ST_VelCtl_t *obj = (ST_VelCtl_t *)handle;
229
230 return(obj->VelFdb);
231 } // end of STVELCTL_getVelocityFeedback function
232
236 static inline void STVELCTL_setInertia(ST_VELCTL_Handle handle, _iq24 inertia) {
237 ST_VelCtl_t *obj = (ST_VelCtl_t *)handle;
238
239 obj->Inertia = inertia;
240
241 return;
242 } // end of STVELCTL_setInertia function
243
247 static inline _iq24 STVELCTL_getInertia(ST_VELCTL_Handle handle) {
248 ST_VelCtl_t *obj = (ST_VelCtl_t *)handle;
249
250 return(obj->Inertia);
251 } // end of STVELCTL_getInertia function
252
256 static inline void STVELCTL_setFriction(ST_VELCTL_Handle handle, _iq24 friction) {
257 ST_VelCtl_t *obj = (ST_VelCtl_t *)handle;
258
259 obj->Friction = friction;
260
261 return;
262 } // end of STVELCTL_setFriction function
263
267 static inline _iq24 STVELCTL_getFriction(ST_VELCTL_Handle handle) {
268 ST_VelCtl_t *obj = (ST_VelCtl_t *)handle;
269
270 return(obj->Friction);
271 } // end of STVELCTL_getFriction function
272
276 static inline void STVELCTL_setBandwidth_radps(ST_VELCTL_Handle handle, _iq20 bw) {
277 ST_VelCtl_t *obj = (ST_VelCtl_t *)handle;
278
279 obj->Bw_radps = bw;
280
281 return;
282 } // end of STVELCTL_setBandwidth_radps function
283
287 static inline _iq20 STVELCTL_getBandwidth_radps(ST_VELCTL_Handle handle) {
288 ST_VelCtl_t *obj = (ST_VelCtl_t *)handle;
289
290 return(obj->Bw_radps);
291 } // end of STVELCTL_getBandwidth_radps function
292
296 static inline void STVELCTL_setEnable(ST_VELCTL_Handle handle, bool enb) {
297 ST_VelCtl_t *obj = (ST_VelCtl_t *)handle;
298
299 obj->ENB = enb;
300
301 return;
302 } // end of STVELCTL_setEnable function
303
307 static inline bool STVELCTL_getEnable(ST_VELCTL_Handle handle) {
308 ST_VelCtl_t *obj = (ST_VelCtl_t *)handle;
309
310 return (obj->ENB);
311
312 } // end of STVELCTL_getEnable function
313
317 static inline void STVELCTL_setTorqueReference(ST_VELCTL_Handle handle, _iq24 out) {
318 ST_VelCtl_t *obj = (ST_VelCtl_t *)handle;
319
320 obj->Out = out;
321
322 return;
323 } // end of STVELCTL_setTorqueReference function
324
328 static inline _iq24 STVELCTL_getTorqueReference(ST_VELCTL_Handle handle) {
329 ST_VelCtl_t *obj = (ST_VelCtl_t *)handle;
330
331 return (obj->Out);
332 } // end of STVELCTL_getTorqueReference function
333
337 static inline ST_CtlStatus_e STVELCTL_getStatus(ST_VELCTL_Handle handle) {
338 ST_VelCtl_t *obj = (ST_VelCtl_t *)handle;
339
340 return (obj->STATUS);
341
342 } // end of STVELCTL_getStatus function
343
347 static inline uint16_t STVELCTL_getErrorID(ST_VELCTL_Handle handle) {
348 ST_VelCtl_t *obj = (ST_VelCtl_t *)handle;
349
350 return (obj->ERR_ID);
351
352 } // end of STVELCTL_getErrorID function
353
358 ST_VELCTL_Handle STVELCTL_init(void *pMemory, const size_t numBytes);
359
362 void STVELCTL_run(ST_VELCTL_Handle handle); // SpinTAC Velocity Controller function
363
365 #endif //__SPINTAC_VEL_CTL_H__
STVELCTL_setOutputMaximums
static void STVELCTL_setOutputMaximums(ST_VELCTL_Handle handle, _iq24 outMax, _iq24 outMin)
Sets the Maximum Output (cfg.OutMax) and Minimum Output (cfg.OutMin) for SpinTAC Velocity Controller...
Definition: spintac_vel_ctl.h:160
ST_VelCtl_t::ENB
bool ENB
Enable bit { false: disable; true: enable }.
Definition: spintac_vel_ctl.h:100
ST_CTL_BUSY
ST_CTL in busy state.
Definition: spintac_vel_ctl.h:69
STVELCTL_getStatus
static ST_CtlStatus_e STVELCTL_getStatus(ST_VELCTL_Handle handle)
Gets the Status value (STATUS) for SpinTAC Velocity Controller.
Definition: spintac_vel_ctl.h:337
STVELCTL_getBandwidth_radps
static _iq20 STVELCTL_getBandwidth_radps(ST_VELCTL_Handle handle)
Gets the Bandwidth (Bw_radps) for SpinTAC Velocity Controller.
Definition: spintac_vel_ctl.h:287
ST_CtlStatus_e
ST_CtlStatus_e
Enumeration for the Control Status states.
Definition: spintac_pos_ctl.h:64
ST_VelCtlCfg_t::OutMax
_iq24 OutMax
Control signal upper limit { unit: [PU], value range: (-1.0, 1.0] }.
Definition: spintac_vel_ctl.h:82
STVELCTL_init
ST_VELCTL_Handle STVELCTL_init(void *pMemory, const size_t numBytes)
Initializes the SpinTAC Velocity Controller object.
STVELCTL_getOutputMinimum
static _iq24 STVELCTL_getOutputMinimum(ST_VELCTL_Handle handle)
Gets the Minimum Output (cfg.OutMin) for SpinTAC Velocity Controller.
Definition: spintac_vel_ctl.h:150
STVELCTL_setVelocityReference
static void STVELCTL_setVelocityReference(ST_VELCTL_Handle handle, _iq24 velRef)
Sets the Velocity Reference (VelRef) for SpinTAC Velocity Controller.
Definition: spintac_vel_ctl.h:185
ST_VelCtlCfg_t::Axis
ST_Axis_e Axis
Axis ID { ST_AXIS0: axis 0, ST_AXIS1: axis 1}.
Definition: spintac_vel_ctl.h:78
ST_CTL_CONF
ST_CTL in conf state.
Definition: spintac_vel_ctl.h:68
STVELCTL_getVelocityFeedback
static _iq24 STVELCTL_getVelocityFeedback(ST_VELCTL_Handle handle)
Gets the Velocity Feedback (VelFdb) for SpinTAC Velocity Controller.
Definition: spintac_vel_ctl.h:227
ST_VelCtlCfg_t::T_sec
_iq24 T_sec
Sample time { unit: [s], value range: (0.0, 0.01] }.
Definition: spintac_vel_ctl.h:79
ST_VelCtlCfg_t::FiltEN
bool FiltEN
Enable low-pass Filter { false: Filter Disabled; true: Filter Enabled }.
Definition: spintac_vel_ctl.h:80
ST_VelCtl_t
Defines the ST_VelCtl_t data.
Definition: spintac_vel_ctl.h:89
STVELCTL_setVelocityFeedback
static void STVELCTL_setVelocityFeedback(ST_VELCTL_Handle handle, _iq24 velFdb)
Sets the Velocity Feedback (VelFdb) for SpinTAC Velocity Controller.
Definition: spintac_vel_ctl.h:216
STVELCTL_getTorqueReference
static _iq24 STVELCTL_getTorqueReference(ST_VELCTL_Handle handle)
Gets the Torque (Iq) Reference (Out) for SpinTAC Velocity Controller.
Definition: spintac_vel_ctl.h:328
STVELCTL_setSampleTime_sec
static void STVELCTL_setSampleTime_sec(ST_VELCTL_Handle handle, _iq24 sampleTime)
Sets the Sample Time (cfg.T_sec) for SpinTAC Velocity Controller.
Definition: spintac_vel_ctl.h:128
ST_VelCtl_t::Out
_iq24 Out
Control output { unit: [PU], value range: [cfg.OutMin, cfg.OutMax] }.
Definition: spintac_vel_ctl.h:102
ST_VelCtl_t::Inertia
_iq24 Inertia
System inertia { unit: [PU/(pu/s^2)], value range: positive _IQ24 value }.
Definition: spintac_vel_ctl.h:96
ST_CTL_IDLE
ST_CTL in idle state.
Definition: spintac_vel_ctl.h:66
ST_CtlStatus_e
ST_CtlStatus_e
Enumeration for the Control Status states.
Definition: spintac_vel_ctl.h:64
STVELCTL_setFilterEnableFlag
static void STVELCTL_setFilterEnableFlag(ST_VELCTL_Handle handle, bool filterEnable)
Sets the Feedback Filter Enable Flag (cfg.FiltEN) for SpinTAC Velocity Controller.
Definition: spintac_vel_ctl.h:172
STVELCTL_getInertia
static _iq24 STVELCTL_getInertia(ST_VELCTL_Handle handle)
Gets the Inertia (Inertia) for SpinTAC Velocity Controller.
Definition: spintac_vel_ctl.h:247
STVELCTL_run
void STVELCTL_run(ST_VELCTL_Handle handle)
Runs the SpinTAC Velocity Control Function.
STVELCTL_getFriction
static _iq24 STVELCTL_getFriction(ST_VELCTL_Handle handle)
Gets the Friction (Friction) from SpinTAC Velocity Controller.
Definition: spintac_vel_ctl.h:267
STVELCTL_setTorqueReference
static void STVELCTL_setTorqueReference(ST_VELCTL_Handle handle, _iq24 out)
Sets the Torque (Iq) Reference (Out) for SpinTAC Velocity Controller.
Definition: spintac_vel_ctl.h:317
STVELCTL_getVelocityReference
static _iq24 STVELCTL_getVelocityReference(ST_VELCTL_Handle handle)
Gets the Velocity Reference (VelRef) for SpinTAC Velocity Controller.
Definition: spintac_vel_ctl.h:196
ST_AXIS1
Second Axis.
Definition: spintac_vel_ctl.h:56
STVELCTL_getOutputMaximum
static _iq24 STVELCTL_getOutputMaximum(ST_VELCTL_Handle handle)
Gets the Maximum Output (cfg.OutMax) for SpinTAC Velocity Controller.
Definition: spintac_vel_ctl.h:141
STVELCTL_getEnable
static bool STVELCTL_getEnable(ST_VELCTL_Handle handle)
Gets the Enable signal (ENB) for SpinTAC Velocity Controller.
Definition: spintac_vel_ctl.h:307
_iq24
long _iq24
Definition: 32b/IQmathLib.h:230
STVELCTL_setAccelerationReference
static void STVELCTL_setAccelerationReference(ST_VELCTL_Handle handle, _iq24 accRef)
Sets the Acceleration Reference (AccRef) for SpinTAC Velocity Controller.
Definition: spintac_vel_ctl.h:205
ST_VelCtl_t::VelRef
_iq24 VelRef
Reference input { unit: [pu/s], value range: [-1.0, 1.0] }.
Definition: spintac_vel_ctl.h:93
ST_VelCtlCfg_t
Defines the ST_VelCtlCfg_t data.
Definition: spintac_vel_ctl.h:76
ST_Axis_e
ST_Axis_e
Enumeration for the Axis Status states.
Definition: spintac_vel_ctl.h:53
ST_Axis_e
ST_Axis_e
Enumeration for the Axis Status states.
Definition: spintac_pos_ctl.h:53
ST_CTL_INIT
ST_CTL in init state.
Definition: spintac_vel_ctl.h:67
spintac_version.h
Public interface, object, and function definitions related to the SpinTAC Version object...
ST_VelCtl_t::ERR_ID
uint16_t ERR_ID
Error ID { 0: no error; others: see error code }.
Definition: spintac_vel_ctl.h:105
ST_VelCtl_t::cfg
ST_VelCtlCfg_t cfg
Definition: spintac_vel_ctl.h:91
STVELCTL_getErrorID
static uint16_t STVELCTL_getErrorID(ST_VELCTL_Handle handle)
Gets the Error value (ERR_ID) for SpinTAC Velocity Controller.
Definition: spintac_vel_ctl.h:347
ST_VelCtl_t::AccRef
_iq24 AccRef
Feedforward input { unit: [pu/s^2] }.
Definition: spintac_vel_ctl.h:94
ST_AXIS0
First Axis.
Definition: spintac_vel_ctl.h:55
ST_VelCtl_t::Bw_radps
_iq20 Bw_radps
Controller Bandwidth {unit: [rad/s], value range: [0.01, min(2000.0, 0.1/T_sec)] }.
Definition: spintac_vel_ctl.h:98
STVELCTL_setInertia
static void STVELCTL_setInertia(ST_VELCTL_Handle handle, _iq24 inertia)
Sets the Inertia (Inertia) for SpinTAC Velocity Controller.
Definition: spintac_vel_ctl.h:236
_iq20
long _iq20
Definition: 32b/IQmathLib.h:234
ST_VELCTL_Handle
struct _ST_VELCTL_Handle_ * ST_VELCTL_Handle
Definition: spintac_vel_ctl.h:110
STVELCTL_setFriction
static void STVELCTL_setFriction(ST_VELCTL_Handle handle, _iq24 friction)
Sets the Friction (Friction) for SpinTAC Velocity Controller.
Definition: spintac_vel_ctl.h:256
STVELCTL_setEnable
static void STVELCTL_setEnable(ST_VELCTL_Handle handle, bool enb)
Sets the Enable signal (ENB) for SpinTAC Velocity Controller.
Definition: spintac_vel_ctl.h:296
ST_VelCtlCfg_t::OutMin
_iq24 OutMin
Control signal lower limit { unit: [PU], value range: [-1.0, OutMax) }.
Definition: spintac_vel_ctl.h:83
STVELCTL_setAxis
static void STVELCTL_setAxis(ST_VELCTL_Handle handle, ST_Axis_e axis)
Sets the Axis (cfg.Axis) for SpinTAC Velocity Controller.
Definition: spintac_vel_ctl.h:115
ST_VelCtl_t::VelFdb
_iq24 VelFdb
Feedback input { unit: [pu/s], value range: [-1.0, 1.0] }.
Definition: spintac_vel_ctl.h:95
ST_VelCtl_t::STATUS
ST_CtlStatus_e STATUS
Status { ST_CTL_IDLE, ST_CTL_INIT, ST_CTL_CONF, ST_CTL_BUSY }.
Definition: spintac_vel_ctl.h:104
ST_VelCtl_t::Friction
_iq24 Friction
Friction Coefficient { unit: [PU/(pu/s)], value range: positive _IQ24 value }.
Definition: spintac_vel_ctl.h:97
STVELCTL_setBandwidth_radps
static void STVELCTL_setBandwidth_radps(ST_VELCTL_Handle handle, _iq20 bw)
Sets the Bandwidth (Bw_radps) for SpinTAC Velocity Controller.
Definition: spintac_vel_ctl.h:276