Sungwoo Kim
/
HydraulicControlBoard_PostLIGHT_210420
LIGHT2
Diff: CAN/function_CAN.cpp
- Revision:
- 249:544011ad9c85
- Parent:
- 248:bfdf0f479a38
- Child:
- 251:91d3ec3a087e
diff -r bfdf0f479a38 -r 544011ad9c85 CAN/function_CAN.cpp --- a/CAN/function_CAN.cpp Fri Jun 24 00:18:20 2022 +0000 +++ b/CAN/function_CAN.cpp Fri Jun 24 05:55:29 2022 +0000 @@ -732,11 +732,11 @@ valve_pos.ref = (double) temp_ref_valve_pos; // Unit : pulse (0~30000) } else { //SW Valve if(temp_ref_valve_pos >= 0) { -// valve_pos.ref = (double)VALVE_ELECTRIC_CENTER + (double)temp_ref_valve_pos * ((double)VALVE_MAX_POS-(double)VALVE_ELECTRIC_CENTER)/10000.0f; - valve_pos.ref = (double)temp_ref_valve_pos; // -10000~10000 + valve_pos.ref = (double)VALVE_ELECTRIC_CENTER + (double)temp_ref_valve_pos * ((double)VALVE_MAX_POS-(double)VALVE_ELECTRIC_CENTER)/10000.0f; +// valve_pos.ref = (double)temp_ref_valve_pos; } else { -// valve_pos.ref = (double)VALVE_ELECTRIC_CENTER - (double)temp_ref_valve_pos * ((double)VALVE_MIN_POS-(double)VALVE_ELECTRIC_CENTER)/10000.0f; - valve_pos.ref = (double)temp_ref_valve_pos; // -10000~10000 + valve_pos.ref = (double)VALVE_ELECTRIC_CENTER - (double)temp_ref_valve_pos * ((double)VALVE_MIN_POS-(double)VALVE_ELECTRIC_CENTER)/10000.0f; +// valve_pos.ref = (double)temp_ref_valve_pos; } } } else if(address==CID_RX_REF_PWM) { @@ -1089,8 +1089,8 @@ CANMessage temp_msg; int16_t temp_valve_min_pos = 0; int16_t temp_valve_max_pos = 0; - temp_valve_min_pos = (int16_t) ((float) VALVE_MIN_POS * 0.1f); - temp_valve_max_pos = (int16_t) ((float) VALVE_MAX_POS * 0.1f); + temp_valve_min_pos = (int16_t) VALVE_MIN_POS; + temp_valve_max_pos = (int16_t) VALVE_MAX_POS; temp_msg.id = CID_TX_INFO; temp_msg.len = 5; @@ -1246,9 +1246,9 @@ int16_t valve_pos_vs_pwm; if(VALVE_POS_VS_PWM[canindex]>= (float) VALVE_ELECTRIC_CENTER) { - valve_pos_vs_pwm = 10000.0f*((double)VALVE_POS_VS_PWM[canindex]-(double)VALVE_ELECTRIC_CENTER)/((double)VALVE_MAX_POS-(double)VALVE_ELECTRIC_CENTER); + valve_pos_vs_pwm = (int16_t) (10000.0f*((float)VALVE_POS_VS_PWM[canindex]-(float)VALVE_ELECTRIC_CENTER)/((float)VALVE_MAX_POS-(float)VALVE_ELECTRIC_CENTER)); } else { - valve_pos_vs_pwm = -10000.0f*((double)VALVE_POS_VS_PWM[canindex]-(double)VALVE_ELECTRIC_CENTER)/((double)VALVE_MIN_POS-(double)VALVE_ELECTRIC_CENTER); + valve_pos_vs_pwm = (int16_t) (-10000.0f*((float)VALVE_POS_VS_PWM[canindex]-(float)VALVE_ELECTRIC_CENTER)/((float)VALVE_MIN_POS-(float)VALVE_ELECTRIC_CENTER)); } int16_t PWM_VALVE_ID;