MotorWare f2806x Module API Documentation

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

32b/traj.h
Go to the documentation of this file.
1 /* --COPYRIGHT--,BSD
2 * Copyright (c) 2012, Texas Instruments Incorporated
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 * --/COPYRIGHT--*/
32 #ifndef _TRAJ_H_
33 #define _TRAJ_H_
34
40
41
42 // **************************************************************************
43 // the includes
44
45 #include "sw/modules/types/src/types.h"
46 #include "sw/modules/iqmath/src/32b/IQmathLib.h"
47
52
53
54 // Include the algorithm overview defined in modules/<module>/docs/doxygen/doxygen.h
56
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60
61
62 // **************************************************************************
63 // the defines
64
67 typedef struct _TRAJ_Obj_
68 {
69 _iq targetValue;
70 _iq intValue;
71 _iq minValue;
72 _iq maxValue;
73 _iq maxDelta;
74 } TRAJ_Obj;
75
76
79 typedef struct _TRAJ_Obj_ *TRAJ_Handle;
80
81
82 // **************************************************************************
83 // the globals
84
85
86 // **************************************************************************
87 // the function prototypes
88
92 static inline _iq TRAJ_getIntValue(TRAJ_Handle handle)
93 {
94 TRAJ_Obj *obj = (TRAJ_Obj *)handle;
95
96 return(obj->intValue);
97 } // end of TRAJ_getIntValue() function
98
99
103 static inline _iq TRAJ_getMaxDelta(TRAJ_Handle handle)
104 {
105 TRAJ_Obj *obj = (TRAJ_Obj *)handle;
106
107 return(obj->maxDelta);
108 } // end of TRAJ_getMaxDelta() function
109
110
114 static inline _iq TRAJ_getMaxValue(TRAJ_Handle handle)
115 {
116 TRAJ_Obj *obj = (TRAJ_Obj *)handle;
117
118 return(obj->maxValue);
119 } // end of TRAJ_getMaxValue() function
120
121
125 static inline _iq TRAJ_getMinValue(TRAJ_Handle handle)
126 {
127 TRAJ_Obj *obj = (TRAJ_Obj *)handle;
128
129 return(obj->minValue);
130 } // end of TRAJ_getMinValue() function
131
132
136 static inline _iq TRAJ_getTargetValue(TRAJ_Handle handle)
137 {
138 TRAJ_Obj *obj = (TRAJ_Obj *)handle;
139
140 return(obj->targetValue);
141 } // end of TRAJ_getTargetValue() function
142
143
148 extern TRAJ_Handle TRAJ_init(void *pMemory,const size_t numBytes);
149
150
154 static inline void TRAJ_setIntValue(TRAJ_Handle handle,const _iq intValue)
155 {
156 TRAJ_Obj *obj = (TRAJ_Obj *)handle;
157
158 obj->intValue = intValue;
159
160 return;
161 } // end of TRAJ_setIntValue() function
162
163
167 static inline void TRAJ_setMaxDelta(TRAJ_Handle handle,const _iq maxDelta)
168 {
169 TRAJ_Obj *obj = (TRAJ_Obj *)handle;
170
171 obj->maxDelta = maxDelta;
172
173 return;
174 } // end of TRAJ_setMaxDelta() function
175
176
180 static inline void TRAJ_setMaxValue(TRAJ_Handle handle,const _iq maxValue)
181 {
182 TRAJ_Obj *obj = (TRAJ_Obj *)handle;
183
184 obj->maxValue = maxValue;
185
186 return;
187 } // end of TRAJ_setMaxValue() function
188
189
193 static inline void TRAJ_setMinValue(TRAJ_Handle handle,const _iq minValue)
194 {
195 TRAJ_Obj *obj = (TRAJ_Obj *)handle;
196
197 obj->minValue = minValue;
198
199 return;
200 } // end of TRAJ_setMinValue() function
201
202
206 static inline void TRAJ_setTargetValue(TRAJ_Handle handle,const _iq targetValue)
207 {
208 TRAJ_Obj *obj = (TRAJ_Obj *)handle;
209
210 obj->targetValue = targetValue;
211
212 return;
213 } // end of TRAJ_setTargetValue() function
214
215
218 static inline void TRAJ_run(TRAJ_Handle handle)
219 {
220 _iq targetValue = TRAJ_getTargetValue(handle);
221 _iq intValue = TRAJ_getIntValue(handle);
222 _iq error = targetValue - intValue;
223 _iq maxDelta = TRAJ_getMaxDelta(handle);
224 _iq minValue = TRAJ_getMinValue(handle);
225 _iq maxValue = TRAJ_getMaxValue(handle);
226
227 // increment the value
228 intValue += _IQsat(error,maxDelta,-maxDelta);
229
230 // bound the value
231 intValue = _IQsat(intValue,maxValue,minValue);
232
233 // store the value
234 TRAJ_setIntValue(handle,intValue);
235
236 return;
237 } // end of TRAJ_run() function
238
239
240 #ifdef __cplusplus
241 }
242 #endif // extern "C"
243
245 #endif // end of _TRAJ_H_ definition
246
247
248
249
250
TRAJ_setTargetValue
static void TRAJ_setTargetValue(TRAJ_Handle handle, const _iq targetValue)
Sets the target value for the trajectory.
Definition: 32b/traj.h:206
types.h
Contains the public interface to the types definitions.
TRAJ_setMaxDelta
static void TRAJ_setMaxDelta(TRAJ_Handle handle, const _iq maxDelta)
Sets the maximum delta value for the trajectory.
Definition: 32b/traj.h:167
_TRAJ_Obj_::maxDelta
_iq maxDelta
the maximum delta value for the trajectory generator
Definition: 32b/traj.h:73
TRAJ_getIntValue
static _iq TRAJ_getIntValue(TRAJ_Handle handle)
Gets the intermediate value for the trajectory.
Definition: 32b/traj.h:92
_TRAJ_Obj_::targetValue
_iq targetValue
the target value for the trajectory
Definition: 32b/traj.h:69
TRAJ_Obj
struct _TRAJ_Obj_ TRAJ_Obj
Defines the trajectory (TRAJ) object.
_iq
long _iq
Definition: 32b/IQmathLib.h:223
TRAJ_getMaxValue
static _iq TRAJ_getMaxValue(TRAJ_Handle handle)
Gets the maximum value for the trajectory.
Definition: 32b/traj.h:114
TRAJ_getTargetValue
static _iq TRAJ_getTargetValue(TRAJ_Handle handle)
Gets the target value for the trajectory.
Definition: 32b/traj.h:136
TRAJ_init
TRAJ_Handle TRAJ_init(void *pMemory, const size_t numBytes)
Initializes the trajectory (TRAJ) object.
Definition: 32b/traj.c:55
TRAJ_setIntValue
static void TRAJ_setIntValue(TRAJ_Handle handle, const _iq intValue)
Sets the intermediate value for the trajectory.
Definition: 32b/traj.h:154
_TRAJ_Obj_
Defines the trajectory (TRAJ) object.
Definition: 32b/traj.h:67
TRAJ_getMaxDelta
static _iq TRAJ_getMaxDelta(TRAJ_Handle handle)
Gets the maximum delta value for the trajectory.
Definition: 32b/traj.h:103
TRAJ_getMinValue
static _iq TRAJ_getMinValue(TRAJ_Handle handle)
Gets the minimum value for the trajectory.
Definition: 32b/traj.h:125
TRAJ_setMaxValue
static void TRAJ_setMaxValue(TRAJ_Handle handle, const _iq maxValue)
Sets the maximum value for the trajectory.
Definition: 32b/traj.h:180
TRAJ_Handle
struct _TRAJ_Obj_ * TRAJ_Handle
Defines the TRAJ handle.
Definition: 32b/traj.h:79
_IQsat
#define _IQsat(A, Pos, Neg)
Definition: 32b/IQmathLib.h:513
IQmathLib.h
_TRAJ_Obj_::maxValue
_iq maxValue
the maximum value for the trajectory generator
Definition: 32b/traj.h:72
_TRAJ_Obj_::minValue
_iq minValue
the minimum value for the trajectory generator
Definition: 32b/traj.h:71
TRAJ_run
static void TRAJ_run(TRAJ_Handle handle)
Runs the trajectory (TRAJ) object.
Definition: 32b/traj.h:218
_TRAJ_Obj_::intValue
_iq intValue
the intermediate value along the trajectory
Definition: 32b/traj.h:70
TRAJ_setMinValue
static void TRAJ_setMinValue(TRAJ_Handle handle, const _iq minValue)
Sets the minimum value for the trajectory.
Definition: 32b/traj.h:193