Q[0][0] = 1e-4 Q[1][1] = 1e-4 Q[2][2] = 3e-2 Q[3][3] = 3e-2 Q[4][4] = 1e-8 # R = 1e-7 * identity(2) # Classes ekf = dEKF(xk, PP, Q, R) w_r = zeros((len(time), 3)) for i in range(0, int(len(time) / 5)): (Ak, Bk, H, D) = acim.dss_statorreferenceframe1(xk[4], Ts) Ulb = coord_trans.clarke_m_i(voltage[i][0], voltage[i][1], voltage[i][2]) Ilb = coord_trans.clarke_m_i(current[i][0], current[i][1], current[i][2]) Udq = coord_trans.stator_coordinate(Ulb, teta[i][0]) Idq = coord_trans.stator_coordinate(Ilb, teta[i][0]) xk = ekf.update_state(Udq, Ak, Bk); Gk = acim.dss_Gk_stator1(xk[2], xk[3], xk[4], Ts) (xk, PP, error) = ekf.update(Idq, Udq, Gk, Ak, Bk, H) w_r[i][0] = xk[ 4 ][0] w_r[i][1] = speed[i][0] w_r[i][2] = speed[i][1] print w_r[i][0] - w_r[i][1] if(abs(w_r[i][0] - w_r[i][1]) > 50): break pylab.figure(1)
U = dlqr.calcU( xk, array( [sw[i:i + N]] ) , Ak = Ak, Bk = Bk, Ck = Ck ) # Voltages inverse transformation Ulb = ct.inv_rotor_coordinate( U, P * xk[4, 0] ) U_abc[ i] = ct.inv_clarke_m_i( Ulb[0, 0], Ulb[1, 0] )[:, 0] #Limitating the signal for k in range( 0, U_abc.shape[1] ): if( np.abs( U_abc[i, k] ) > 380 ): U_abc[i, k] = np.sign( U_abc[i, k] ) * 380; #Voltages transformation Ulb = ct.clarke_m_i( U_abc[ i, 0], U_abc[ i, 1], U_abc[ i, 2] ) Udq = ct.rotor_coordinate( Ulb, P * xk[4, 0] ) #Simulating the model... ( y_out, x ) = pmsm.dlsim( Udq, xk, Ts = Ts, Tl = torque[ 0, i] ) #Tl = torque[ i] ) #Estimating the states. We assume that the x(0) and x(1) is the measured current xk = ekf.update_state( Udq, Ak, Bk ); Gk = pmsm.GK( xk, Ts ) ( xk, PP, eerror ) = ekf.update( array( [[x[0, 0]], [x[1, 0]]] ), Udq, Gk, Ak, Bk, H ) #History w_est[i, :] = xk[2, 0]; O_est[i, :] = xk[3, 0]; w_s[i, :] = y_out
pylab.plot(signal[0]) pylab.plot(signal[1]) pylab.plot(signal[2]) pylab.subplot(3,1,2, title='Alpha,Beta transformation') pylab.plot(a_alpha_beta[0]) pylab.plot(a_alpha_beta[1]) pylab.subplot(3,1,3, title="Alpha,Beta inverse transformation") pylab.plot(a_a_b_c[0]) pylab.plot(a_a_b_c[1]) pylab.plot(a_a_b_c[2]) for i in range( len( atime ) ): alpha_beta = transf.clarke_m_i(signal[0][i], signal[1][i], signal[2][i]) a_b_c = transf.inv_clarke_m_i(alpha_beta[0][0], alpha_beta[1][0], alpha_beta[2][0]) a_alpha_beta[0][i] = alpha_beta[0][0] a_alpha_beta[1][i] = alpha_beta[1][0] a_alpha_beta[2][i] = alpha_beta[2][0] a_a_b_c[0][i] = a_b_c[0][0] a_a_b_c[1][i] = a_b_c[1][0] a_a_b_c[2][i] = a_b_c[2][0] pylab.figure( 3 ) pylab.subplot(3,1,1, title="Three phase signal") pylab.plot(signal[0]) pylab.plot(signal[1])
pylab.plot(signal[0]) pylab.plot(signal[1]) pylab.plot(signal[2]) pylab.subplot(3, 1, 2, title='Alpha,Beta transformation') pylab.plot(a_alpha_beta[0]) pylab.plot(a_alpha_beta[1]) pylab.subplot(3, 1, 3, title="Alpha,Beta inverse transformation") pylab.plot(a_a_b_c[0]) pylab.plot(a_a_b_c[1]) pylab.plot(a_a_b_c[2]) for i in range(len(atime)): alpha_beta = transf.clarke_m_i(signal[0][i], signal[1][i], signal[2][i]) a_b_c = transf.inv_clarke_m_i(alpha_beta[0][0], alpha_beta[1][0], alpha_beta[2][0]) a_alpha_beta[0][i] = alpha_beta[0][0] a_alpha_beta[1][i] = alpha_beta[1][0] a_alpha_beta[2][i] = alpha_beta[2][0] a_a_b_c[0][i] = a_b_c[0][0] a_a_b_c[1][i] = a_b_c[1][0] a_a_b_c[2][i] = a_b_c[2][0] pylab.figure(3) pylab.subplot(3, 1, 1, title="Three phase signal") pylab.plot(signal[0])
Q[1][1] = 1e-2 Q[2][2] = 1e-4 Q[3][3] = 1e-4 Q[4][4] = 1e-6 Q[5][5] = 1e-6 # R = 1e-7 * identity( 2 ) #Classes ekf = dEKF( xk, PP, Q, R ) w_r = zeros( ( len( time ), 3 ) ) for i in range( 0, int( len( time ) / 5 ) ): ( Ak, Bk, H, D ) = acim.dss_statorreferenceframe2( xk[4], Ts ) Ulb = coord_trans.clarke_m_i( voltage[i][0], voltage[i][1], voltage[i][2] ) Ilb = coord_trans.clarke_m_i( current[i][0], current[i][1], current[i][2] ) Udq = coord_trans.stator_coordinate( Ulb, teta[i][0] ) Idq = coord_trans.stator_coordinate( Ilb, teta[i][0] ) xk = ekf.update_state( Udq, Ak, Bk ); Gk = acim.dss_Gk_stator1( xk[2], xk[3], xk[4], Ts ) ( xk, PP, error ) = ekf.update( Idq, Udq, Gk, Ak, Bk, H ) w_r[i][0] = xk[ 4 ][0] w_r[i][1] = speed[i][0] w_r[i][2] = speed[i][1] print w_r[i][0] - w_r[i][1] if( abs( w_r[i][0] - w_r[i][1] ) > 50 ): break pylab.figure( 1 )
Q[0][0] = 1e-4 Q[1][1] = 1e-4 Q[2][2] = 3e-2 Q[3][3] = 3e-2 Q[4][4] = 1e-8 # R = 1e-7 * identity(2) #Classes ekf = dEKF(xk, PP, Q, R) w_r = zeros((len(time), 3)) for i in range(0, int(len(time) / 5)): (Ak, Bk, H, D) = acim.dss_statorreferenceframe1(xk[4], Ts) Ulb = coord_trans.clarke_m_i(voltage[i][0], voltage[i][1], voltage[i][2]) Ilb = coord_trans.clarke_m_i(current[i][0], current[i][1], current[i][2]) Udq = coord_trans.stator_coordinate(Ulb, teta[i][0]) Idq = coord_trans.stator_coordinate(Ilb, teta[i][0]) xk = ekf.update_state(Udq, Ak, Bk) Gk = acim.dss_Gk_stator1(xk[2], xk[3], xk[4], Ts) (xk, PP, error) = ekf.update(Idq, Udq, Gk, Ak, Bk, H) w_r[i][0] = xk[4][0] w_r[i][1] = speed[i][0] w_r[i][2] = speed[i][1] print w_r[i][0] - w_r[i][1] if (abs(w_r[i][0] - w_r[i][1]) > 50): break pylab.figure(1)