Sungwoo Kim
/
HydraulicControlBoard_Rainbow_v1_2_
rainbow
Diff: CAN/function_CAN.cpp
- Revision:
- 238:4e660aa77eb7
- Parent:
- 237:c2cfe349f5c1
- Child:
- 240:fb5b57e3f157
diff -r c2cfe349f5c1 -r 4e660aa77eb7 CAN/function_CAN.cpp --- a/CAN/function_CAN.cpp Wed Jul 07 10:09:21 2021 +0000 +++ b/CAN/function_CAN.cpp Tue Jul 13 01:40:56 2021 +0000 @@ -355,17 +355,17 @@ break; } - case CRX_ASK_COMPLIANCE_GAIN: { - CAN_TX_COMPLIANCE_GAIN(); + case CRX_ASK_VALVE_ELECTRIC_CENTER: { + CAN_TX_VALVE_ELECTRIC_CENTER(); break; } - case CRX_SET_COMPLIANCE_GAIN: { - COMPLIANCE_GAIN = (int16_t) (msg.data[1] | msg.data[2] << 8); + case CRX_SET_VALVE_ELECTRIC_CENTER: { + VALVE_ELECTRIC_CENTER = (int16_t) (msg.data[1] | msg.data[2] << 8); - spi_eeprom_write(RID_COMPLIANCE_GAIN, (int16_t) COMPLIANCE_GAIN); + spi_eeprom_write(RID_VALVE_ELECTRIC_CENTER, (int16_t) VALVE_ELECTRIC_CENTER); break; } @@ -736,9 +736,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)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 } 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)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 } } } else if(address==CID_RX_REF_PWM) { @@ -974,15 +976,15 @@ can.write(temp_msg); } -void CAN_TX_COMPLIANCE_GAIN(void) +void CAN_TX_VALVE_ELECTRIC_CENTER(void) { CANMessage temp_msg; temp_msg.id = CID_TX_INFO; temp_msg.len = 3; - temp_msg.data[0] = (uint8_t) CTX_SEND_COMPLIANCE_GAIN; - temp_msg.data[1] = (uint8_t) COMPLIANCE_GAIN; - temp_msg.data[2] = (uint8_t) (COMPLIANCE_GAIN >> 8); + temp_msg.data[0] = (uint8_t) CTX_SEND_VALVE_ELECTRIC_CENTER; + temp_msg.data[1] = (uint8_t) VALVE_ELECTRIC_CENTER; + temp_msg.data[2] = (uint8_t) (VALVE_ELECTRIC_CENTER >> 8); can.write(temp_msg); }