Fix calculation on PIDs

This commit is contained in:
Carsten Schmiemann 2022-04-14 22:54:52 +02:00
parent 81319297ec
commit 3aae5c16a8

View file

@ -245,24 +245,24 @@ void OvmsVehicleRenaultZoePh2::IncomingPollReply(canbus* bus, uint16_t type, uin
void OvmsVehicleRenaultZoePh2::IncomingINV(uint16_t type, uint16_t pid, const char* data, uint16_t len) { void OvmsVehicleRenaultZoePh2::IncomingINV(uint16_t type, uint16_t pid, const char* data, uint16_t len) {
switch (pid) { switch (pid) {
case 0x700C: { // Inverter temperature case 0x700C: { // Inverter temperature
StandardMetrics.ms_v_inv_temp->SetValue(float((CAN_UINT(0) - 40) * 0.1953125), Celcius); StandardMetrics.ms_v_inv_temp->SetValue(float((CAN_UINT(0) * 0.1953125) - 40), Celcius);
ESP_LOGD(TAG, "700C INV ms_v_inv_temp: %f", float((CAN_UINT(0) - 40) * 0.1953125)); ESP_LOGD(TAG, "700C INV ms_v_inv_temp: %f", float((CAN_UINT(0) * 0.1953125) - 40));
break; break;
} }
case 0x700F: { // Motor, Stator1 temperature case 0x700F: { // Motor, Stator1 temperature
StandardMetrics.ms_v_mot_temp->SetValue(float((CAN_UINT(0) - 40) * 0.1953125), Celcius); StandardMetrics.ms_v_mot_temp->SetValue(float((CAN_UINT(0) * 0.1953125) - 40), Celcius);
mt_mot_temp_stator1->SetValue(float((CAN_UINT(0) - 40)), Celcius); mt_mot_temp_stator1->SetValue(float((CAN_UINT(0) * 0.1953125) - 40), Celcius);
ESP_LOGD(TAG, "700F INV ms_v_mot_temp: %f", float((CAN_UINT(0) - 40) * 0.1953125)); ESP_LOGD(TAG, "700F INV ms_v_mot_temp: %f", float((CAN_UINT(0) * 0.1953125) - 40));
break; break;
} }
case 0x7010: { // Stator 2 temperature case 0x7010: { // Stator 2 temperature
mt_mot_temp_stator2->SetValue(float((CAN_UINT(0) - 40) * 0.1953125), Celcius); mt_mot_temp_stator2->SetValue(float((CAN_UINT(0) * 0.1953125) - 40), Celcius);
ESP_LOGD(TAG, "7010 INV mt_mot_temp_stator2: %f", float((CAN_UINT(0) - 40) * 0.1953125)); ESP_LOGD(TAG, "7010 INV mt_mot_temp_stator2: %f", float((CAN_UINT(0) * 0.1953125) - 40));
break; break;
} }
case 0x2001: { // Motor rpm case 0x2001: { // Motor rpm
StandardMetrics.ms_v_mot_rpm->SetValue(float(CAN_UINT(0) - 16000) * 0.5); StandardMetrics.ms_v_mot_rpm->SetValue(float(CAN_UINT(0) / 2) - 16000);
ESP_LOGD(TAG, "2001 INV ms_v_mot_rpm: %f", float(CAN_UINT(0) - 16000) * 0.5); ESP_LOGD(TAG, "2001 INV ms_v_mot_rpm: %f", float(CAN_UINT(0) / 2) - 16000);
break; break;
} }
case 0x2004: { // Battery voltage sense case 0x2004: { // Battery voltage sense
@ -272,8 +272,8 @@ void OvmsVehicleRenaultZoePh2::IncomingINV(uint16_t type, uint16_t pid, const ch
break; break;
} }
case 0x7049: { // Battery current sense case 0x7049: { // Battery current sense
mt_inv_hv_current->SetValue(float((CAN_UINT(0) - 500) * 0.003125), Amps); mt_inv_hv_current->SetValue(float((CAN_UINT(0) * 0.003125) - 500), Amps);
ESP_LOGD(TAG, "7049 INV mt_inv_hv_current: %f", float(CAN_UINT(0) - 500) * 0.003125); ESP_LOGD(TAG, "7049 INV mt_inv_hv_current: %f", float(CAN_UINT(0) * 0.003125) - 500);
StandardMetrics.ms_v_inv_power->SetValue(float (mt_inv_hv_current->AsFloat() * mt_inv_hv_voltage->AsFloat() / 1000)); StandardMetrics.ms_v_inv_power->SetValue(float (mt_inv_hv_current->AsFloat() * mt_inv_hv_voltage->AsFloat() / 1000));
break; break;
} }
@ -408,9 +408,9 @@ void OvmsVehicleRenaultZoePh2::IncomingLBC(uint16_t type, uint16_t pid, const ch
break; break;
} }
case 0x925D: { //Battery current case 0x925D: { //Battery current
StandardMetrics.ms_v_bat_current->SetValue((float) ((CAN_UINT(0) - 1020) * 0.03125), Amps); StandardMetrics.ms_v_bat_current->SetValue((float) ((CAN_UINT(4) - 1020) * 0.03125), Amps);
ESP_LOGD(TAG, "925D LBC ms_v_bat_current: %d", CAN_UINT(0)); ESP_LOGD(TAG, "925D LBC ms_v_bat_current: %d", CAN_UINT(4));
ESP_LOGD(TAG, "925D LBC ms_v_bat_current: %f", ((CAN_UINT(0) - 1020) * 0.03125)); ESP_LOGD(TAG, "925D LBC ms_v_bat_current: %f", ((CAN_UINT(4) - 1020) * 0.03125));
break; break;
} }
case 0x9012: { //Battery average temperature case 0x9012: { //Battery average temperature