-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'Heater-Update-12-2024' into Developmental_NOT_VEHICLE
- Loading branch information
Showing
9 changed files
with
314 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* This file is part of the Zombieverter VCU project. | ||
* | ||
* Copyright (C) 2018 Johannes Huebner <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#ifndef MGCOOLANTHEATER_H | ||
#define MGCOOLANTHEATER_H | ||
|
||
//#include <libopencm3/stm32/usart.h> | ||
#include <heater.h> | ||
|
||
|
||
class mgCoolantHeater : public Heater | ||
{ | ||
public: | ||
void SetTargetTemperature(float temp); | ||
void SetCanInterface(CanHardware* c); | ||
void DecodeCAN(int id, uint32_t data[2]); | ||
void SetPower(uint16_t power, bool HeatReq); | ||
void Task100Ms(); | ||
|
||
private: | ||
int8_t currentTemperature; | ||
int8_t desiredTemperature; | ||
|
||
bool shouldHeat; | ||
static void handle2B5(uint32_t data[2]); | ||
static void handle2B6(uint32_t data[2]); | ||
|
||
}; | ||
|
||
#endif // MGCOOLANTHEATER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* This file is part of the Zombieverter VCU project. | ||
* | ||
* Copyright (C) 2024 Tom de Bree <[email protected]> | ||
* Copyright (C) 2018 Johannes Huebner <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* Controls the VW LIN based heater as : https://openinverter.org/wiki/Volkswagen_Heater | ||
*/ | ||
#ifndef VWAIRHEATER_H | ||
#define VWAIRTHEATER_H | ||
|
||
//#include <libopencm3/stm32/usart.h> | ||
#include <heater.h> | ||
#include "linbus.h" | ||
|
||
|
||
class vwAirHeater : public Heater | ||
{ | ||
public: | ||
void SetTargetTemperature(float temp) { (void)temp; } //Not supported (yet)? | ||
void SetPower(uint16_t power, bool HeatReq); | ||
void SetLinInterface(LinBus* l); | ||
|
||
private: | ||
bool isAwake=false; | ||
LinBus* lin; | ||
}; | ||
|
||
#endif // VWAirHEATER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* | ||
* This file is part of the Zombieverter VCU project. | ||
* | ||
* Copyright (C) 2018 Johannes Huebner <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* Controls the MG heater as : https://openinverter.org/wiki/MG_Coolant_Heater | ||
* | ||
* Based on reverse engineer work by Tom de Bree | ||
* | ||
*/ | ||
|
||
#include <MGCoolantHeater.h> | ||
|
||
static uint16_t HvVolt = 0; | ||
|
||
void mgCoolantHeater::SetPower(uint16_t power, bool HeatReq) | ||
{ | ||
shouldHeat = HeatReq; | ||
power = power;//mask warning | ||
} | ||
|
||
void mgCoolantHeater::SetCanInterface(CanHardware* c) | ||
{ | ||
|
||
can = c; | ||
can->RegisterUserMessage(0x2B5); | ||
can->RegisterUserMessage(0x2B6); | ||
} | ||
|
||
void mgCoolantHeater::Task100Ms() | ||
{ | ||
uint8_t bytes[8]; | ||
bytes[0] = 0x00; //No Power! | ||
bytes[1] = 0x00; //No Power! | ||
bytes[2] = 0x01; //Fixed | ||
bytes[3] = 0x00; //Fixed | ||
bytes[4] = 0x00; //Fixed | ||
bytes[5] = 0x60; //Fixed | ||
bytes[6] = 0x00; //Fixed | ||
bytes[7] = 0x00; //Fixed | ||
|
||
if (shouldHeat) | ||
{ | ||
bytes[0] = 0x04; //Max Power!!!! 0x04 gives 19A | ||
bytes[1] = 0x0F; //Max Power!!!! 0x0F gives 19A | ||
} | ||
else | ||
{ | ||
|
||
} | ||
|
||
can->Send(0x2A0, (uint32_t*)bytes, 8); | ||
} | ||
|
||
void mgCoolantHeater::SetTargetTemperature(float temp) | ||
{ | ||
desiredTemperature = temp; | ||
} | ||
|
||
void mgCoolantHeater::DecodeCAN(int id, uint32_t data[2]) | ||
{ | ||
switch (id) | ||
{ | ||
case 0x2B5: | ||
mgCoolantHeater::handle2B5(data); | ||
break; | ||
case 0x2B6: | ||
mgCoolantHeater::handle2B6(data); | ||
break; | ||
} | ||
} | ||
|
||
void mgCoolantHeater::handle2B5(uint32_t data[2]) | ||
{ | ||
uint8_t* bytes = (uint8_t*)data;// arrgghhh this converts the two 32bit array into bytes. See comments are useful:) | ||
|
||
uint8_t HvCur = bytes[4];//0.75A/1 | ||
|
||
Param::SetFloat(Param::powerheater,(HvVolt*HvCur*0.75)); | ||
} | ||
|
||
void mgCoolantHeater::handle2B6(uint32_t data[2]) | ||
{ | ||
uint8_t* bytes = (uint8_t*)data;// arrgghhh this converts the two 32bit array into bytes. See comments are useful:) | ||
|
||
uint8_t temp1 = bytes[6]; | ||
uint16_t temp2 = bytes[4]|((bytes[3] &0x0F)<<8); | ||
|
||
temp2 = temp2; //remove warning for unused variable | ||
|
||
HvVolt = bytes[2]; //tbc scaling | ||
|
||
Param::SetFloat(Param::tmpheater, temp1*0.75); //temp 1 appears to be scaled by 0.75C/1 | ||
|
||
|
||
Param::SetInt(Param::udcheater,HvVolt); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* This file is part of the Zombieverter VCU project. | ||
* | ||
* Copyright (C) 2024 Tom de Bree <[email protected]> | ||
* Copyright (C) 2018 Johannes Huebner <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* Controls the VW LIN based heater as : https://openinverter.org/wiki/VAG_PTC_Air_Heater | ||
* | ||
* Based on reverse engineer work by Tom de Bree | ||
* | ||
*/ | ||
|
||
#include <VWAirHeater.h> | ||
|
||
static uint8_t processedPower=0; | ||
static uint8_t TenCount=0; | ||
|
||
|
||
void vwAirHeater::SetLinInterface(LinBus* l) | ||
{ | ||
lin = l; | ||
DigIo::lin_wake.Clear();//Not used on TJA1027 | ||
DigIo::lin_nslp.Set();//Wakes the device | ||
|
||
} | ||
|
||
void vwAirHeater::SetPower(uint16_t power, bool HeatReq) | ||
{ | ||
TenCount++; | ||
if(TenCount==5)//slow down to 50ms as this is called in 10ms task. | ||
{ | ||
TenCount=0; | ||
HeatReq=HeatReq; | ||
//going to ignore heatreq here, already used to determine to run this sequence. | ||
|
||
if(power>=255) power = 255;//Constrain power to max for VW heater. | ||
processedPower=power;//10; | ||
|
||
static bool read = true; | ||
|
||
if (lin->HasReceived(19, 8))//0x13 hex address | ||
{ | ||
uint8_t* data = lin->GetReceivedBytes(); | ||
|
||
Param::SetFloat(Param::tmpheater, data[5]*0.25);//Looks like the temp feedback 1 | ||
Param::SetFloat(Param::udcheater, data[1]*2);//HV Voltage feedback | ||
Param::SetFloat(Param::powerheater,data[0]*data[1]);//HV current is Byte 0 in 0.5A per/1 and HV voltage is byte 1 2V/1 so they cancel | ||
} | ||
|
||
if (read) | ||
{ | ||
lin->Request(19, 0, 0);//0x13 hex address | ||
} | ||
|
||
else | ||
{ | ||
uint8_t PowReq = Param::GetInt(Param::HeatPercnt);//VW heater uses a % setting as opposed to a set power val. Regulates its temps to this. | ||
uint8_t lindata[8]; | ||
lindata[0] = 0x39; //fixed | ||
lindata[1] = 0xC5;//fixed | ||
lindata[2] = PowReq; //Left Request 0-100, tested even at 120 to confirm max values | ||
lindata[3] = PowReq; //Right Request 0-100, tested even at 120 to confirm max values | ||
lindata[4] = 0; //fixed | ||
lindata[5] = 0xAA; //fixed | ||
lindata[6] = 0x78; //Power Limit? 0x50 and 0x78 tested | ||
lindata[7] = 0; //fixed | ||
lin->Request(38, lindata, sizeof(lindata));//0x26 hex address | ||
} | ||
|
||
read = !read; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.