![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
gotta check ctrl algo - it gives negative value
Fork of BAE_hw_test1_3 by
Diff: ACS.cpp
- Revision:
- 10:8bfa80bf4263
- Parent:
- 9:8b74ed33be76
- Child:
- 11:6b00f3b1be17
--- a/ACS.cpp Sun Mar 01 07:41:51 2015 +0000 +++ b/ACS.cpp Sun Mar 01 08:26:04 2015 +0000 @@ -18,7 +18,7 @@ uint8_t trflag_mag; uint8_t trFlag; //ticker Flag for gyro uint8_t drFlag; //data-ready interrupt flag for gyro - +float pwm; //--------------------------------TORQUE ROD--------------------------------------------------------------------------------------------------------------// void FUNC_ACS_GENPWM(float M[3]) @@ -26,6 +26,10 @@ printf("\n\rEnterd PWMGEN function\n\r\r"); + for(int i = 0 ; i<3;i++) + { + printf(" %f \t ",M[i]); + } float DCx = 0; //Duty cycle of Moment in x, y, z directions float ix = 0; //Current sent in x, y, z TR's float timep = 0.02 ; @@ -35,7 +39,7 @@ ix = Mx * 0.3 ; //Moment and Current always have the linear relationship - + ix = 0.554999; if( ix>0&& ix < 0.006 ) //Current and Duty cycle have the linear relationship between 1% and 100% { DCx = 6*1000000*pow(ix,4) - 377291*pow(ix,3) + 4689.6*pow(ix,2) + 149.19*ix - 0.0008; @@ -62,8 +66,10 @@ PWM1.period(timep); PWM1 = DCx/100 ; } - else if(ix==0) + //printf("\n \r b4 %f ",ix); + else if(ix==0) { + printf("\n \r ix====0"); DCx = 75; PWM1.period(timep); PWM1 = DCx/100 ; @@ -72,8 +78,10 @@ { // printf("!!!!!!!!!!Error!!!!!!!!!"); } - //DCx = 25; - printf("\n\r icx :%f\n\r",ix); + pwm = PWM1; + //DCx = 25; + //PWM1 = 0.50; + printf("\n\r icx :%f pwm : %f \n\r",ix,pwm); float DCy = 0; //Duty cycle of Moment in x, y, z directions float iy = 0; //Current sent in x, y, z TR's @@ -119,8 +127,13 @@ { // printf("!!!!!!!!!!Error!!!!!!!!!"); } + + pwm = PWM2; + printf("\n\r icy :%f pwm : %f \n\r",iy,pwm); + + float DCz = 0; //Duty cycle of Moment in x, y, z directions - float iz = 0; //Current sent in x, y, z TR's + float iz = 0; //Current sent in x, y, z TR's float Mz=M[2]; //Time period is set to 0.2s //Moment in x, y, z directions @@ -163,7 +176,7 @@ else { // printf("!!!!!!!!!!Error!!!!!!!!!"); - } + } printf("\n\rExited PWMGEN function\n\r"); }