Sungwoo Kim
/
HydraulicControlBoard_LIGHT
For LIGHT
Diff: CAN/function_CAN.cpp
- Revision:
- 30:8d561f16383b
- Parent:
- 28:2a62d73e3dd0
- Child:
- 32:4b8c0fedaf2c
diff -r 69f3f5445d6d -r 8d561f16383b CAN/function_CAN.cpp --- a/CAN/function_CAN.cpp Wed Oct 02 04:41:59 2019 +0000 +++ b/CAN/function_CAN.cpp Fri Oct 04 11:58:18 2019 +0000 @@ -203,7 +203,7 @@ } case CRX_SET_VOLTAGE_SUPPLY: { - SUPPLY_VOLTAGE = (double) ((int16_t) (msg.data[1] | msg.data[2] << 8)) / 10.; + SUPPLY_VOLTAGE = (double) ((int16_t) (msg.data[1] | msg.data[2] << 8)) / 10.0f; ROM_RESET_DATA(); @@ -219,7 +219,7 @@ } case CRX_SET_VOLTAGE_VALVE: { - VALVE_VOLTAGE_LIMIT = (double) ((int16_t) (msg.data[1] | msg.data[2] << 8)) / 10.0; + VALVE_VOLTAGE_LIMIT = (double) ((int16_t) (msg.data[1] | msg.data[2] << 8)) / 10.0f; ROM_RESET_DATA(); @@ -499,8 +499,8 @@ } case CRX_SET_PRES_SENSOR_PULSE_PER_PRES: { - PRES_SENSOR_A_PULSE_PER_BAR = (double) ((int16_t) (msg.data[1] | msg.data[2] << 8)) * 0.01; - PRES_SENSOR_B_PULSE_PER_BAR = (double) ((int16_t) (msg.data[3] | msg.data[4] << 8)) * 0.01; + PRES_SENSOR_A_PULSE_PER_BAR = (double) ((int16_t) (msg.data[1] | msg.data[2] << 8)) * 0.01f; + PRES_SENSOR_B_PULSE_PER_BAR = (double) ((int16_t) (msg.data[3] | msg.data[4] << 8)) * 0.01f; ROM_RESET_DATA(); //spi_eeprom_write(RID_PRES_SENSOR_A_PULSE_PER_BAR, (int16_t) (PRES_SENSOR_A_PULSE_PER_BAR * 100.)); //(RID_PRES_SENSOR_B_PULSE_PER_BAR, (int16_t) (PRES_SENSOR_B_PULSE_PER_BAR * 100.)); @@ -515,7 +515,7 @@ } case CRX_SET_FRICTION: { - FRICTION = (double) ((int16_t) (msg.data[1] | msg.data[2] << 8)) / 10.; + FRICTION = (double) ((int16_t) (msg.data[1] | msg.data[2] << 8)) / 10.0f; ROM_RESET_DATA(); //spi_eeprom_write(RID_FRICTION, (int16_t) (FRICTION * 10.)); @@ -528,17 +528,17 @@ break; } case CRX_SET_VALVE_GAIN_PLUS: { - VALVE_GAIN_LPM_PER_V[0] = (double) msg.data[1] / 50.0; - VALVE_GAIN_LPM_PER_V[2] = (double) msg.data[2] / 50.0; - VALVE_GAIN_LPM_PER_V[4] = (double) msg.data[3] / 50.0; - VALVE_GAIN_LPM_PER_V[6] = (double) msg.data[4] / 50.0; - VALVE_GAIN_LPM_PER_V[8] = (double) msg.data[5] / 50.0; + VALVE_GAIN_LPM_PER_V[0] = (double) msg.data[1] / 50.0f; + VALVE_GAIN_LPM_PER_V[2] = (double) msg.data[2] / 50.0f; + VALVE_GAIN_LPM_PER_V[4] = (double) msg.data[3] / 50.0f; + VALVE_GAIN_LPM_PER_V[6] = (double) msg.data[4] / 50.0f; + VALVE_GAIN_LPM_PER_V[8] = (double) msg.data[5] / 50.0f; ROM_RESET_DATA(); - //spi_eeprom_write(RID_VALVE_GAIN_PLUS_1, (int16_t) (VALVE_GAIN_LPM_PER_V[0] * 100.)); - //spi_eeprom_write(RID_VALVE_GAIN_PLUS_2, (int16_t) (VALVE_GAIN_LPM_PER_V[2] * 100.)); - //spi_eeprom_write(RID_VALVE_GAIN_PLUS_3, (int16_t) (VALVE_GAIN_LPM_PER_V[4] * 100.)); - //spi_eeprom_write(RID_VALVE_GAIN_PLUS_4, (int16_t) (VALVE_GAIN_LPM_PER_V[6] * 100.)); - //spi_eeprom_write(RID_VALVE_GAIN_PLUS_5, (int16_t) (VALVE_GAIN_LPM_PER_V[8] * 100.)); + //spi_eeprom_write(RID_VALVE_GAIN_PLUS_1, (int16_t) (VALVE_GAIN_LPM_PER_V[0] * 100.0f)); + //spi_eeprom_write(RID_VALVE_GAIN_PLUS_2, (int16_t) (VALVE_GAIN_LPM_PER_V[2] * 100.0f)); + //spi_eeprom_write(RID_VALVE_GAIN_PLUS_3, (int16_t) (VALVE_GAIN_LPM_PER_V[4] * 100.0f)); + //spi_eeprom_write(RID_VALVE_GAIN_PLUS_4, (int16_t) (VALVE_GAIN_LPM_PER_V[6] * 100.0f)); + //spi_eeprom_write(RID_VALVE_GAIN_PLUS_5, (int16_t) (VALVE_GAIN_LPM_PER_V[8] * 100.0f)); break; } @@ -549,17 +549,17 @@ break; } case CRX_SET_VALVE_GAIN_MINUS: { - VALVE_GAIN_LPM_PER_V[1] = (double) msg.data[1] / 50.0; - VALVE_GAIN_LPM_PER_V[3] = (double) msg.data[2] / 50.0; - VALVE_GAIN_LPM_PER_V[5] = (double) msg.data[3] / 50.0; - VALVE_GAIN_LPM_PER_V[7] = (double) msg.data[4] / 50.0; - VALVE_GAIN_LPM_PER_V[9] = (double) msg.data[5] / 50.0; + VALVE_GAIN_LPM_PER_V[1] = (double) msg.data[1] / 50.0f; + VALVE_GAIN_LPM_PER_V[3] = (double) msg.data[2] / 50.0f; + VALVE_GAIN_LPM_PER_V[5] = (double) msg.data[3] / 50.0f; + VALVE_GAIN_LPM_PER_V[7] = (double) msg.data[4] / 50.0f; + VALVE_GAIN_LPM_PER_V[9] = (double) msg.data[5] / 50.0f; ROM_RESET_DATA(); - //spi_eeprom_write(RID_VALVE_GAIN_MINUS_1, (int16_t) (VALVE_GAIN_LPM_PER_V[1] * 100.)); - //spi_eeprom_write(RID_VALVE_GAIN_MINUS_2, (int16_t) (VALVE_GAIN_LPM_PER_V[3] * 100.)); - //spi_eeprom_write(RID_VALVE_GAIN_MINUS_3, (int16_t) (VALVE_GAIN_LPM_PER_V[5] * 100.)); - //spi_eeprom_write(RID_VALVE_GAIN_MINUS_4, (int16_t) (VALVE_GAIN_LPM_PER_V[7] * 100.)); - //(RID_VALVE_GAIN_MINUS_5, (int16_t) (VALVE_GAIN_LPM_PER_V[9] * 100.)); + //spi_eeprom_write(RID_VALVE_GAIN_MINUS_1, (int16_t) (VALVE_GAIN_LPM_PER_V[1] * 100.0f)); + //spi_eeprom_write(RID_VALVE_GAIN_MINUS_2, (int16_t) (VALVE_GAIN_LPM_PER_V[3] * 100.0f)); + //spi_eeprom_write(RID_VALVE_GAIN_MINUS_3, (int16_t) (VALVE_GAIN_LPM_PER_V[5] * 100.0f)); + //spi_eeprom_write(RID_VALVE_GAIN_MINUS_4, (int16_t) (VALVE_GAIN_LPM_PER_V[7] * 100.0f)); + //(RID_VALVE_GAIN_MINUS_5, (int16_t) (VALVE_GAIN_LPM_PER_V[9] * 100.0f)); break; } @@ -572,10 +572,10 @@ REFERENCE_MODE = msg.data[1]; REF_NUM = msg.data[2]; - REF_PERIOD = (double) ((int16_t) (msg.data[3] | msg.data[4] << 8)) / 100.; - if (REF_PERIOD <= 0.) REF_MOVE_TIME_5k = TMR_FREQ_5k / CAN_FREQ; + REF_PERIOD = (double) ((int16_t) (msg.data[3] | msg.data[4] << 8)) / 100.0f; + if (REF_PERIOD <= 0.0f) REF_MOVE_TIME_5k = TMR_FREQ_5k / CAN_FREQ; else REF_MOVE_TIME_5k = (int) (REF_PERIOD * (double) TMR_FREQ_5k); - REF_MAG = (double) ((int16_t) (msg.data[5] | msg.data[6] << 8)) / 100.; + REF_MAG = (double) ((int16_t) (msg.data[5] | msg.data[6] << 8)) / 100.0f; break; } @@ -815,9 +815,9 @@ int16_t sendPgain=0, sendIgain=0, sendDgain=0; if (t_type == 0) { -// sendPgain = (int16_t) (P_GAIN_VALVE_POSITION); -// sendIgain = (int16_t) (I_GAIN_VALVE_POSITION); -// sendDgain = (int16_t) (D_GAIN_VALVE_POSITION); + sendPgain = (int16_t) (P_GAIN_VALVE_POSITION); + sendIgain = (int16_t) (I_GAIN_VALVE_POSITION); + sendDgain = (int16_t) (D_GAIN_VALVE_POSITION); } else if (t_type == 1) { sendPgain = (int16_t) (P_GAIN_JOINT_POSITION); sendIgain = (int16_t) (I_GAIN_JOINT_POSITION); @@ -1021,10 +1021,10 @@ temp_msg.id = CID_TX_INFO; temp_msg.len = 5; temp_msg.data[0] = (uint8_t) CTX_SEND_PRES_SENSOR_PULSE_PER_BAR; - temp_msg.data[1] = (uint8_t) (int) (PRES_SENSOR_A_PULSE_PER_BAR * 100.); - temp_msg.data[2] = (uint8_t) ((int) (PRES_SENSOR_A_PULSE_PER_BAR * 100.) >> 8); - temp_msg.data[3] = (uint8_t) (int) (PRES_SENSOR_B_PULSE_PER_BAR * 100.); - temp_msg.data[4] = (uint8_t) ((int) (PRES_SENSOR_B_PULSE_PER_BAR * 100.) >> 8); + temp_msg.data[1] = (uint8_t) (int) (PRES_SENSOR_A_PULSE_PER_BAR * 100.0f); + temp_msg.data[2] = (uint8_t) ((int) (PRES_SENSOR_A_PULSE_PER_BAR * 100.0f) >> 8); + temp_msg.data[3] = (uint8_t) (int) (PRES_SENSOR_B_PULSE_PER_BAR * 100.0f); + temp_msg.data[4] = (uint8_t) ((int) (PRES_SENSOR_B_PULSE_PER_BAR * 100.0f) >> 8); can.write(temp_msg); } @@ -1032,7 +1032,7 @@ void CAN_TX_FRICTION(void) { CANMessage temp_msg; int16_t send_friction; - send_friction = (int16_t) (FRICTION * 10.); + send_friction = (int16_t) (FRICTION * 10.0f); temp_msg.id = CID_TX_INFO; temp_msg.len = 3; @@ -1049,11 +1049,11 @@ temp_msg.id = CID_TX_INFO; temp_msg.len = 6; temp_msg.data[0] = (uint8_t) CTX_SEND_VALVE_GAIN_PLUS; - temp_msg.data[1] = (uint8_t) (VALVE_GAIN_LPM_PER_V[0] * 50.); - temp_msg.data[2] = (uint8_t) (VALVE_GAIN_LPM_PER_V[2] * 50.); - temp_msg.data[3] = (uint8_t) (VALVE_GAIN_LPM_PER_V[4] * 50.); - temp_msg.data[4] = (uint8_t) (VALVE_GAIN_LPM_PER_V[6] * 50.); - temp_msg.data[5] = (uint8_t) (VALVE_GAIN_LPM_PER_V[8] * 50.); + temp_msg.data[1] = (uint8_t) (VALVE_GAIN_LPM_PER_V[0] * 50.0f); + temp_msg.data[2] = (uint8_t) (VALVE_GAIN_LPM_PER_V[2] * 50.0f); + temp_msg.data[3] = (uint8_t) (VALVE_GAIN_LPM_PER_V[4] * 50.0f); + temp_msg.data[4] = (uint8_t) (VALVE_GAIN_LPM_PER_V[6] * 50.0f); + temp_msg.data[5] = (uint8_t) (VALVE_GAIN_LPM_PER_V[8] * 50.0f); can.write(temp_msg); } @@ -1080,11 +1080,11 @@ temp_msg.id = CID_TX_INFO; temp_msg.len = 6; temp_msg.data[0] = (uint8_t) CTX_SEND_VALVE_GAIN_MINUS; - temp_msg.data[1] = (uint8_t) (VALVE_GAIN_LPM_PER_V[1] * 50.); - temp_msg.data[2] = (uint8_t) (VALVE_GAIN_LPM_PER_V[3] * 50.); - temp_msg.data[3] = (uint8_t) (VALVE_GAIN_LPM_PER_V[5] * 50.); - temp_msg.data[4] = (uint8_t) (VALVE_GAIN_LPM_PER_V[7] * 50.); - temp_msg.data[5] = (uint8_t) (VALVE_GAIN_LPM_PER_V[9] * 50.); + temp_msg.data[1] = (uint8_t) (VALVE_GAIN_LPM_PER_V[1] * 50.0f); + temp_msg.data[2] = (uint8_t) (VALVE_GAIN_LPM_PER_V[3] * 50.0f); + temp_msg.data[3] = (uint8_t) (VALVE_GAIN_LPM_PER_V[5] * 50.0f); + temp_msg.data[4] = (uint8_t) (VALVE_GAIN_LPM_PER_V[7] * 50.0f); + temp_msg.data[5] = (uint8_t) (VALVE_GAIN_LPM_PER_V[9] * 50.0f); can.write(temp_msg); } @@ -1096,10 +1096,10 @@ temp_msg.len = 6; temp_msg.data[0] = (uint8_t) CTX_SEND_REFENCE_MODE; temp_msg.data[1] = (uint8_t) REFERENCE_MODE; - temp_msg.data[2] = (uint8_t) (int) (REFERENCE_FREQ * 100.); - temp_msg.data[3] = (uint8_t) ((int) (REFERENCE_FREQ * 100.) >> 8); - temp_msg.data[4] = (uint8_t) (int) (REFERENCE_MAG * 100.); - temp_msg.data[5] = (uint8_t) ((int) (REFERENCE_MAG * 100.) >> 8); + temp_msg.data[2] = (uint8_t) (int) (REFERENCE_FREQ * 100.0f); + temp_msg.data[3] = (uint8_t) ((int) (REFERENCE_FREQ * 100.0f) >> 8); + temp_msg.data[4] = (uint8_t) (int) (REFERENCE_MAG * 100.0f); + temp_msg.data[5] = (uint8_t) ((int) (REFERENCE_MAG * 100.0f) >> 8); can.write(temp_msg); }