MotorWare f2806x Module API Documentation
spintac_vel_move.h
Go to the documentation of this file.
1 #ifndef __SPINTAC_VEL_MOVE_H__
2 #define __SPINTAC_VEL_MOVE_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 
54 typedef enum
55 {
58 } ST_Axis_e;
59 #endif //__ST_AXIS_ENUM__
60 
61 #ifndef __ST_MOVE_CURVE_TYPE_ENUM__
62 #define __ST_MOVE_CURVE_TYPE_ENUM__
63 
66 typedef enum
67 {
72 #endif //__ST_MOVE_CURVE_TYPE_ENUM__
73 
74 #ifndef __ST_MOVE_STATUS_ENUM__
75 #define __ST_MOVE_STATUS_ENUM__
76 
79 typedef enum
80 {
87 #endif //__ST_MOVE_STATUS_ENUM__
88 
92 typedef struct {
93  //System config parameters: Can be set only once at system startup
97  // Config parameters that may be modified
100 } ST_VelMoveCfg_t; // Structure for SpinTAC Move-Velocity configuration
101 
102 
106 typedef struct {
107  uint32_t ProTime_tick;
110 } ST_VelMoveMsg_t;
111 
115 typedef struct {
116  // Configuration structure
118  // Information structure
120  /* Input variables */
124  // Control bits
125  bool ENB;
126  bool TST;
127  /* Output variables */
131  // Information variables
133  uint16_t ERR_ID;
134  /* Internal variables */
135  uint32_t s1[23];
136 } ST_VelMove_t;
137 
138 typedef struct _ST_VELMOVE_Handle_ *ST_VELMOVE_Handle; // SpinTAC Velocity Move Handle
139 
143 static inline void STVELMOVE_setAxis(ST_VELMOVE_Handle handle, ST_Axis_e axis) {
144  ST_VelMove_t *obj = (ST_VelMove_t *)handle;
145 
146  if(obj->STATUS == ST_MOVE_IDLE) {
147  obj->cfg.Axis = axis;
148  }
149 
150  return;
151 } // end of STVELMOVE_setAxis function
152 
156 static inline void STVELMOVE_setCurveType(ST_VELMOVE_Handle handle, ST_MoveCurveType_e curveType) {
157  ST_VelMove_t *obj = (ST_VelMove_t *)handle;
158 
159  obj->cfg.CurveType = curveType;
160 
161  return;
162 } // end of STVELMOVE_setCurveType function
163 
168  ST_VelMove_t *obj = (ST_VelMove_t *)handle;
169 
170  return(obj->cfg.CurveType);
171 } // end of STVELMOVE_getCurveType function
172 
176 static inline void STVELMOVE_setSampleTime_sec(ST_VELMOVE_Handle handle, _iq24 sampleTime) {
177  ST_VelMove_t *obj = (ST_VelMove_t *)handle;
178 
179  if(obj->STATUS == ST_MOVE_IDLE) {
180  obj->cfg.T_sec = sampleTime;
181  }
182 
183  return;
184 } // end of STVELMOVE_setSampleTime_sec function
185 
189 static inline void STVELMOVE_setHaltLimits(ST_VELMOVE_Handle handle, _iq20 haltJrkLim) {
190  ST_VelMove_t *obj = (ST_VelMove_t *)handle;
191 
192  if(obj->STATUS == ST_MOVE_IDLE) {
193  obj->cfg.HaltJrkLim = haltJrkLim;
194  }
195 
196  return;
197 } // end of STVELMOVE_setHaltLimits function
198 
202 static inline void STVELMOVE_setVelocityStart(ST_VELMOVE_Handle handle, _iq24 velStart) {
203  ST_VelMove_t *obj = (ST_VelMove_t *)handle;
204 
205  if(obj->STATUS == ST_MOVE_IDLE) {
206  obj->cfg.VelStart = velStart;
207  }
208 
209  return;
210 } // end of STVELMOVE_setVelocityStart function
211 
216  ST_VelMove_t *obj = (ST_VelMove_t *)handle;
217 
218  return(obj->cfg.VelStart);
219 } // end of STVELMOVE_getVelocityStart function
220 
224 static inline uint32_t STVELMOVE_getProfileTime_tick(ST_VELMOVE_Handle handle) {
225  ST_VelMove_t *obj = (ST_VelMove_t *)handle;
226 
227  return(obj->msg.ProTime_tick);
228 } // end of STVELMOVE_getProfileTime_tick function
229 
234  ST_VelMove_t *obj = (ST_VelMove_t *)handle;
235 
236  return(obj->msg.ActualAccLim);
237 } // end of STVELMOVE_getActualAcceleration function
238 
243  ST_VelMove_t *obj = (ST_VelMove_t *)handle;
244 
245  return(obj->msg.ActualJrkLim);
246 } // end of STVELMOVE_getActualJerk function
247 
251 static inline void STVELMOVE_setVelocityEnd(ST_VELMOVE_Handle handle, _iq24 velEnd) {
252  ST_VelMove_t *obj = (ST_VelMove_t *)handle;
253 
254  obj->VelEnd = velEnd;
255 
256  return;
257 } // end of STVELMOVE_setVelocityEnd function
258 
263  ST_VelMove_t *obj = (ST_VelMove_t *)handle;
264 
265  return(obj->VelEnd);
266 } // end of STVELMOVE_getVelocityEnd function
267 
271 static inline void STVELMOVE_setAccelerationLimit(ST_VELMOVE_Handle handle, _iq24 accLim) {
272  ST_VelMove_t *obj = (ST_VelMove_t *)handle;
273 
274  obj->AccLim = accLim;
275 
276  return;
277 } // end of STVELMOVE_setAccelerationLimit function
278 
283  ST_VelMove_t *obj = (ST_VelMove_t *)handle;
284 
285  return(obj->AccLim);
286 } // end of STVELMOVE_getAccelerationLimit function
287 
291 static inline void STVELMOVE_setJerkLimit(ST_VELMOVE_Handle handle, _iq20 jrkLim) {
292  ST_VelMove_t *obj = (ST_VelMove_t *)handle;
293 
294  obj->JrkLim = jrkLim;
295 
296  return;
297 } // end of STVELMOVE_setJerkLimit function
298 
303  ST_VelMove_t *obj = (ST_VelMove_t *)handle;
304 
305  return(obj->JrkLim);
306 } // end of STVELMOVE_getJerkLimit function
307 
311 static inline void STVELMOVE_setEnable(ST_VELMOVE_Handle handle, bool enb) {
312  ST_VelMove_t *obj = (ST_VelMove_t *)handle;
313 
314  obj->ENB = enb;
315 
316  return;
317 } // end of STVELMOVE_setEnable function
318 
322 static inline bool STVELMOVE_getEnable(ST_VELMOVE_Handle handle) {
323  ST_VelMove_t *obj = (ST_VelMove_t *)handle;
324 
325  return (obj->ENB);
326 } // end of STVELMOVE_getEnable function
327 
331 static inline void STVELMOVE_setTest(ST_VELMOVE_Handle handle, bool tst) {
332  ST_VelMove_t *obj = (ST_VelMove_t *)handle;
333 
334  obj->TST = tst;
335 
336  return;
337 } // end of STVELMOVE_setTest function
338 
342 static inline bool STVELMOVE_getTest(ST_VELMOVE_Handle handle) {
343  ST_VelMove_t *obj = (ST_VelMove_t *)handle;
344 
345  return (obj->TST);
346 } // end of STVELMOVE_getTest function
347 
352  ST_VelMove_t *obj = (ST_VelMove_t *)handle;
353 
354  return(obj->VelRef);
355 } // end of STVELMOVE_getVelocityReference function
356 
360 static inline void STVELMOVE_setVelocityReference(ST_VELMOVE_Handle handle, _iq24 velRef) {
361  ST_VelMove_t *obj = (ST_VelMove_t *)handle;
362 
363  obj->VelRef = velRef;
364 
365  return;
366 } // end of STVELMOVE_setVelocityReference function
367 
372  ST_VelMove_t *obj = (ST_VelMove_t *)handle;
373 
374  return(obj->AccRef);
375 } // end of STVELMOVE_getAccelerationReference function
376 
381  ST_VelMove_t *obj = (ST_VelMove_t *)handle;
382 
383  return(obj->JrkRef);
384 } // end of STVELMOVE_getJerkReference function
385 
390  ST_VelMove_t *obj = (ST_VelMove_t *)handle;
391 
392  return (obj->STATUS);
393 } // end of STVELMOVE_getStatus function
394 
398 static inline uint16_t STVELMOVE_getErrorID(ST_VELMOVE_Handle handle) {
399  ST_VelMove_t *obj = (ST_VelMove_t *)handle;
400 
401  return (obj->ERR_ID);
402 } // end of STVELMOVE_getErrorID function
403 
408 ST_VELMOVE_Handle STVELMOVE_init(void *pMemory, const size_t numBytes);
409 
412 void STVELMOVE_run(ST_VELMOVE_Handle handle);
413 
415 #endif //__SPINTAC_VEL_MOVE_H__
_iq24 VelStart
Velocity start value { unit: [pu/s], value range: [-1.0, 1.0] }.
static uint16_t STVELMOVE_getErrorID(ST_VELMOVE_Handle handle)
Gets the Error value (ERR_ID) for SpinTAC Velocity Move.
ST_MoveCurveType_e CurveType
Curve Type { ST_MOVE_CUR_TRAP: Trap; ST_MOVE_CUR_SCRV: s-Curve; ST_MOVE_CUR_STCRV: st-Curve }...
static ST_MoveStatus_e STVELMOVE_getStatus(ST_VELMOVE_Handle handle)
Gets the Status value (STATUS) for SpinTAC Velocity Move.
ST_VELMOVE_Handle STVELMOVE_init(void *pMemory, const size_t numBytes)
Initializes the SpinTAC Velocity Move object.
static _iq20 STVELMOVE_getJerkLimit(ST_VELMOVE_Handle handle)
Gets the Jerk Limit (JrkLim) for SpinTAC Velocity Move.
Defines the ST_VelMoveCfg_t data.
Not used in ST_MOVE_VEL.
static _iq24 STVELMOVE_getActualAcceleration(ST_VELMOVE_Handle handle)
Gets the Actual Acceleration (msg.ActualAccLim) for current profile.
Move is in conf state, determining the curves.
static _iq24 STVELMOVE_getVelocityReference(ST_VELMOVE_Handle handle)
Gets the Velocity Reference (VelRef) for SpinTAC Velocity Move.
ST_MoveStatus_e STATUS
Profile generator status { ST_MOVE_IDLE, ST_MOVE_INIT, ST_MOVE_CONF, ST_MOVE_BUSY}.
static _iq24 STVELMOVE_getAccelerationReference(ST_VELMOVE_Handle handle)
Gets the Acceleration Reference (AccRef) for SpinTAC Velocity Move.
_iq24 AccRef
Acceleration reference { unit: [pu/s^2] }.
static void STVELMOVE_setCurveType(ST_VELMOVE_Handle handle, ST_MoveCurveType_e curveType)
Sets the Curve Type (cfg.CurveType) for SpinTAC Velocity Move.
static bool STVELMOVE_getTest(ST_VELMOVE_Handle handle)
Gets the Test signal (TST) for SpinTAC Velocity Move.
static void STVELMOVE_setVelocityEnd(ST_VELMOVE_Handle handle, _iq24 velEnd)
Sets the Velocity End (VelEnd) for SpinTAC Velocity Move.
static bool STVELMOVE_getEnable(ST_VELMOVE_Handle handle)
Gets the Enable signal (ENB) for SpinTAC Velocity Move.
Move is in idle state, holding velocity.
_iq20 JrkRef
Jerk reference { unit:; [pu /s^3] }.
Trapazoidal curve.
static void STVELMOVE_setVelocityReference(ST_VELMOVE_Handle handle, _iq24 velRef)
Sets the Velocity Reference (VelRef) for SpinTAC Velocity Move.
static void STVELMOVE_setAccelerationLimit(ST_VELMOVE_Handle handle, _iq24 accLim)
Sets the Acceleration Limit (AccLim) for SpinTAC Velocity Move.
static void STVELMOVE_setHaltLimits(ST_VELMOVE_Handle handle, _iq20 haltJrkLim)
Sets the Halt Limits (cfg.HaltJrkLim) for SpinTAC Velocity Move.
ST_MoveCurveType_e
Enumeration for the Move Curve modes.
_iq24 T_sec
Sample time { unit: [s], value range: (0.0, 0.01] }.
_iq24 VelRef
Velocity reference { unit: [pu/s] }.
ST_VelMoveMsg_t msg
_iq20 HaltJrkLim
Jerk Limit to use during Halt State { unit: [pu/s^3], value range: [0.0005, 2000.0] }...
uint32_t ProTime_tick
Amount of time profile will take { unit: [tick], value range: (0, uint32_t max] }.
uint16_t ERR_ID
Error ID { 0: no error; others: see error code }.
static _iq24 STVELMOVE_getAccelerationLimit(ST_VELMOVE_Handle handle)
Gets the Acceleration Limit (AccLim) for SpinTAC Velocity Move.
Second Axis.
Move is in busy state, providing the curves.
long _iq24
ST_Axis_e Axis
Axis ID { ST_AXIS0: axis 0, ST_AXIS1: axis 1}.
void STVELMOVE_run(ST_VELMOVE_Handle handle)
Runs the SpinTAC Velocity Move Function.
_iq24 VelEnd
Velocity end value { unit: [pu/s], value range: [-1.0, 1.0] }.
_iq24 AccLim
Acceleration Limit { unit: [pu/s^2], value range: [0.001, 120.0] }.
Move is in init state, validating configured parameters.
ST_Axis_e
Enumeration for the Axis Status states.
struct _ST_VELMOVE_Handle_ * ST_VELMOVE_Handle
Public interface, object, and function definitions related to the SpinTAC Version object...
Defines the ST_VelMoveMsg_t message data.
static void STVELMOVE_setJerkLimit(ST_VELMOVE_Handle handle, _iq20 jrkLim)
Sets the Jerk Limit (JrkLim) for SpinTAC Velocity Move.
static uint32_t STVELMOVE_getProfileTime_tick(ST_VELMOVE_Handle handle)
Gets the Profile Time (msg.ProTime_tick) for SpinTAC Velocity Move.
_iq24 ActualAccLim
Actual maximum acceleration of the profile { unit: [pu/s^2], value range: (0.0, AccLim] }...
First Axis.
Defines the ST_VelMove_t data.
ST_Axis_e
Enumeration for the Axis Status states.
static void STVELMOVE_setAxis(ST_VELMOVE_Handle handle, ST_Axis_e axis)
Sets the Axis (cfg.Axis) for SpinTAC Velocity Move.
bool ENB
Enable bit { false: disabled; true: enabled }.
static void STVELMOVE_setTest(ST_VELMOVE_Handle handle, bool tst)
Sets the Test signal (TST) for SpinTAC Velocity Move.
static ST_MoveCurveType_e STVELMOVE_getCurveType(ST_VELMOVE_Handle handle)
Gets the Curve Type (cfg.CurveType) for SpinTAC Velocity Move.
_iq20 ActualJrkLim
Actual maximum jerk of the profile { unit: [pu/s^3], value range: (0.0, JrkLim] }.
ST_MoveStatus_e
Enumeration for the Move Status states.
long _iq20
ST_VelMoveCfg_t cfg
ST_MoveCurveType_e
Enumeration for the Move Curve Mode states.
static void STVELMOVE_setVelocityStart(ST_VELMOVE_Handle handle, _iq24 velStart)
Sets the Velocity Start (cfg.VelStart) for SpinTAC Velocity Move.
static _iq24 STVELMOVE_getVelocityStart(ST_VELMOVE_Handle handle)
Gets the Velocity Start (cfg.VelStart) for SpinTAC Velocity Move.
static _iq20 STVELMOVE_getJerkReference(ST_VELMOVE_Handle handle)
Gets the Jerk Reference (JrkRef) for SpinTAC Velocity Move.
bool TST
Profile test bit { false: Not Testing; true: Testing Mode }.
static void STVELMOVE_setSampleTime_sec(ST_VELMOVE_Handle handle, _iq24 sampleTime)
Sets the Sample Time (cfg.T_sec) for SpinTAC Velocity Move.
static _iq20 STVELMOVE_getActualJerk(ST_VELMOVE_Handle handle)
Gets the Actual Jerk (msg.ActualJrkLim) for current pofile.
static void STVELMOVE_setEnable(ST_VELMOVE_Handle handle, bool enb)
Sets the Enable signal (ENB) for SpinTAC Velocity Move.
static _iq24 STVELMOVE_getVelocityEnd(ST_VELMOVE_Handle handle)
Gets the Velocity End (VelEnd) for SpinTAC Velocity Move.
_iq20 JrkLim
Jerk Limit { unit: [pu/s^3], value range: [0.0005, 2000.0] }.
ST_MoveStatus_e
Enumeration for the Move Status states.