From d571620ad8462a80672f62662194ead4f3839c1f Mon Sep 17 00:00:00 2001 From: "David J. Fiddes" Date: Fri, 16 Aug 2024 13:04:42 +0100 Subject: [PATCH] Decode oil pump temp, voltage and current status Lots of fields had the same value after an overnight cold soak with a 40 degree offset from the drive-unit case temp. Running the pump causes some temps to increase but other stay the same. Supply voltage and current tested with a bench power supply. Values track measured values quite accurately. --- OilPumpController/OilPumpController.ino | 58 +++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/OilPumpController/OilPumpController.ino b/OilPumpController/OilPumpController.ino index 9488f94..7729296 100644 --- a/OilPumpController/OilPumpController.ino +++ b/OilPumpController/OilPumpController.ino @@ -42,6 +42,10 @@ static const PumpMessages AllPumpMessages[] = { PumpMessages::Command, typedef std::array MessageData; +// Pump temperatures seem to be offset by 40 degrees Celsius +// This makes sense given typical automotive temp ranges +static const int8_t TempOffset = 40; + static void PrintError(LIN_Master::error_t error) { if (error == LIN_Master::NO_ERROR) @@ -65,11 +69,57 @@ static void PrintError(LIN_Master::error_t error) Serial.print("misc "); } -static void PrintMessage(const MessageData& data) +static void PrintMessage(PumpMessages id, const MessageData& data) { - for (auto b : data) + switch (id) { - Serial.printf("%#.2x ", b); + case PumpMessages::Command: + break; + + case PumpMessages::Status1: + Serial.printf("%#.2x ", data[0]); + Serial.printf("%#.2x ", data[1]); + Serial.printf("%#.2x ", data[2]); + Serial.printf("Temp1: %d ", data[3] - TempOffset); + Serial.printf("%#.2x ", data[4]); + Serial.printf("Temp2: %d ", data[5] - TempOffset); + Serial.printf("%#.2x ", data[6]); + Serial.printf("%#.2x ", data[7]); + break; + + case PumpMessages::Status2: + Serial.printf("%#.2x ", data[0]); + Serial.printf("%#.2x ", data[1]); + Serial.printf("%#.2x ", data[2]); + Serial.printf("%#.2x ", data[3]); + Serial.printf("%#.2x ", data[4]); + Serial.printf("%#.2x ", data[5]); + Serial.printf("%#.2x ", data[6]); + Serial.printf("%#.2x ", data[7]); + break; + + case PumpMessages::Status3: + Serial.printf("Supply: %.1f [V] ", data[0] * 0.1); + Serial.printf("%#.2x ", data[1]); + Serial.printf("%#.2x ", data[2]); + Serial.printf("%#.2x ", data[3]); + Serial.printf("%#.2x ", data[4]); + ; + Serial.printf("%#.2x ", data[5]); + Serial.printf("%#.2x ", data[6]); + Serial.printf("%#.2x ", data[7]); + break; + + case PumpMessages::Status4: + Serial.printf("%#.2x ", data[0]); + Serial.printf("Current: %.1f [A] ", data[1] * 0.1); + Serial.printf("%#.2x ", data[2]); + Serial.printf("Temp3: %d ", data[3] - TempOffset); + Serial.printf("Temp4: %d ", data[4] - TempOffset); + Serial.printf("Temp5: %d ", data[5] - TempOffset); + Serial.printf("Temp6: %d ", data[6] - TempOffset); + Serial.printf("%#.2x ", data[7]); + break; } } @@ -148,7 +198,7 @@ void loop() } else { - PrintMessage(data); + PrintMessage(id, data); } }