Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 431 lines (360 sloc) 11.669 kB
6280569 added python skeleton
Antoine Drouin authored
1 #-*- coding: utf-8 -*-
0708d5c @esden Added license headers.
authored
2 #
65f2fb7 @esden Corrected application name in the license headers.
authored
3 # Open-BLDC pysim - Open BrushLess DC Motor Controller python simulator
0708d5c @esden Added license headers.
authored
4 # Copyright (C) 2011 by Antoine Drouin <poinix@gmail.com>
5 # Copyright (C) 2011 by Piotr Esden-Tempski <piotr@esden.net>
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #
20
6280569 added python skeleton
Antoine Drouin authored
21 import numpy as np
0c3350c blaaaaa
Antoine Drouin authored
22 import math
7593860 @esden Changed omega to thetae (electrical angle) in the bemf calculation. M…
authored
23 import misc_utils as mu
6280569 added python skeleton
Antoine Drouin authored
24
25 # parameters
78b4411 @esden Added rpm_of_radps helper function, decreased simulator frequency aga…
authored
26 pset = 2
0322ebe @esden Added one more set of motor parameters.
authored
27
28 if pset == 0:
369f125 added psim parameters
Antoine Drouin authored
29 Inertia = 0.0022 # aka. 'J' in kg/(m^2)
30 Damping = 0.001 # aka. 'B' in Nm/(rad/s)
31 Kv = 1700. # aka. motor constant in RPM/V
32 L = 0.00312 # aka. Coil inductance in H
88c40ca @esden Now calculating the phase voltage including the inverter diode forwar…
authored
33 M = 0.0 # aka. Mutual inductance in H
369f125 added psim parameters
Antoine Drouin authored
34 R = 0.8 # aka. Phase resistence in Ohm
35 VDC = 100. # aka. Supply voltage
36 NbPoles = 14. # NbPoles / 2 = Number of pole pairs (you count the permanent magnets on the rotor to get NbPoles)
39b6230 @esden Fixed Kv to Ke conversion. Now the outputs make much more sense.
authored
37 dvf = .7 # aka. freewheeling diode forward voltage
0322ebe @esden Added one more set of motor parameters.
authored
38 elif pset == 1:
39 Inertia = 0.0022 # aka. 'J' in kg/(m^2)
40 Damping = 0.001 # aka. 'B' in Nm/(rad/s)
41 Kv = 70. # aka. motor constant in RPM/V
42 L = 0.00521 # aka. Coil inductance in H
43 M = 0.0 # aka. Mutual inductance in H
44 R = 0.7 # aka. Phase resistence in Ohm
45 VDC = 100. # aka. Supply voltage
46 NbPoles = 4. # NbPoles / 2 = Number of pole pairs (you count the permanent magnets on the rotor to get NbPoles)
47 dvf = .7 # aka. freewheeling diode forward voltage
48 elif pset == 2: #psim
88c40ca @esden Now calculating the phase voltage including the inverter diode forwar…
authored
49 Inertia = 0.000007 # aka. 'J' in kg/(m^2)
369f125 added psim parameters
Antoine Drouin authored
50 tau_shaft = 0.006
51 Damping = Inertia/tau_shaft # aka. 'B' in Nm/(rad/s)
52 Kv = 1./32.3*1000 # aka. motor constant in RPM/V
53 L = 0.00207 # aka. Coil inductance in H
88c40ca @esden Now calculating the phase voltage including the inverter diode forwar…
authored
54 M = -0.00069 # aka. Mutual inductance in H
369f125 added psim parameters
Antoine Drouin authored
55 R = 11.9 # aka. Phase resistence in Ohm
af1da6f @esden Added friction to the perturbation vector. Now the motor is not spinn…
authored
56 VDC = 100. # aka. Supply voltage
637f97b @esden Some more debugging work. Still not there. Added internal variable de…
authored
57 NbPoles = 4. #
7ea3119 @esden Fixed a bug in the diode code so that the low side diodes switch now …
authored
58 dvf = .0 # aka. freewheeling diode forward voltage
59 elif pset == 3: #modified psim
60 Inertia = 0.000059 # aka. 'J' in kg/(m^2)
61 tau_shaft = 0.006
62 Damping = Inertia/tau_shaft # aka. 'B' in Nm/(rad/s)
63 Kv = 1./32.3*1000 # aka. motor constant in RPM/V
64 L = 0.00207 # aka. Coil inductance in H
65 M = -0.00069 # aka. Mutual inductance in H
66 R = 11.9 # aka. Phase resistence in Ohm
67 VDC = 300. # aka. Supply voltage
68 NbPoles = 4. #
69 dvf = .0 # aka. freewheeling diode forward voltage
0322ebe @esden Added one more set of motor parameters.
authored
70 else:
71 print "Unknown pset {}".format(pset)
637f97b @esden Some more debugging work. Still not there. Added internal variable de…
authored
72
6280569 added python skeleton
Antoine Drouin authored
73 # Components of the state vector
1fef2ba @esden Started implementing the system equations.
authored
74 sv_theta = 0 # angle of the rotor
75 sv_omega = 1 # angular speed of the rotor
76 sv_iu = 2 # phase u current
77 sv_iv = 3 # phase v current
78 sv_iw = 4 # phase w current
79 sv_size = 5
6280569 added python skeleton
Antoine Drouin authored
80
81
82 # Components of the command vector
83 iv_lu = 0
84 iv_hu = 1
85 iv_lv = 2
86 iv_hv = 3
87 iv_lw = 4
88 iv_hw = 5
93d7cf5 @esden Removed diode handling.
authored
89 iv_size = 6
6280569 added python skeleton
Antoine Drouin authored
90
91
92 # Components of the perturbation vector
0c3350c blaaaaa
Antoine Drouin authored
93 pv_torque = 0
af1da6f @esden Added friction to the perturbation vector. Now the motor is not spinn…
authored
94 pv_friction = 1
95 pv_size = 2
6280569 added python skeleton
Antoine Drouin authored
96
0c3350c blaaaaa
Antoine Drouin authored
97 # Components of the output vector
5de78a7 added voltages to output vector
Antoine Drouin authored
98 ov_iu = 0
99 ov_iv = 1
100 ov_iw = 2
101 ov_vu = 3
102 ov_vv = 4
103 ov_vw = 5
444c14b commitning in shit state for debugging
Antoine Drouin authored
104 ov_theta = 6
105 ov_omega = 7
5de78a7 added voltages to output vector
Antoine Drouin authored
106 ov_size = 8
0c3350c blaaaaa
Antoine Drouin authored
107
bf6212e @esden Moved voltage calculation to it's own function. Added voltages to the…
authored
108 # Phases and star vector designators
109 ph_U = 0
110 ph_V = 1
111 ph_W = 2
112 ph_star = 3
113 ph_size = 4
0c3350c blaaaaa
Antoine Drouin authored
114
637f97b @esden Some more debugging work. Still not there. Added internal variable de…
authored
115 # Debug vector components
116 dv_eu = 0
117 dv_ev = 1
118 dv_ew = 2
119 dv_ph_U = 3
120 dv_ph_V = 4
121 dv_ph_W = 5
122 dv_ph_star = 6
123 dv_size = 7
124
0c3350c blaaaaa
Antoine Drouin authored
125 #
1fef2ba @esden Started implementing the system equations.
authored
126 # Calculate backemf at a given omega offset from the current rotor position
127 #
128 # Used to calculate the phase backemf aka. 'e'
129 #
7593860 @esden Changed omega to thetae (electrical angle) in the bemf calculation. M…
authored
130 def backemf(X,thetae_offset):
665835a @esden Updated the motor simulation parameters. Fixed some little issues wit…
authored
131 phase_thetae = mu.norm_angle((X[sv_theta] * (NbPoles / 2.)) + thetae_offset)
132
39b6230 @esden Fixed Kv to Ke conversion. Now the outputs make much more sense.
authored
133 bemf_constant = mu.vpradps_of_rpmpv(Kv) # aka. ke in V/rad/s
1fef2ba @esden Started implementing the system equations.
authored
134 max_bemf = bemf_constant * X[sv_omega]
665835a @esden Updated the motor simulation parameters. Fixed some little issues wit…
authored
135
0971c9d @esden Converted all constant variables in the model to floats. (is it the r…
authored
136 bemf = 0.
665835a @esden Updated the motor simulation parameters. Fixed some little issues wit…
authored
137 if 0. <= phase_thetae <= (math.pi * (1./6.)):
138 bemf = (max_bemf / (math.pi * (1./6.))) * phase_thetae
139 elif (math.pi/6.) < phase_thetae <= (math.pi * (5./6.)):
1fef2ba @esden Started implementing the system equations.
authored
140 bemf = max_bemf
665835a @esden Updated the motor simulation parameters. Fixed some little issues wit…
authored
141 elif (math.pi * (5./6.)) < phase_thetae <= (math.pi * (7./6.)):
142 bemf = -((max_bemf/(math.pi/6.))* (phase_thetae - math.pi))
143 elif (math.pi * (7./6.)) < phase_thetae <= (math.pi * (11./6.)):
1fef2ba @esden Started implementing the system equations.
authored
144 bemf = -max_bemf
665835a @esden Updated the motor simulation parameters. Fixed some little issues wit…
authored
145 elif (math.pi * (11./6.)) < phase_thetae <= (2.0 * math.pi):
146 bemf = (max_bemf/(math.pi/6.)) * (phase_thetae - (2. * math.pi))
147 else:
148 print "ERROR: angle out of bounds can not calculate bemf {}".format(phase_thetae)
1fef2ba @esden Started implementing the system equations.
authored
149
150 return bemf
6280569 added python skeleton
Antoine Drouin authored
151
152 #
bf6212e @esden Moved voltage calculation to it's own function. Added voltages to the…
authored
153 # Calculate phase voltages
154 # Returns a vector of phase voltages in reference to the star point
155 def voltages(X, U):
6280569 added python skeleton
Antoine Drouin authored
156
0971c9d @esden Converted all constant variables in the model to floats. (is it the r…
authored
157 eu = backemf(X, 0.)
158 ev = backemf(X, math.pi * (2./3.))
159 ew = backemf(X, math.pi * (4./3.))
1fef2ba @esden Started implementing the system equations.
authored
160
5bf825d @esden Diode state is being passed as input now, voltages are calculated bas…
authored
161 # Check which phases are excited
162 pux = (U[iv_hu] == 1) or \
93d7cf5 @esden Removed diode handling.
authored
163 (U[iv_lu] == 1)
5bf825d @esden Diode state is being passed as input now, voltages are calculated bas…
authored
164
165 pvx = (U[iv_hv] == 1) or \
93d7cf5 @esden Removed diode handling.
authored
166 (U[iv_lv] == 1)
5bf825d @esden Diode state is being passed as input now, voltages are calculated bas…
authored
167
168 pwx = (U[iv_hw] == 1) or \
93d7cf5 @esden Removed diode handling.
authored
169 (U[iv_lw] == 1)
5bf825d @esden Diode state is being passed as input now, voltages are calculated bas…
authored
170
171 vu = 0.
172 vv = 0.
173 vw = 0.
174 vm = 0.
175
176 if pux and pvx and pwx:
88c40ca @esden Now calculating the phase voltage including the inverter diode forwar…
authored
177 if (U[iv_hu] == 1):
7c08537 @esden Now calculating phase voltages also in the case when only one or no p…
authored
178 vu = VDC/2.
5bf825d @esden Diode state is being passed as input now, voltages are calculated bas…
authored
179 else:
7c08537 @esden Now calculating phase voltages also in the case when only one or no p…
authored
180 vu = -VDC/2.
88c40ca @esden Now calculating the phase voltage including the inverter diode forwar…
authored
181
182 if (U[iv_hv] == 1):
7c08537 @esden Now calculating phase voltages also in the case when only one or no p…
authored
183 vv = VDC/2.
5bf825d @esden Diode state is being passed as input now, voltages are calculated bas…
authored
184 else:
7c08537 @esden Now calculating phase voltages also in the case when only one or no p…
authored
185 vv = -VDC/2.
88c40ca @esden Now calculating the phase voltage including the inverter diode forwar…
authored
186
187 if (U[iv_hw] == 1):
7c08537 @esden Now calculating phase voltages also in the case when only one or no p…
authored
188 vw = VDC/2.
5bf825d @esden Diode state is being passed as input now, voltages are calculated bas…
authored
189 else:
7c08537 @esden Now calculating phase voltages also in the case when only one or no p…
authored
190 vw = -VDC/2.
88c40ca @esden Now calculating the phase voltage including the inverter diode forwar…
authored
191
5bf825d @esden Diode state is being passed as input now, voltages are calculated bas…
authored
192 vm = (vu + vv + vw - eu - ev - ew) / 3.
88c40ca @esden Now calculating the phase voltage including the inverter diode forwar…
authored
193
5bf825d @esden Diode state is being passed as input now, voltages are calculated bas…
authored
194 elif pux and pvx:
93d7cf5 @esden Removed diode handling.
authored
195
196 # calculate excited phase voltages
88c40ca @esden Now calculating the phase voltage including the inverter diode forwar…
authored
197 if (U[iv_hu] == 1):
7c08537 @esden Now calculating phase voltages also in the case when only one or no p…
authored
198 vu = VDC/2.
5bf825d @esden Diode state is being passed as input now, voltages are calculated bas…
authored
199 else:
7c08537 @esden Now calculating phase voltages also in the case when only one or no p…
authored
200 vu = -VDC/2.
88c40ca @esden Now calculating the phase voltage including the inverter diode forwar…
authored
201
202 if (U[iv_hv] == 1):
7c08537 @esden Now calculating phase voltages also in the case when only one or no p…
authored
203 vv = VDC/2.
5bf825d @esden Diode state is being passed as input now, voltages are calculated bas…
authored
204 else:
7c08537 @esden Now calculating phase voltages also in the case when only one or no p…
authored
205 vv = -VDC/2.
88c40ca @esden Now calculating the phase voltage including the inverter diode forwar…
authored
206
93d7cf5 @esden Removed diode handling.
authored
207 # calculate star voltage
5bf825d @esden Diode state is being passed as input now, voltages are calculated bas…
authored
208 vm = (vu + vv - eu - ev) / 2.
93d7cf5 @esden Removed diode handling.
authored
209
210 # calculate remaining phase voltage
5bf825d @esden Diode state is being passed as input now, voltages are calculated bas…
authored
211 vw = ew + vm
93d7cf5 @esden Removed diode handling.
authored
212
213 # clip the voltage to freewheeling diodes
214 #if (vw > ((VDC/2) + dvf)):
215 # vw = (VDC/2) + dvf;
216 # vm = (vu + vv + vw - eu - ev - ew) / 3.
217 #elif (vw < (-(VDC/2) - dvf)):
218 # vw = -(VDC/2) - dvf;
219 # vm = (vu + vv + vw - eu - ev - ew) / 3.
220
5bf825d @esden Diode state is being passed as input now, voltages are calculated bas…
authored
221 elif pux and pwx:
88c40ca @esden Now calculating the phase voltage including the inverter diode forwar…
authored
222 if (U[iv_hu] == 1):
7c08537 @esden Now calculating phase voltages also in the case when only one or no p…
authored
223 vu = VDC/2.
5bf825d @esden Diode state is being passed as input now, voltages are calculated bas…
authored
224 else:
7c08537 @esden Now calculating phase voltages also in the case when only one or no p…
authored
225 vu = -VDC/2.
88c40ca @esden Now calculating the phase voltage including the inverter diode forwar…
authored
226
227 if (U[iv_hw] == 1):
7c08537 @esden Now calculating phase voltages also in the case when only one or no p…
authored
228 vw = VDC/2.
5bf825d @esden Diode state is being passed as input now, voltages are calculated bas…
authored
229 else:
7c08537 @esden Now calculating phase voltages also in the case when only one or no p…
authored
230 vw = -VDC/2.
88c40ca @esden Now calculating the phase voltage including the inverter diode forwar…
authored
231
5bf825d @esden Diode state is being passed as input now, voltages are calculated bas…
authored
232 vm = (vu + vw - eu - ew) / 2.
233 vv = ev + vm
93d7cf5 @esden Removed diode handling.
authored
234
235 # clip the voltage to freewheeling diodes
236 #if (vv > ((VDC/2) + dvf)):
237 # vv = (VDC/2) + dvf;
238 # vm = (vu + vv + vw - eu - ev - ew) / 3.
239 #elif (vv < (-(VDC/2) - dvf)):
240 # vv = -(VDC/2) - dvf;
241 # vm = (vu + vv + vw - eu - ev - ew) / 3.
242
5bf825d @esden Diode state is being passed as input now, voltages are calculated bas…
authored
243 elif pvx and pwx:
88c40ca @esden Now calculating the phase voltage including the inverter diode forwar…
authored
244 if (U[iv_hv] == 1):
7c08537 @esden Now calculating phase voltages also in the case when only one or no p…
authored
245 vv = VDC/2.
246 else:
247 vv = -VDC/2.
248
249 if (U[iv_hw] == 1):
250 vw = VDC/2.
251 else:
252 vw = -VDC/2.
253
254 vm = (vv + vw - ev - ew) / 2.
255 vu = eu + vm
93d7cf5 @esden Removed diode handling.
authored
256
257 # clip the voltage to freewheeling diodes
258 #if (vu > ((VDC/2) + dvf)):
259 # vu = (VDC/2) + dvf;
260 # vm = (vu + vv + vw - eu - ev - ew) / 3.
261 #elif (vu < (-(VDC/2) - dvf)):
262 # vu = -(VDC/2) - dvf;
263 # vm = (vu + vv + vw - eu - ev - ew) / 3.
264
7c08537 @esden Now calculating phase voltages also in the case when only one or no p…
authored
265 elif pux:
266 if (U[iv_hu] == 1):
267 vu = VDC/2
268 else:
269 vu = -VDC/2.
270
271 vm = (vu - eu)
272 vv = ev + vm
273 vw = ew + vm
93d7cf5 @esden Removed diode handling.
authored
274
275 # if we want to handle diodes properly how to do that here?
276
7c08537 @esden Now calculating phase voltages also in the case when only one or no p…
authored
277 elif pvx:
278 if (U[iv_hv] == 1):
5bf825d @esden Diode state is being passed as input now, voltages are calculated bas…
authored
279 vv = VDC/2
280 else:
7c08537 @esden Now calculating phase voltages also in the case when only one or no p…
authored
281 vv = -VDC/2.
88c40ca @esden Now calculating the phase voltage including the inverter diode forwar…
authored
282
7c08537 @esden Now calculating phase voltages also in the case when only one or no p…
authored
283 vm = (vv - ev)
284 vu = eu + vm
285 vw = ew + vm
286 elif pwx:
88c40ca @esden Now calculating the phase voltage including the inverter diode forwar…
authored
287 if (U[iv_hw] == 1):
5bf825d @esden Diode state is being passed as input now, voltages are calculated bas…
authored
288 vw = VDC/2
289 else:
7c08537 @esden Now calculating phase voltages also in the case when only one or no p…
authored
290 vw = -VDC/2.
88c40ca @esden Now calculating the phase voltage including the inverter diode forwar…
authored
291
7c08537 @esden Now calculating phase voltages also in the case when only one or no p…
authored
292 vm = (vw - ew)
5bf825d @esden Diode state is being passed as input now, voltages are calculated bas…
authored
293 vu = eu + vm
7c08537 @esden Now calculating phase voltages also in the case when only one or no p…
authored
294 vv = ev + vm
295 else:
296 vm = eu
297 vv = ev
298 vw = ew
5bf825d @esden Diode state is being passed as input now, voltages are calculated bas…
authored
299
8e72e13 @esden Changed the old voltage calculation to use phase excitation instead o…
authored
300
301 # # Initialize the imposed terminal voltages
5bf825d @esden Diode state is being passed as input now, voltages are calculated bas…
authored
302 # vui = 0.
303 # vvi = 0.
304 # vwi = 0.
8e72e13 @esden Changed the old voltage calculation to use phase excitation instead o…
authored
305 #
306 # # Phase input voltages based on the inverter switches states
307 # if (U[iv_hu] == 1) or (U[iv_dhu] == 1):
308 # vui = VDC/2.
5bf825d @esden Diode state is being passed as input now, voltages are calculated bas…
authored
309 # if (U[iv_lu] == 1) or (U[iv_dlu] == 1):
310 # vui = -VDC/2.
311 # if (U[iv_hv] == 1) or (U[iv_dhv] == 1):
312 # vvi = VDC/2.
313 # if (U[iv_lv] == 1) or (U[iv_dlv] == 1):
314 # vvi = -VDC/2.
315 # if (U[iv_hw] == 1) or (U[iv_dhw] == 1):
316 # vwi = VDC/2.
317 # if (U[iv_lw] == 1) or (U[iv_dlw] == 1):
318 # vwi = -VDC/2.
319 #
8e72e13 @esden Changed the old voltage calculation to use phase excitation instead o…
authored
320 # #i_thr = 0.001 # current threshold saying that the phase is not conducting
321 # i_thr = 0. # current threshold saying that the phase is not conducting
322 # #if -i_thr < X[sv_iu] < i_thr: # phase V & W are conducting current
323 # if not pux: # phase V & W are conducting current
5bf825d @esden Diode state is being passed as input now, voltages are calculated bas…
authored
324 # vm = ((vvi + vwi) / 2.) - ((ev + ew) / 2.)
325 # vu = eu
326 # vv = vvi - vm
327 # vw = vwi - vm
8e72e13 @esden Changed the old voltage calculation to use phase excitation instead o…
authored
328 # elif not pvx: # phase U & W are conducting current
5bf825d @esden Diode state is being passed as input now, voltages are calculated bas…
authored
329 # vm = ((vui + vwi) / 2.) - ((eu + ew) / 2.)
330 # vu = vui - vm
331 # vv = ev
332 # vw = vwi - vm
8e72e13 @esden Changed the old voltage calculation to use phase excitation instead o…
authored
333 # elif not pwx: # phase U & V are conducting current
5bf825d @esden Diode state is being passed as input now, voltages are calculated bas…
authored
334 # vm = ((vui + vvi) / 2.) - ((eu + ev) / 2.)
335 # vu = vui - vm
336 # vv = vvi - vm
337 # vw = ew
338 # else: # all phases are corducting current
339 # print "all phases are conducting!"
340 # vm = ((vui + vvi + vwi) / 3.) - ((eu + ev + ew) / 3.)
341 # vu = vui - vm
342 # vv = vvi - vm
343 # vw = vwi - vm
eb838b7 @esden Calculation of phase voltages is more accurate now. Still ignoring fr…
authored
344
8e72e13 @esden Changed the old voltage calculation to use phase excitation instead o…
authored
345
444c14b commitning in shit state for debugging
Antoine Drouin authored
346 # print "{} : {} {} {}".format(X[sv_omega], vu, vv, vw )
347
bf6212e @esden Moved voltage calculation to it's own function. Added voltages to the…
authored
348 V = [ vu,
349 vv,
350 vw,
351 vm
352 ]
353
354 return V
355
356 #
357 # Dynamic model
358 #
359 # X state, t time, U input, W perturbation
360 #
361 def dyn(X, t, U, W):
637f97b @esden Some more debugging work. Still not there. Added internal variable de…
authored
362 Xd, Xdebug = dyn_debug(X, t, U, W)
363
364 return Xd
365
366 # Dynamic model with debug vector
367 def dyn_debug(X, t, U, W):
368
bf6212e @esden Moved voltage calculation to it's own function. Added voltages to the…
authored
369 eu = backemf(X, 0.)
370 ev = backemf(X, math.pi * (2./3.))
371 ew = backemf(X, math.pi * (4./3.))
372
373 # Electromagnetic torque
374 etorque = (eu * X[sv_iu] + ev * X[sv_iv] + ew * X[sv_iw])/X[sv_omega]
375
af1da6f @esden Added friction to the perturbation vector. Now the motor is not spinn…
authored
376 # Mechanical torque
377 mtorque = ((etorque * (NbPoles / 2)) - (Damping * X[sv_omega]) - W[pv_torque])
378
379 if ((mtorque > 0) and (mtorque <= W[pv_friction])):
380 mtorque = 0
381 elif (mtorque >= W[pv_friction]):
382 mtorque = mtorque - W[pv_friction]
383 elif ((mtorque < 0) and (mtorque >= (-W[pv_friction]))):
384 mtorque = 0
385 elif (mtorque <= (-W[pv_friction])):
386 mtorque = mtorque + W[pv_friction]
387
bf6212e @esden Moved voltage calculation to it's own function. Added voltages to the…
authored
388 # Acceleration of the rotor
af1da6f @esden Added friction to the perturbation vector. Now the motor is not spinn…
authored
389 omega_dot = mtorque / Inertia
bf6212e @esden Moved voltage calculation to it's own function. Added voltages to the…
authored
390
391 V = voltages(X, U)
392
637f97b @esden Some more debugging work. Still not there. Added internal variable de…
authored
393 pdt = VDC/2 + dvf
394
88c40ca @esden Now calculating the phase voltage including the inverter diode forwar…
authored
395 iu_dot = (V[ph_U] - (R * X[sv_iu]) - eu - V[ph_star]) / (L - M)
396 iv_dot = (V[ph_V] - (R * X[sv_iv]) - ev - V[ph_star]) / (L - M)
397 iw_dot = (V[ph_W] - (R * X[sv_iw]) - ew - V[ph_star]) / (L - M)
1fef2ba @esden Started implementing the system equations.
authored
398
399 Xd = [ X[sv_omega],
0c3350c blaaaaa
Antoine Drouin authored
400 omega_dot,
401 iu_dot,
402 iv_dot,
403 iw_dot
404 ]
405
637f97b @esden Some more debugging work. Still not there. Added internal variable de…
authored
406 Xdebug = [
407 eu,
408 ev,
409 ew,
410 V[ph_U],
411 V[ph_V],
412 V[ph_W],
413 V[ph_star]
414 ]
415
416 return Xd, Xdebug
0c3350c blaaaaa
Antoine Drouin authored
417
418
419 #
420 #
421 #
bf6212e @esden Moved voltage calculation to it's own function. Added voltages to the…
authored
422 def output(X, U):
423
424 V = voltages(X, U)
0c3350c blaaaaa
Antoine Drouin authored
425
369f125 added psim parameters
Antoine Drouin authored
426 Y = [X[sv_iu], X[sv_iv], X[sv_iw],
427 V[ph_U], V[ph_V], V[ph_W],
444c14b commitning in shit state for debugging
Antoine Drouin authored
428 X[sv_theta], X[sv_omega]]
369f125 added psim parameters
Antoine Drouin authored
429
0c3350c blaaaaa
Antoine Drouin authored
430 return Y
Something went wrong with that request. Please try again.