graph.h
Go to the documentation of this file.
1 //#############################################################################
2 // $TI Release: MotorControl SDK v3.01.00.00 $
3 // $Release Date: Mon Jan 11 11:23:03 CST 2021 $
4 // $Copyright:
5 // Copyright (C) 2017-2019 Texas Instruments Incorporated - http://www.ti.com/
6 //
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions
9 // are met:
10 //
11 // Redistributions of source code must retain the above copyright
12 // notice, this list of conditions and the following disclaimer.
13 //
14 // Redistributions in binary form must reproduce the above copyright
15 // notice, this list of conditions and the following disclaimer in the
16 // documentation and/or other materials provided with the
17 // distribution.
18 //
19 // Neither the name of Texas Instruments Incorporated nor the names of
20 // its contributors may be used to endorse or promote products derived
21 // from this software without specific prior written permission.
22 //
23 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 // $
35 //#############################################################################
36 
37 #ifndef GRAPH_H
38 #define GRAPH_H
39 
44 
45 // **************************************************************************
46 // the includes
48 
49 // modules
50 
51 // drivers
52 
53 // platforms
54 
55 // **************************************************************************
56 // the defines
57 #define GRAPH_BUFFER_NR 2 // Number of data arrays
58 
59 #define GRAPH_BUFFER_SIZE 256 // Size of data arrays
60 
61 #if (16 < GRAPH_BUFFER_SIZE && GRAPH_BUFFER_SIZE <= 32)
62 #define GRAPH_BUFFER_MASK (32-1)
63 #elif(32 < GRAPH_BUFFER_SIZE && GRAPH_BUFFER_SIZE <= 64)
64 #define GRAPH_BUFFER_MASK (64-1)
65 #elif(64 < GRAPH_BUFFER_SIZE && GRAPH_BUFFER_SIZE <= 128)
66 #define GRAPH_BUFFER_MASK (128-1)
67 #elif(128 < GRAPH_BUFFER_SIZE && GRAPH_BUFFER_SIZE <= 256)
68 #define GRAPH_BUFFER_MASK (256-1)
69 #elif(256 < GRAPH_BUFFER_SIZE && GRAPH_BUFFER_SIZE <= 512)
70 #define GRAPH_BUFFER_MASK (512-1)
71 #elif(512 < GRAPH_BUFFER_SIZE && GRAPH_BUFFER_SIZE <= 1024)
72 #define GRAPH_BUFFER_MASK (1024-1)
73 #elif(1024 < GRAPH_BUFFER_SIZE && GRAPH_BUFFER_SIZE <= 2048)
74 #define GRAPH_BUFFER_MASK (2048-1)
75 #elif(2048 < GRAPH_BUFFER_SIZE && GRAPH_BUFFER_SIZE <= 4096)
76 #define GRAPH_BUFFER_MASK (4096-1)
77 #elif(4096 < GRAPH_BUFFER_SIZE && GRAPH_BUFFER_SIZE <= 8192)
78 #define GRAPH_BUFFER_MASK (8192-1)
79 #else
80 #error GRAPH_BUFFER_SIZE is outside GRAPH_BUFFER_MASK definition in graph.h
81 #endif
82 
85 #define GRAPH_VARS_INIT { \
86  0, \
87  0, \
88  10, \
89  GRAPH_STEP_RP_CURRENT, \
90  0, \
91  }
92 
93 #define GRAPH_STEP_VARS_INIT { \
94  0, \
95  \
96  NULL, \
97  NULL, \
98  NULL, \
99  \
100  NULL, \
101  NULL, \
102  NULL, \
103  \
104  20, \
105  20, \
106  \
107  0.0, \
108  -1.0, \
109  }
110 
111 // **************************************************************************
112 // the typedefs
113 
116 typedef enum
117 {
123 
124 typedef enum
125 {
133 
134 typedef struct _GRAPH_Buffer_t_
135 {
137  uint16_t read; // points to field with oldest content
138  uint16_t write; // points to empty field
140 
141 typedef struct _GRAPH_Vars_t_
142 {
143  uint16_t bufferCounter; // used as an index into the buffer
144  uint16_t bufferTickCounter; // used to count the interrupts
145  uint16_t bufferTick; // defines how many interrupts per graph write
146 
147  GRAPH_StepResponseMode_e bufferMode; // used to define different values to
148  // record for each mode during run time
149 
151 }GRAPH_Vars_t;
152 
153 typedef struct _GRAPH_StepVars_t_
154 {
155  uint16_t stepResponse; // value to start the step response generation
156 
157  volatile float32_t *pSpeed_in; // Pointer to Real value of Speed
158  float32_t *pId_in; // Pointer to Real value of Id
159  float32_t *pIq_in; // Pointer to Real value of Iq
160 
161  volatile float32_t *pSpeed_ref; // Pointer to Setting value of spdRef
162  float32_t *pId_ref; // Pointer to Setting value of IdRef
163  float32_t *pIq_ref; // Pointer to Setting value of IqRef
164 
165  float32_t spdRef_Default; // Default starting value of spdRef
166  float32_t spdRef_StepSize; // Step size of spdRef
167 
168  float32_t IdRef_Default; // Default starting value of IdRef
169  float32_t IdRef_StepSize; // Step size of IdRef
171 
172 
173 // **************************************************************************
174 // the function prototypes
175 
179 bool GRAPH_BufferOut(GRAPH_Buffer_t *pBuffer, float32_t *pWord);
180 
184 bool GRAPH_BufferIn(GRAPH_Buffer_t *pBuffer, float32_t data);
185 
188 void GRAPH_BufferInit(GRAPH_Vars_t *pGraphVars);
189 
199  volatile float32_t *pSpeed_in, float32_t *pId_in, float32_t *pIq_in,
200  volatile float32_t *pSpeed_ref, float32_t *pId_ref, float32_t *pIq_ref);
201 
207 void GRAPH_Data_Gather (GRAPH_Vars_t *pGraphVars, GRAPH_BufferNR_e bufferNum,
208  float32_t gData);
209 
214 void GRAPH_DATA(GRAPH_Vars_t *pGraphVars, GRAPH_StepVars_t *pStepVars);
215 
221  GRAPH_StepVars_t *pStepVars);
222 
224 #endif // end of GRAPH_H definition
225 
GRAPH_BufferNR_e
GRAPH_BufferNR_e
Enumeration for the number of buffers.
Definition: graph.h:116
GRAPH_STEP_RP_SPEED
speed step response
Definition: graph.h:127
GRAPH_STEP_RP_CURRENT
current step response
Definition: graph.h:126
_GRAPH_StepVars_t_::spdRef_StepSize
float32_t spdRef_StepSize
Definition: graph.h:166
GRAPH_BUFFER_SIZE
#define GRAPH_BUFFER_SIZE
Definition: graph.h:59
float32_t
float float32_t
Definition: sfra_f32.h:42
_GRAPH_StepVars_t_::pSpeed_in
volatile float32_t * pSpeed_in
Definition: graph.h:157
_GRAPH_StepVars_t_::pIq_ref
float32_t * pIq_ref
Definition: graph.h:163
_GRAPH_Vars_t_::bufferData
GRAPH_Buffer_t bufferData[2]
Definition: graph.h:150
_GRAPH_Vars_t_::bufferCounter
uint16_t bufferCounter
Definition: graph.h:143
GRAPH_PH_A_VIEW
Definition: graph.h:129
GRAPH_Data_Gather
void GRAPH_Data_Gather(GRAPH_Vars_t *pGraphVars, GRAPH_BufferNR_e bufferNum, float32_t gData)
Data gathering function for any iq value.
GRAPH_generateStepResponse
void GRAPH_generateStepResponse(GRAPH_Vars_t *pGraphVars, GRAPH_StepVars_t *pStepVars)
Sets the values to collect in a data array.
GRAPH_StepResponseMode_e
GRAPH_StepResponseMode_e
Definition: graph.h:124
_GRAPH_Vars_t_::bufferTick
uint16_t bufferTick
Definition: graph.h:145
_GRAPH_StepVars_t_
Definition: graph.h:153
_GRAPH_StepVars_t_::pSpeed_ref
volatile float32_t * pSpeed_ref
Definition: graph.h:161
_GRAPH_Buffer_t_::data
float32_t data[256]
Definition: graph.h:136
math.h
GRAPH_PH_C_VIEW
Definition: graph.h:131
GRAPH_StepVars_t
struct _GRAPH_StepVars_t_ GRAPH_StepVars_t
GRAPH_DATA
void GRAPH_DATA(GRAPH_Vars_t *pGraphVars, GRAPH_StepVars_t *pStepVars)
Sets the values to collect in a data array.
_GRAPH_StepVars_t_::pIq_in
float32_t * pIq_in
Definition: graph.h:159
GRAPH_DataPointerInit
void GRAPH_DataPointerInit(GRAPH_StepVars_t *pStepVars, volatile float32_t *pSpeed_in, float32_t *pId_in, float32_t *pIq_in, volatile float32_t *pSpeed_ref, float32_t *pId_ref, float32_t *pIq_ref)
Data gathering function for any iq value.
GRAPH_Vars_t
struct _GRAPH_Vars_t_ GRAPH_Vars_t
_GRAPH_StepVars_t_::IdRef_Default
float32_t IdRef_Default
Definition: graph.h:168
GRAPH_BufferInit
void GRAPH_BufferInit(GRAPH_Vars_t *pGraphVars)
Init function and reset function.
_GRAPH_StepVars_t_::IdRef_StepSize
float32_t IdRef_StepSize
Definition: graph.h:169
_GRAPH_Vars_t_::bufferMode
GRAPH_StepResponseMode_e bufferMode
Definition: graph.h:147
GRAPH_STEP_RP_VIEW
No Used.
Definition: graph.h:128
GRAPH_BufferIn
bool GRAPH_BufferIn(GRAPH_Buffer_t *pBuffer, float32_t data)
Write into the buffer.
_GRAPH_StepVars_t_::stepResponse
uint16_t stepResponse
Definition: graph.h:155
GRAPH_BUFFER_NR1
Buffer define 1.
Definition: graph.h:119
_GRAPH_Buffer_t_::read
uint16_t read
Definition: graph.h:137
_GRAPH_Buffer_t_
Definition: graph.h:134
_GRAPH_Vars_t_
Definition: graph.h:141
_GRAPH_StepVars_t_::pId_ref
float32_t * pId_ref
Definition: graph.h:162
_GRAPH_StepVars_t_::spdRef_Default
float32_t spdRef_Default
Definition: graph.h:165
GRAPH_BUFFER_NR0
Buffer define 0.
Definition: graph.h:118
_GRAPH_Buffer_t_::write
uint16_t write
Definition: graph.h:138
_GRAPH_Vars_t_::bufferTickCounter
uint16_t bufferTickCounter
Definition: graph.h:144
GRAPH_BUFFER_NR3
Buffer define 3.
Definition: graph.h:121
GRAPH_BUFFER_NR
#define GRAPH_BUFFER_NR
Definition: graph.h:57
GRAPH_BufferOut
bool GRAPH_BufferOut(GRAPH_Buffer_t *pBuffer, float32_t *pWord)
Read from the buffer.
GRAPH_PH_B_VIEW
Definition: graph.h:130
_GRAPH_StepVars_t_::pId_in
float32_t * pId_in
Definition: graph.h:158
GRAPH_BUFFER_NR2
Buffer define 2.
Definition: graph.h:120
GRAPH_Buffer_t
struct _GRAPH_Buffer_t_ GRAPH_Buffer_t

Copyright 2023, Texas Instruments Incorporated