Re: Webasto HVH50
Posted: Tue Feb 27, 2024 2:02 pm
HA! Yes. I am not sure what ID is the write ID though, so I guess I can modify the code to run through all IDs 0-64 . . .
HA! Yes. I am not sure what ID is the write ID though, so I guess I can modify the code to run through all IDs 0-64 . . .
Code: Select all
#include "lin_bus.h"
// Create an IntervalTimer object
IntervalTimer myTimer;
int ledState = LOW; // ledState used to set the LED
unsigned long interval = 200000; // interval at which to blinkLED to run every 0.2 seconds
LIN lin;
int lin_cs = 32; // cs and serial port set for skpang LIN / FDCAN board
int led1 = 23;
int lin_fault = 28;
uint16_t Power = 1000; // set to required power
uint8_t Temperature = 100; //set to required temperature
uint16_t tmpheater = 0;
uint16_t udcheater = 0;
uint16_t powerheater = 0;
uint8_t CRC = 0;
uint8_t orderID = 0;
//uint8_t responseID = 0;
uint8_t data[8];
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
pinMode(lin_fault,INPUT);
pinMode(lin_cs, OUTPUT);
digitalWrite(lin_cs, HIGH); // enable MCP2004 LIN transceiver
digitalWrite(LED_BUILTIN, HIGH);
Serial.begin(115200);
//Serial.print("HVH50 Heater demo");
//lin.begin(&Serial3, 9600);
lin.begin(&Serial3, 19200); /// Change to this for 19200 /////
delay(1000);
pinMode(led1,OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
myTimer.begin(blinkLED, interval);
}
void loop() {
// heater
SendLin();
delay(1000); // wait 1000ms
//Serial.print(" Heater test\n");
}
void blinkLED() {
ledState = !ledState;
digitalWrite(LED_BUILTIN, ledState);
digitalWrite(led1, ledState);
}
static void SendLin()
{
for (orderID = 0; orderID < 64; orderID++) {
static bool read = true;
uint8_t data[8];
delay(1000); // wait 1000ms
uint8_t lindata[] = {uint8_t(Power/40), uint8_t(Temperature+40), 0, 8};
lin.order(orderID, lindata, 4, lin2x);
delay(100);
if (lin.response(39, data, 8, lin2x) >=0) // -1 indicates crc error, 19200
{
tmpheater = data[1] - 40;
udcheater = data[4] | (data[5] & 3) << 8;
powerheater =((data[5] >> 2) | (data[6] << 8)) * 20;
Serial.print("orderID:");
Serial.print(orderID);
Serial.print(",");
Serial.print("Temp:");
Serial.print(tmpheater);
Serial.print(",");
Serial.print("Udc:");
Serial.print(udcheater);
Serial.print(",");
Serial.print("Power:");
Serial.println(powerheater);
Serial.print("CRC:");
Serial.print(CRC);
Serial.print(",");
}
else if (read)
{
lin.order(orderID, lindata, 4, lin2x);
}
else
{
uint8_t lindata[] = {uint8_t(Power/40), uint8_t(Temperature+40), 0, 8};
lin.order(orderID, lindata, 4, lin2x);
//Serial.print("\n Sending power and temperature");
}
read = !read;
}
}
Code: Select all
CRC:0,orderID:0,Temp:21,Udc:60,Power:400
CRC:0,orderID:1,Temp:21,Udc:60,Power:400
CRC:0,orderID:2,Temp:21,Udc:60,Power:400
CRC:0,orderID:3,Temp:21,Udc:60,Power:400
CRC:0,orderID:4,Temp:21,Udc:60,Power:400
CRC:0,orderID:5,Temp:21,Udc:60,Power:400
CRC:0,orderID:6,Temp:21,Udc:60,Power:400
CRC:0,orderID:7,Temp:21,Udc:60,Power:400
CRC:0,orderID:8,Temp:21,Udc:60,Power:400
CRC:0,orderID:9,Temp:21,Udc:60,Power:400
CRC:0,orderID:10,Temp:21,Udc:60,Power:400
CRC:0,orderID:11,Temp:21,Udc:60,Power:400
CRC:0,orderID:12,Temp:21,Udc:60,Power:400
CRC:0,orderID:13,Temp:21,Udc:60,Power:400
CRC:0,orderID:14,Temp:21,Udc:60,Power:400
CRC:0,orderID:15,Temp:21,Udc:60,Power:400
CRC:0,orderID:16,Temp:21,Udc:60,Power:400
CRC:0,orderID:17,Temp:21,Udc:60,Power:400
CRC:0,orderID:18,Temp:21,Udc:60,Power:400
CRC:0,orderID:19,Temp:21,Udc:60,Power:400
CRC:0,orderID:20,Temp:21,Udc:60,Power:400
CRC:0,orderID:21,Temp:21,Udc:60,Power:400
CRC:0,orderID:22,Temp:21,Udc:60,Power:400
CRC:0,orderID:23,Temp:21,Udc:60,Power:1040
CRC:0,orderID:24,Temp:21,Udc:60,Power:400
CRC:0,orderID:25,Temp:21,Udc:60,Power:400
CRC:0,orderID:26,Temp:21,Udc:60,Power:400
CRC:0,orderID:27,Temp:21,Udc:60,Power:400
CRC:0,orderID:28,Temp:21,Udc:60,Power:400
CRC:0,orderID:29,Temp:21,Udc:60,Power:400
CRC:0,orderID:30,Temp:21,Udc:60,Power:400
CRC:0,orderID:31,Temp:21,Udc:60,Power:400
CRC:0,orderID:32,Temp:21,Udc:60,Power:400
CRC:0,orderID:33,Temp:21,Udc:60,Power:400
CRC:0,orderID:34,Temp:21,Udc:60,Power:400
CRC:0,orderID:35,Temp:21,Udc:60,Power:400
CRC:0,orderID:36,Temp:21,Udc:60,Power:400
CRC:0,orderID:37,Temp:21,Udc:60,Power:400
CRC:0,orderID:38,Temp:21,Udc:60,Power:400
CRC:0,orderID:39,Temp:21,Udc:60,Power:1040
CRC:0,orderID:40,Temp:21,Udc:60,Power:400
CRC:0,orderID:41,Temp:21,Udc:60,Power:400
CRC:0,orderID:42,Temp:21,Udc:60,Power:400
CRC:0,orderID:43,Temp:21,Udc:60,Power:400
CRC:0,orderID:44,Temp:21,Udc:60,Power:400
CRC:0,orderID:45,Temp:21,Udc:60,Power:400
CRC:0,orderID:46,Temp:21,Udc:60,Power:400
CRC:0,orderID:47,Temp:21,Udc:60,Power:400
CRC:0,orderID:48,Temp:21,Udc:60,Power:400
CRC:0,orderID:49,Temp:21,Udc:60,Power:400
CRC:0,orderID:50,Temp:21,Udc:60,Power:400
CRC:0,orderID:51,Temp:21,Udc:60,Power:400
CRC:0,orderID:52,Temp:21,Udc:60,Power:400
CRC:0,orderID:53,Temp:21,Udc:60,Power:400
CRC:0,orderID:54,Temp:21,Udc:60,Power:400
CRC:0,orderID:55,Temp:21,Udc:60,Power:400
CRC:0,orderID:56,Temp:21,Udc:60,Power:400
CRC:0,orderID:57,Temp:21,Udc:60,Power:400
CRC:0,orderID:58,Temp:21,Udc:60,Power:400
CRC:0,orderID:59,Temp:21,Udc:60,Power:400
CRC:0,orderID:60,Temp:21,Udc:60,Power:1040
CRC:0,orderID:61,Temp:21,Udc:60,Power:400
CRC:0,orderID:62,Temp:21,Udc:60,Power:400
CRC:0,orderID:63,Temp:21,Udc:60,Power:400
Code: Select all
61,0,0,61,192,0,100,1
61,0,0,60,192,0,100,0
61,0,0,60,192,0,100,1
61,0,0,60,192,0,100,0
61,0,0,60,192,0,100,1
61,0,0,60,192,0,101,0
61,0,0,60,192,0,100,1
61,0,0,60,192,0,100,0
61,0,0,61,192,0,99,1
61,0,0,61,192,0,99,0
61,0,0,60,192,0,101,1
61,0,0,60,192,0,100,0
61,0,0,60,192,0,101,1
Code: Select all
Status
4=running
Outlet temp
Scaling as above
Inlet temp -
Voltage LSB
Voltage MSB - 2 bits
Power LSB - 6 bits / Power MSB 1 digit=20W
Unknown
Code: Select all
59, 0, 114, 58, 64,0, 239, 0
Code: Select all
#include "lin_bus.h"
// Create an IntervalTimer object
IntervalTimer myTimer;
int ledState = LOW; // ledState used to set the LED
unsigned long interval = 200000; // interval at which to blinkLED to run every 0.2 seconds
LIN lin;
int lin_cs = 32; // cs and serial port set for skpang LIN / FDCAN board
int led1 = 23;
int lin_fault = 28;
uint16_t Power = 40; // set to required power
uint8_t Temperature = 85; //set to required temperature
uint16_t tmpheater = 0;
uint16_t udcheater = 0;
uint16_t powerheater = 0;
uint8_t CRC = 0;
uint8_t orderID = 0;
uint8_t responseID = 0;
//uint8_t data[8];
uint8_t linTXdata[4] = { 0, 0, 0, 0 }; // 40W, 45C, heater on
uint8_t linRXdata[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
//uint8_t CRC = 0;
//uint8_t orderID = 0;
//uint8_t responseID = 0;
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
pinMode(lin_fault,INPUT);
pinMode(lin_cs, OUTPUT);
digitalWrite(lin_cs, HIGH); // enable MCP2004 LIN transceiver
digitalWrite(LED_BUILTIN, HIGH);
Serial.begin(115200);
//Serial.print("HVH50 Heater demo");
//lin.begin(&Serial3, 9600);
lin.begin(&Serial3, 19200); /// Change to this for 19200 /////
delay(1000);
pinMode(led1,OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
myTimer.begin(blinkLED, interval);
}
void loop() {
// heater
SendLin();
delay(100); // wait 100ms
//Serial.print(" Heater test\n");
}
void blinkLED() {
ledState = !ledState;
digitalWrite(LED_BUILTIN, ledState);
digitalWrite(led1, ledState);
}
static void SendLin()
{
for (orderID = 0; orderID < 64; orderID++) {
static bool read = true;
uint8_t data[8];
delay(1000); // wait 1000ms
lin.order(34, linTXdata, 4, lin2x);
delay(100);
CRC = lin.response(39, linRXdata, 8, lin2x);
lin.response(39, linRXdata, 8, lin2x); //>=0) // -1 indicates crc error, 19200
{
tmpheater = linRXdata[1] - 40;
udcheater = linRXdata[4] | (linRXdata[5] & 3) << 8;
powerheater =((linRXdata[5] >> 2) | (linRXdata[6] << 8)) * 20;
//Serial.print("orderID:");
//Serial.print(orderID);
//Serial.print(",");
Serial.print("Temp:");
Serial.print(tmpheater);
Serial.print(",");
Serial.print("Udc:");
Serial.print(udcheater);
Serial.print(",");
Serial.print("Power:");
Serial.println(powerheater);
Serial.print("CRC:");
Serial.println(CRC);
Serial.print(linRXdata[0]);
Serial.print(",");
Serial.print(linRXdata[1]);
Serial.print(",");
Serial.print(linRXdata[2]);
Serial.print(",");
Serial.print(linRXdata[2]);
Serial.print(",");
Serial.print(linRXdata[4]);
Serial.print(",");
Serial.print(linRXdata[5]);
Serial.print(",");
Serial.print(linRXdata[6]);
Serial.print(",");
Serial.print(linRXdata[7]);
Serial.print(",");
Serial.println(linRXdata[8]);
//Serial.println(data);
}
//else if (read)
// {
lin.order(34, linTXdata, 4, lin2x);
//}
// else
{
//uint8_t linTXdata[] = {uint8_t(Power/40), uint8_t(Temperature+40), 0, 8};
lin.order(34, linTXdata, 4, lin2x);
//Serial.print("\n Sending power and temperature");
}
read = !read;
}
}
Code: Select all
orderID:30,Temp:19,Udc:58,Power:320
CRC:0
0,59,0,0,58,64,0,238,27
orderID:31,Temp:19,Udc:58,Power:320
CRC:0
0,59,0,0,58,64,0,238,27
orderID:32,Temp:19,Udc:58,Power:320
CRC:0
0,59,0,0,58,64,0,237,27
orderID:33,Temp:19,Udc:58,Power:320
CRC:0
0,59,0,0,58,64,0,237,27
orderID:34,Temp:19,Udc:58,Power:320
CRC:0
0,59,0,0,58,64,0,239,27
orderID:35,Temp:19,Udc:58,Power:320
CRC:0
128,59,0,0,58,64,0,110,27
orderID:36,Temp:19,Udc:58,Power:320
CRC:0
0,59,0,0,58,64,0,237,27
orderID:37,Temp:19,Udc:58,Power:320
CRC:0
0,59,0,0,58,64,0,237,27
Code: Select all
#include "lin_bus.h"
// Create an IntervalTimer object
IntervalTimer myTimer;
int ledState = LOW; // ledState used to set the LED
unsigned long interval = 200000; // interval at which to blinkLED to run every 0.2 seconds
LIN lin;
uint16_t Power = 400; // set to required power
uint8_t Temperature = 100; //set to required temperature
int lin_cs = 32; // pin 23 for my LIN board
int led1 = 23;
int lin_fault = 28;
uint8_t linTXdata[4] = { Power, Temperature, 0, 8 }; // 40W, 45C, heater on
uint8_t linRXdata[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
uint8_t CRC = 0;
uint8_t orderID = 0;
uint8_t responseID = 0;
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
pinMode(lin_fault, INPUT);
pinMode(lin_cs, OUTPUT);
digitalWrite(lin_cs, HIGH); // enable MCP2004 LIN transceiver
digitalWrite(LED_BUILTIN, HIGH);
Serial.begin(115200);
lin.begin(&Serial3, 19200); // or
//lin.begin(&Serial3, 9600);
delay(1000);
pinMode(led1, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
}
void loop() {
//for (orderID = 0; orderID < 64; orderID++) {
//for (responseID = 0; responseID < 64; responseID++) {
lin.order(34, linTXdata, 4, lin2x);
delay(100);
CRC = lin.response(39, linRXdata, 8, lin2x);
delay(100);
Serial.print(34, HEX);
Serial.print("\t");
Serial.print(39, HEX);
Serial.print("\t");
Serial.println(CRC, HEX);
for (int i = 0; i < 8; i++) { // display the raw data
Serial.print(linRXdata[i]);
Serial.print("\t");
Serial.print("\t");
Serial.print(" ");
Serial.println();
delay(10);
}
}
//}
//}
Code: Select all
22 27 0
128
95
2
116
91
80
0
22
22 27 0
128
95
2
114
91
80
0
24
22 27 0
32
95
0
114
91
80
0
122
22 27 0
32
95
0
115
91
80
0
121
22 27 0
32
89
0
117
89
80
0
127
22 27 0
32
88
0
115
88
80
0
131
22 27 0
32
84
0
116
83
80
0
139
22 27 0
32
84
0
115
83
80
0
140
22 27 0
32
82
0
116
81
80
0
143
22 27 0
32
82
0
115
81
80
0
144
22 27 0
32
80
0
116
80
80
0
146
22 27 0
32
80
0
116
79
80
0
147
22 27 0
32
79
0
116
78
80
0
149
22 27 0
32
79
0
115
78
80
0
150
If that is the case, do I need to change it from 8 to 16? The heater can handle up to 5000W on the HVH50 and 7000W on the HVH70.
I will do this for sure and let you know.
No, the simplist way it to put the code back to how it was originally with the power sent over LIN the required power / 40.jsimonkeller wrote: ↑Mon Mar 04, 2024 4:58 am If I use the max 8 bit value of 255, by the formula of (255-256)*40 = -40, right???
Code: Select all
orderID:33,Temp:19,Udc:58,Power:320
CRC:0
0,59,0,115,58,64,0,237,27
orderID:34,Temp:19,Udc:58,Power:320
CRC:0
0,59,0,115,58,64,0,239,27
orderID:35,Temp:19,Udc:58,Power:320
CRC:0
128,59,0,115,58,64,0,110,27
orderID:36,Temp:19,Udc:58,Power:320
CRC:0
0,59,0,115,58,64,0,237,27
Code: Select all
Node_attributes {
HVH_100{
LIN_protocol = "2.0" ;
configured_NAD = 0x5F ;
product_id = 0x0, 0x0, 0 ;
response_error = PTC_ResponseError ;
P2_min = 10 ms ;
ST_min = 10 ms ;
configurable_frames {
HV_He_01 = 0x401C ;
HV_Hs_01 = 0x4030 ;
HV_Hs_02 = 0x400C ;
Code: Select all
Frames {
HV_He_01: 28, Controller, 4 {
KL_HV_PTC_soll, 0 ;
KL_PTC_ein, 8 ;
}
H
V_Hs_01: 48, HVH_100, 8 {
PTC_HV_I_ist, 0 ;
PTC_HV_ERR, 8 ;
PTC_HV_Status_PTC, 16 ;
PTC_Status_UBatt, 19 ;
PTC_ResponseError, 21 ;
PTC_TimeOut_Fehler, 22 ;
PTC_HV_Err_Heizkreis_1, 24 ;
PTC_HV_Err_Heizkreis_2, 25 ;
PTC_HV_Err_Heizkreis_3, 26 ;
PTC_HV_Err_Leckagestrom, 27 ;
PTC_HV_Err_Ueberstromabschaltung, 28 ;
PTC_HV_Err_Temperaturschutz, 29 ;
PTC_HV_Err_intern, 30 ;
PTC_UBatt, 32 ;
PTC_Temp_PCB, 40 ;
PTC_HV_Heizmedium_Sensor_1, 48 ;
PTC_HV_Heizmedium_Sensor_2, 56 ;
}
HV_Hs_02: 12, HVH_100, 8 {
HVH_HV_Voltage, 32 ;
HVH_HV_Voltage_Offset, 41 ;
HVH_HV_Ilock_Status, 45 ;
HVH_ParameterChange, 61 ;
HVH_ErrMem_State, 62 ;
}
}
Schedule_tables {
ST1 {
HV_He_01 delay 20 ms ;
HV_Hs_01 delay 20 ms ;
HV_Hs_02 delay 20 ms ;
}
DiagRequest {
MasterReq delay 10 ms ;
}
DiagResponse {
SlaveResp delay 10 ms ;
}
}