UVW 3 phases Brushless DC motor control
Dependencies: QEI mbed-rtos mbed
Fork of BLDCmotor by
Diff: controller.cpp
- Revision:
- 14:8e205264baa8
- Parent:
- 13:791e20f1af43
- Child:
- 15:427f5ae8e957
--- a/controller.cpp Sun Mar 03 09:09:34 2013 +0000 +++ b/controller.cpp Thu Jun 13 06:41:16 2013 +0000 @@ -145,7 +145,8 @@ void current_loop(){ // 電流制御マイナーループ float th, c, s, Cdq[2][2], iu, iv, iab[2], idq_act[2], vab_ref[2], tmp, prev[2]; if( f_find_origin==1 ){ - th = 0; +// th = 0; + th = debug[2]; }else{ th = p.th[0]; } @@ -287,6 +288,7 @@ duty_u = p.vuvw[0]/vdqMAX+0.5; // dutyを計算 duty_v = p.vuvw[1]/vdqMAX+0.5; // dutyを計算 duty_w = p.vuvw[2]/vdqMAX+0.5; // dutyを計算 +duty_u*=5;duty_v*=5;duty_w*=5;//koko uvw[0].duty = duty_u; // dutyをPWM発生関数に渡す uvw[1].duty = duty_v; // dutyをPWM発生関数に渡す uvw[2].duty = duty_w; // dutyをPWM発生関数に渡す @@ -419,14 +421,15 @@ // モータシミュレータ sim_motor(); // IPM, dq座標 #else -//koko p.th[0] = (float)encoder.getPulses()/(float)N_ENC*2.0*PI; // get angle [rad] from encoder - // 位置θをセンサで検出 #ifdef DOUKI led1=1; p.th[0] += 2*PI*TS0 * 1; if(p.th[0]>4*PI){ p.th[0]-=4*PI;} debug[0]=p.th[0]/PI*180; analog_out=debug[0]/180*PI/4/PI; led1=0; +#else + // 位置θをセンサで検出 + p.th[0] = (float)encoder.getPulses()/(float)N_ENC*2.0*PI; // get angle [rad] from encoder #endif #endif current_loop(); // 電流制御マイナーループ(idq_ref to vuvw)