Skip to content

Commit

Permalink
Added friction to the perturbation vector. Now the motor is not spinn…
Browse files Browse the repository at this point in the history
…ing up to full bemf matching speed no matter what but actually reflects the decreased input power based on PWM duty cycle.
  • Loading branch information
esden committed Mar 27, 2012
1 parent 93d7cf5 commit af1da6f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
6 changes: 3 additions & 3 deletions control.py
Expand Up @@ -25,9 +25,9 @@

import math

PWM_freq = 200000
PWM_cycle_time = (1./200000)
PWM_duty = 1.
PWM_freq = 16000
PWM_cycle_time = (1./16000)
PWM_duty = 0.6
PWM_duty_time = PWM_cycle_time * PWM_duty

debug = False
Expand Down
19 changes: 16 additions & 3 deletions dyn_model.py
Expand Up @@ -53,7 +53,7 @@
L = 0.00207 # aka. Coil inductance in H
M = -0.00069 # aka. Mutual inductance in H
R = 11.9 # aka. Phase resistence in Ohm
VDC = 300. # aka. Supply voltage
VDC = 100. # aka. Supply voltage
NbPoles = 4. #
dvf = .0 # aka. freewheeling diode forward voltage
elif pset == 3: #modified psim
Expand Down Expand Up @@ -91,7 +91,8 @@

# Components of the perturbation vector
pv_torque = 0
pv_size = 1
pv_friction = 1
pv_size = 2

# Components of the output vector
ov_iu = 0
Expand Down Expand Up @@ -372,8 +373,20 @@ def dyn_debug(X, t, U, W):
# Electromagnetic torque
etorque = (eu * X[sv_iu] + ev * X[sv_iv] + ew * X[sv_iw])/X[sv_omega]

# Mechanical torque
mtorque = ((etorque * (NbPoles / 2)) - (Damping * X[sv_omega]) - W[pv_torque])

if ((mtorque > 0) and (mtorque <= W[pv_friction])):
mtorque = 0
elif (mtorque >= W[pv_friction]):
mtorque = mtorque - W[pv_friction]
elif ((mtorque < 0) and (mtorque >= (-W[pv_friction]))):
mtorque = 0
elif (mtorque <= (-W[pv_friction])):
mtorque = mtorque + W[pv_friction]

# Acceleration of the rotor
omega_dot = ((etorque * (NbPoles / 2)) - (Damping * X[sv_omega]) - W[pv_torque]) / Inertia
omega_dot = mtorque / Inertia

V = voltages(X, U)

Expand Down
6 changes: 3 additions & 3 deletions sim_1.py
Expand Up @@ -73,16 +73,16 @@ def main():
# t_psim, Y_psim = mio.read_csv('bldc_startup_psim_1us_resolution.csv')
# mp.plot_output(t_psim, Y_psim, '.')

freq_sim = 1e5 # simulation frequency
freq_sim = 1e6 # simulation frequency
compress_factor = 3
time = pl.arange(0.0, 0.1, 1./freq_sim) # create time slice vector
time = pl.arange(0.0, 0.01, 1./freq_sim) # create time slice vector
X = np.zeros((time.size, dm.sv_size)) # allocate state vector
Xdebug = np.zeros((time.size, dm.dv_size)) # allocate debug data vector
Y = np.zeros((time.size, dm.ov_size)) # allocate output vector
U = np.zeros((time.size, dm.iv_size)) # allocate input vector
X0 = [0, mu.rad_of_deg(0.1), 0, 0, 0] #
X[0,:] = X0
W = [0]
W = [0, 1]
for i in range(1,time.size):

if i==1:
Expand Down

0 comments on commit af1da6f

Please sign in to comment.