cpu_cla_shared_dm.h
Go to the documentation of this file.
1 //#############################################################################
2 // FILE: cpu_cla_shared_dm.h
3 // TITLE: header file for shared data and types between CPU and CLA.
4 //
5 // Group: C2000
6 // Target Family: F2837x/F2838x/F28004x
7 //
8 //#############################################################################
9 // $TI Release: C2000-FCL $
10 // $Release Date: Feb 2017 $
11 // $Copyright: Copyright (C) 2013-2017 Texas Instruments Incorporated -
12 // http://www.ti.com/ ALL RIGHTS RESERVED $
13 //#############################################################################
14 
15 #ifndef CPU_CLA_SHARED_DM_H
16 #define CPU_CLA_SHARED_DM_H
17 
18 //
19 // includes
20 //
21 #if defined(F2837x_DEVICE) || defined(F28004x_DEVICE)
22 #include "F28x_Project.h"
23 #else
24 #include "f28x_project.h"
25 #endif
26 
27 #include "f28x_bmsk.h"
28 #include "qep_defs.h"
29 
30 #include "fcl_pi.h"
31 #include "RAMP_GEN_CLA.h"
32 
33 #include "dual_axis_servo_drive_user.h"
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 //
40 // defines
41 //
42 
43 #if 0
44 #define SETGPIO18_HIGH asm(" PUSH DP"); \
45  asm(" MOVW DP,#0x1fc"); \
46  asm(" OR @0x1,#0x0004 "); \
47  asm(" POP DP");
48 
49 #define SETGPIO18_LOW asm(" PUSH DP"); \
50  asm(" MOVW DP,#0x1fc") ; \
51  asm(" AND @0x1,#0xfffb "); \
52  asm(" POP DP");
53 
54 #else
55 #define SETGPIO18_HIGH
56 #define SETGPIO18_LOW
57 
58 #endif
59 
60 //
61 // typedefs
62 //
63 
64 //
65 // Define the structure of the QEP (Quadrature Encoder) Driver Object
66 // this is same as QEP stucture
67 //
68 
69 typedef struct motPars {
77 } cmplxPars_t;
78 
79 
80 #define CMPLXPARS_DEFAULTS { \
81  0, /* cosWTs */ \
82  0, /* sinWTs */ \
83  0, /* expVal */ \
84  0, /* kDirect */ \
85  0, /* idErr */ \
86  0, /* iqErr */ \
87  0 /* carryOver */ \
88 }
89 
90 //
91 // globals
92 //
93 
94 //
95 // Variables for CLA tasks
96 //
97 #define FCL_DEFAULTS { \
98  ENC_ALIGNMENT, /* lsw */ \
99  \
100  CMPLXPARS_DEFAULTS, /* Q_cla */ \
101  0, /* speedWePrev */ \
102  0, /* pangle */ \
103  RAMPGEN_CLA_DEFAULTS, /* rg */ \
104  FCL_PI_CONTROLLER_DEFAULTS, /* pi_iq */ \
105  QEP_DEFAULTS, /* qep */ \
106  &EQep1Regs, /* *ptrQEP */ \
107  0, /* taskFlag */ \
108  0, 0, 0, 0 /* taskCount[4] */ \
109  }
110 
111 //
112 // default parameters for motor_2
113 //
114 
115 //
118 //
119 typedef struct _FCL_Vars_t_
120 {
122 
125  float32_t pangle; // rotor angle
126  RAMP_GEN_CLA rg; // a ramp generator to simulate an Angle
129  volatile struct EQEP_REGS *ptrQEP; // Aligned to lower 16-bits
130  uint32_t taskCount[4];
131 } FCL_Vars_t;
132 
133 extern FCL_Vars_t fclVars[2];
134 
135 
136 typedef struct _SVGEN2_t_
137 {
138  float32_t Ualpha; // Input: reference alpha-axis phase voltage
139  float32_t Ubeta; // Input: reference beta-axis phase voltage
140  float32_t Ta; // Output: reference phase-a switching function
141  float32_t Tb; // Output: reference phase-b switching function
142  float32_t Tc; // Output: reference phase-c switching function
143  float32_t tmp1; // Variable: temp variable
144  float32_t tmp2; // Variable: temp variable
145 }SVGEN2_t;
146 
147 //
148 // MACROS
149 //
150 
151 //
152 // Speed optimized PI MACRO
153 //
154 #define FCL_PI_MACRO(v) \
155 { \
156  v.out += (v.err * v.Kerr) + v.carryOver; \
157  v.out = (v.out > v.Umax) ? v.Umax : v.out; \
158  v.out = (v.out < v.Umin) ? v.Umin : v.out; \
159 }
160 
161 #define CLAMP_MACRO(v) \
162 { \
163  v.out = (v.out > v.Umax) ? v.Umax : v.out; \
164  v.out = (v.out < v.Umin) ? v.Umin : v.out; \
165 }
166 
167 #ifdef __cplusplus
168 }
169 #endif // extern "C"
170 
171 #endif // end of CPU_CLA_SHARED_DM_H definition
_FCL_Vars_t_::pi_iq
FCL_PIController_t pi_iq
Definition: cpu_cla_shared_dm.h:127
fclVars
FCL_Vars_t fclVars[2]
float32_t
float float32_t
Definition: sfra_f32.h:42
_FCL_Vars_t_::pangle
float32_t pangle
Definition: cpu_cla_shared_dm.h:125
FCL_PIController_t
Definition: fcl_pi.h:22
SVGEN2_t
struct _SVGEN2_t_ SVGEN2_t
cmplxPars_t
struct motPars cmplxPars_t
FCL_Vars_t
struct _FCL_Vars_t_ FCL_Vars_t
typedefs for motorVars Variables for CLA tasks
_FCL_Vars_t_::lsw
ENC_Status_e lsw
Definition: cpu_cla_shared_dm.h:121
_FCL_Vars_t_::Q_cla
cmplxPars_t Q_cla
Definition: cpu_cla_shared_dm.h:123
QEP
Definition: qep_defs.h:27
_FCL_Vars_t_::qep
QEP qep
Definition: cpu_cla_shared_dm.h:128
fcl_pi.h
motPars::cosWTs
float32_t cosWTs
Definition: cpu_cla_shared.h:63
motPars
Definition: cpu_cla_shared.h:62
_FCL_Vars_t_
typedefs for motorVars Variables for CLA tasks
Definition: cpu_cla_shared_dm.h:119
_SVGEN2_t_::Tc
float32_t Tc
Definition: cpu_cla_shared_dm.h:142
motPars::idErr
float32_t idErr
Definition: cpu_cla_shared.h:67
_SVGEN2_t_::Tb
float32_t Tb
Definition: cpu_cla_shared_dm.h:141
_SVGEN2_t_
Definition: cpu_cla_shared_dm.h:136
qep_defs.h
motPars::expVal
float32_t expVal
Definition: cpu_cla_shared.h:65
ENC_Status_e
ENC_Status_e
Definition: encoder.h:86
motPars::iqErr
float32_t iqErr
Definition: cpu_cla_shared.h:68
motPars::kDirect
float32_t kDirect
Definition: cpu_cla_shared.h:66
_FCL_Vars_t_::rg
RAMP_GEN_CLA rg
Definition: cpu_cla_shared_dm.h:126
_SVGEN2_t_::tmp2
float32_t tmp2
Definition: cpu_cla_shared_dm.h:144
_FCL_Vars_t_::speedWePrev
float32_t speedWePrev
Definition: cpu_cla_shared_dm.h:124
f28x_bmsk.h
_SVGEN2_t_::Ta
float32_t Ta
Definition: cpu_cla_shared_dm.h:140
_SVGEN2_t_::tmp1
float32_t tmp1
Definition: cpu_cla_shared_dm.h:143
_FCL_Vars_t_::ptrQEP
volatile struct EQEP_REGS * ptrQEP
Definition: cpu_cla_shared_dm.h:129
motPars::sinWTs
float32_t sinWTs
Definition: cpu_cla_shared.h:64
_SVGEN2_t_::Ubeta
float32_t Ubeta
Definition: cpu_cla_shared_dm.h:139
_FCL_Vars_t_::taskCount
uint32_t taskCount[4]
Definition: cpu_cla_shared_dm.h:130
_SVGEN2_t_::Ualpha
float32_t Ualpha
Definition: cpu_cla_shared_dm.h:138
motPars::carryOver
float32_t carryOver
Definition: cpu_cla_shared.h:69

Copyright 2023, Texas Instruments Incorporated