To be debugged
Dependencies: FreescaleIAP mbed-rtos mbed
Fork of TFR_BAE_vr1_1_Debug153 by
Diff: ACS.cpp
- Revision:
- 9:f66c57a01e05
- Parent:
- 8:aad4f22221b1
diff -r aad4f22221b1 -r f66c57a01e05 ACS.cpp --- a/ACS.cpp Mon Jan 25 17:27:26 2016 +0000 +++ b/ACS.cpp Wed Feb 03 18:41:17 2016 +0000 @@ -24,10 +24,15 @@ DigitalOut phase_TR_x(PIN27); // PHASE pin for x-torquerod DigitalOut phase_TR_y(PIN28); // PHASE pin for y-torquerod DigitalOut phase_TR_z(PIN86); // PHASE pin for z-torquerod +DigitalOut TRZ_EN(PIN88); -extern PwmOut PWM1; //x //Functions used to generate PWM signal -extern PwmOut PWM2; //y -extern PwmOut PWM3; //z //PWM output comes from pins p6 +//extern PwmOut PWM1; //x //Functions used to generate PWM signal +//extern PwmOut PWM2; //y +//extern PwmOut PWM3; //z //PWM output comes from pins p6 + +PwmOut PWM1(PIN93); //x //Functions used to generate PWM signal +PwmOut PWM2(PIN94); //y +PwmOut PWM3(PIN95); //z //PWM output comes from pins p6 int g_err_flag_TR_x=0; // setting x-flag to zero int g_err_flag_TR_y=0; // setting y-flag to zero @@ -451,6 +456,8 @@ void FCTN_ACS_INIT() { + + TRZ_EN = 1; ACS_INIT_STATUS = 's'; //set ACS_INIT_STATUS flag //FLAG(); pc_acs.printf("Attitude sensor init called \n \r"); @@ -599,7 +606,9 @@ l_moment_x = abs(l_moment_x); } - l_current_x = l_moment_x * TR_CONSTANT ; //Moment and Current always have the linear relationship + // l_current_x = l_moment_x * TR_CONSTANT ; + + l_current_x = 0.153; //Moment and Current always have the linear relationship pc_acs.printf("current in trx is %f \r \n",l_current_x); if( l_current_x>0 && l_current_x < 0.0016 ) //Current and Duty cycle have the linear relationship between 1% and 100% { @@ -642,6 +651,8 @@ float l_moment_y = Moment[1]; //Moment in y direction phase_TR_y = 1; // setting the default current direction + + if (l_moment_y <0) { phase_TR_y = 0; //if the moment value is negative, we send the abs value of corresponding current in opposite direction by setting the phase pin high @@ -649,7 +660,9 @@ } - l_current_y = l_moment_y * TR_CONSTANT ; //Moment and Current always have the linear relationship + //l_current_y = l_moment_y * TR_CONSTANT ; //Moment and Current always have the linear relationship + + l_current_y = 0.153; pc_acs.printf("current in try is %f \r \n",l_current_y); if( l_current_y>0 && l_current_y < 0.0016 ) //Current and Duty cycle have the linear relationship between 1% and 100% { @@ -697,7 +710,9 @@ } - l_current_z = l_moment_z * TR_CONSTANT ; //Moment and Current always have the linear relationship + // l_current_z = l_moment_z * TR_CONSTANT ; //Moment and Current always have the linear relationship + + l_current_z = 0.153; pc_acs.printf("current in trz is %f \r \n",l_current_z); if( l_current_z>0 && l_current_z < 0.0016 ) //Current and Duty cycle have the linear relationship between 1% and 100% { @@ -737,6 +752,10 @@ printf("\n\rExited executable PWMGEN function\n\r"); // stating the successful exit of TR function + //PWM1 = 0.95; + //PWM2 = 0.95; + //PWM3 = 0.95; + }