MotorWare f2806x Module API Documentation

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

float/traj.h
Go to the documentation of this file.
1 /* --COPYRIGHT--,BSD
2 * Copyright (c) 2014, 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/math/src/float/math.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 float_t targetValue;
70 float_t intValue;
71 float_t minValue;
72 float_t maxValue;
73 float_t 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 float_t 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 float_t 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 float_t 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 float_t 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 float_t 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 float_t 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 float_t 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 float_t 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 float_t 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 float_t 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 float_t targetValue = TRAJ_getTargetValue(handle);
221 float_t intValue = TRAJ_getIntValue(handle);
222 float_t error = targetValue - intValue;
223 float_t maxDelta = TRAJ_getMaxDelta(handle);
224 float_t minValue = TRAJ_getMinValue(handle);
225 float_t maxValue = TRAJ_getMaxValue(handle);
226
227 // increment the value
228 intValue += MATH_sat(error,maxDelta,-maxDelta);
229
230 // bound the value
231 intValue = MATH_sat(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
types.h
Contains the public interface to the types definitions.
_TRAJ_Obj_::maxDelta
_iq maxDelta
the maximum delta value for the trajectory generator
Definition: 32b/traj.h:73
TRAJ_setIntValue
static void TRAJ_setIntValue(TRAJ_Handle handle, const float_t intValue)
Sets the intermediate value for the trajectory.
Definition: float/traj.h:154
math.h
Contains the public interface to the math (MATH) module routines.
_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.
MATH_sat
static float_t MATH_sat(const float_t in, const float_t max, const float_t min)
Saturates the input value between the minimum and maximum values.
Definition: float/math.h:218
_TRAJ_Obj_::maxDelta
float_t maxDelta
the maximum delta value for the trajectory generator
Definition: float/traj.h:73
TRAJ_init
TRAJ_Handle TRAJ_init(void *pMemory, const size_t numBytes)
Initializes the trajectory (TRAJ) object.
Definition: 32b/traj.c:55
TRAJ_setTargetValue
static void TRAJ_setTargetValue(TRAJ_Handle handle, const float_t targetValue)
Sets the target value for the trajectory.
Definition: float/traj.h:206
TRAJ_run
static void TRAJ_run(TRAJ_Handle handle)
Runs the trajectory (TRAJ) object.
Definition: float/traj.h:218
TRAJ_setMaxDelta
static void TRAJ_setMaxDelta(TRAJ_Handle handle, const float_t maxDelta)
Sets the maximum delta value for the trajectory.
Definition: float/traj.h:167
TRAJ_getMinValue
static float_t TRAJ_getMinValue(TRAJ_Handle handle)
Gets the minimum value for the trajectory.
Definition: float/traj.h:125
TRAJ_getMaxValue
static float_t TRAJ_getMaxValue(TRAJ_Handle handle)
Gets the maximum value for the trajectory.
Definition: float/traj.h:114
_TRAJ_Obj_
Defines the trajectory (TRAJ) object.
Definition: 32b/traj.h:67
_TRAJ_Obj_::targetValue
float_t targetValue
the target value for the trajectory
Definition: float/traj.h:69
TRAJ_getTargetValue
static float_t TRAJ_getTargetValue(TRAJ_Handle handle)
Gets the target value for the trajectory.
Definition: float/traj.h:136
_TRAJ_Obj_::minValue
float_t minValue
the minimum value for the trajectory generator
Definition: float/traj.h:71
_TRAJ_Obj_::intValue
float_t intValue
the intermediate value along the trajectory
Definition: float/traj.h:70
TRAJ_getMaxDelta
static float_t TRAJ_getMaxDelta(TRAJ_Handle handle)
Gets the maximum delta value for the trajectory.
Definition: float/traj.h:103
_TRAJ_Obj_::maxValue
float_t maxValue
the maximum value for the trajectory generator
Definition: float/traj.h:72
TRAJ_Handle
struct _TRAJ_Obj_ * TRAJ_Handle
Defines the TRAJ handle.
Definition: float/traj.h:79
_TRAJ_Obj_::maxValue
_iq maxValue
the maximum value for the trajectory generator
Definition: 32b/traj.h:72
TRAJ_setMinValue
static void TRAJ_setMinValue(TRAJ_Handle handle, const float_t minValue)
Sets the minimum value for the trajectory.
Definition: float/traj.h:193
_TRAJ_Obj_::minValue
_iq minValue
the minimum value for the trajectory generator
Definition: 32b/traj.h:71
TRAJ_getIntValue
static float_t TRAJ_getIntValue(TRAJ_Handle handle)
Gets the intermediate value for the trajectory.
Definition: float/traj.h:92
TRAJ_setMaxValue
static void TRAJ_setMaxValue(TRAJ_Handle handle, const float_t maxValue)
Sets the maximum value for the trajectory.
Definition: float/traj.h:180
float_t
float float_t
Defines the portable data type for 32 bit, signed floating-point data.
Definition: types.h:121
_TRAJ_Obj_::intValue
_iq intValue
the intermediate value along the trajectory
Definition: 32b/traj.h:70