![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
LIGHT2
Diff: CAN/function_CAN.cpp
- Revision:
- 252:a08f301231f1
- Parent:
- 251:91d3ec3a087e
--- a/CAN/function_CAN.cpp Fri Jul 01 05:37:08 2022 +0000 +++ b/CAN/function_CAN.cpp Wed Jul 06 08:08:15 2022 +0000 @@ -727,21 +727,23 @@ int16_t temp_ref_valve_pos = (int16_t) (msg.data[0] | msg.data[1] << 8); if (((OPERATING_MODE&0b110)>>1) == 0) { //Moog Valve - valve_pos.ref = (double) temp_ref_valve_pos; // Unit : pulse (0~10000) + valve_pos.ref = (float) temp_ref_valve_pos; // Unit : pulse (0~10000) } else if (((OPERATING_MODE&0b110)>>1) == 1) { //KNR Valve - valve_pos.ref = (double) temp_ref_valve_pos; // Unit : pulse (0~30000) + valve_pos.ref = (float) temp_ref_valve_pos; // Unit : pulse (0~30000) } else { //SW Valve - if(temp_ref_valve_pos >= 0) { - valve_pos.ref = (double)VALVE_DEADZONE_PLUS + (double)temp_ref_valve_pos * ((double)VALVE_MAX_POS-(double)VALVE_DEADZONE_PLUS)/10000.0f; -// valve_pos.ref = (double)temp_ref_valve_pos; + if(temp_ref_valve_pos == 0) { + valve_pos.ref = ((float)VALVE_DEADZONE_PLUS + (float)VALVE_DEADZONE_MINUS) * 0.5f; + } else if(temp_ref_valve_pos> 0) { + valve_pos.ref = (float)VALVE_DEADZONE_PLUS + (float)temp_ref_valve_pos * ((float)VALVE_MAX_POS-(float)VALVE_DEADZONE_PLUS)/10000.0f; +// valve_pos.ref = (float)temp_ref_valve_pos; } else { - valve_pos.ref = (double)VALVE_DEADZONE_MINUS - (double)temp_ref_valve_pos * ((double)VALVE_MIN_POS-(double)VALVE_DEADZONE_MINUS)/10000.0f; -// valve_pos.ref = (double)temp_ref_valve_pos; + valve_pos.ref = (float)VALVE_DEADZONE_MINUS - (float)temp_ref_valve_pos * ((float)VALVE_MIN_POS-(float)VALVE_DEADZONE_MINUS)/10000.0f; +// valve_pos.ref = (float)temp_ref_valve_pos; } } } else if(address==CID_RX_REF_PWM) { int temp_ref_pwm = (int16_t) (msg.data[0] | msg.data[1] << 8); - Vout.ref = (double) temp_ref_pwm; + Vout.ref = (float) temp_ref_pwm; } }