Yeseong Jeong
/
HydraulicControlBoard_Start
20210203
Diff: main.cpp
- Revision:
- 135:79885a39c161
- Parent:
- 134:32e808423e70
- Child:
- 136:7e66fc71af40
--- a/main.cpp Tue Oct 06 05:25:47 2020 +0000 +++ b/main.cpp Tue Oct 06 11:17:12 2020 +0000 @@ -1583,7 +1583,8 @@ } } float tau = 0.01f; - float K_valve = 0.00004f; +// float K_valve = 0.00004f; + float K_valve = 0.4f; float x_v = 0.0f; //x_v : -1~1 if(value>=VALVE_CENTER) { @@ -1615,9 +1616,7 @@ V_out = (-f4 + x_4_des_dot - k4*(x_v-x_4_des)- rho3/rho4*gamma_hat*g3_prime*torq.err)/g4; - - /* - + /* double torq_ref = 0.0f; pos.err = (pos.ref - pos.sen)/(float)(ENC_PULSE_PER_POSITION); //[mm] vel.err = (0.0f - vel.sen)/(float)(ENC_PULSE_PER_POSITION); //[mm/s] @@ -1834,13 +1833,17 @@ } else { //////////////////////////sw valve // Output Voltage Linearization - double CUR_PWM_nonlin = V_out; // Unit : mV - double CUR_PWM_lin = PWM_duty_byLT(CUR_PWM_nonlin); // -8000~8000 +// double CUR_PWM_nonlin = V_out; // Unit : mV +// double CUR_PWM_lin = PWM_duty_byLT(CUR_PWM_nonlin); // -8000~8000 // Dead Zone Cancellation (Electrical dead-zone) - if (CUR_PWM_lin > 0) V_out = (float) (CUR_PWM_lin + 169.0f); - else if (CUR_PWM_lin < 0) V_out = (float) (CUR_PWM_lin - 174.0f); - else V_out = (float) (CUR_PWM_lin); +// if (CUR_PWM_lin > 0) V_out = (float) (CUR_PWM_lin + 169.0f); +// else if (CUR_PWM_lin < 0) V_out = (float) (CUR_PWM_lin - 174.0f); +// else V_out = (float) (CUR_PWM_lin); + + if (V_out > 0 ) V_out = (V_out + 180.0f)/0.8588f; + else if (V_out < 0) V_out = (V_out - 200.0f)/0.8651f; + else V_out = 0.0f; } // if(V_out > 0.0f) V_out = (float) (V_out + 169.0f);