VW A/C Compressor

Forum on Volkswagen related hardware, so VW, Audi, Seat, Skoda etc.
BERA
Posts: 1
Joined: Wed Apr 12, 2023 1:26 pm

Re: VW A/C Compressor

Post by BERA »

Does anyone have any idea what a message to wake up the compressor looks like in HEX format?

for example "0B 00 00 FE FE FE 3F 00 E8". (this is FrameID + 8 DataBytes)

I am using the LIN Analyzer from Microchip with the LIN Serial Analyzer Debug Tool. In this program I can send messages only as shown above.
User avatar
muehlpower
Posts: 570
Joined: Fri Oct 11, 2019 10:51 am
Location: Germany Fürstenfeldbruck
Has thanked: 12 times
Been thanked: 96 times

Re: VW A/C Compressor

Post by muehlpower »

here the whole code, running on arduino due
PID[AC_ID]=0x20
PID[BH_ID]=0x9C
PID[AC_R_ID] =0x61
PID[BH_R_ID]=0xF0
PID[DS_R_ID]=0x80

Code: Select all

uint8_t buff[42]="";

void Lin (uint8_t msg[10],uint8_t len)  //this manages the serial output to the LIN tranceiver
{ 
  Serial1.begin(LIN_baud*10/16,SERIAL_8N1);
  Serial1.write((byte)0);                // 16 bit langes low
  Serial1.end();  // UART ausschalten
  Serial1.begin(LIN_baud,SERIAL_8N1);
  Serial1.write(0b01010101);             //synkronbyte senden
  for (uint8_t i=0; i<=len; ++i)
   { 
    Serial1.write(data[i]);             //daten senden  
   }
  if (len > 0) Serial1.write(data[9]);  //checksum senden
}

void serialEvent1()
{
 Serial1.readBytes(buff, 12);
}

void clearbuffer (void)
{
 for (uint8_t i=0; i<11; ++i)
  {
   buff[i]= 0;
  }
}

uint8_t meincheck (uint8_t * pdata, uint8_t len, uint8_t mode)  // this adds the cecksum
{
 uint16_t tmp;
 if (mode == CLASSIC) tmp = 0;
 else tmp = pdata[0];
 for (uint8_t i=1; i<=len; i++)
  {
   tmp = tmp + pdata[i];
   if (tmp>255) tmp = tmp-255;
  }
  //tmp = pdata[3]+11;
  tmp = 255-tmp;
  return  tmp;
}






void send_LIN ()  // this runs every 50ms and read/write data
{
 if (buff[1] == PID[AC_R_ID])   //set AC
    {
     AC_R_HV = buff[7];
     AC_R_Temp = buff[6]/2;
     AC_R_Speed = buff[3];
     AC_R_HV_OK = buff[4]&1<<6; 
     AC_R_Run = buff[4]&1<<5;
     //Anzeigen ();
    }
 if (buff[1] == PID[BH_R_ID])   //set Heater
    {
     BH_R_LV = buff[6];          //LV Spannung  90=9V,  135= 13,5V
     BH_R_Temp_In = buff[7];    //Wassereintritt Themperatur
     BH_R_Temp_Out = buff[8];   //Wasseraustritt Themperatur
     BH_R_Power = buff[2];      //Heizleistung ca x30 = W
     BH_R_LV_OK = buff[4]&1<<3; //Bit3=1 bei LV Untespannung, Bit5+6=Empfang OK 
     //Anzeigen (); 
    }
  if (buff[1] == PID[DS_R_ID])    //read  presure sensor
    {
      DS_Druck = (buff [2]+ buff[3]*256)*0.818;       //Druck Niederdruckseite AC in 10mbar schritten
     //Anzeigen ();
    } 
  if (buff[1] == PID[AC_ID])                   // does nothing
    {
     //Anzeigen ();
    } 
  if (buff[1] == PID[BH_ID])                   // does nothing
    {
     //Anzeigen ();
    }     
 clearbuffer ();   
 switch (MSG_CNT)
  {
   case 0:                                         //Lin botschaft für A/C Kompressor
    {                                              // fill data vor AC
     DB=6;                                         // DB = amount of data bytes
     data [0] = PID[AC_ID]; 
     data [1] = AC_Speed; // Drehzahl für Kompressor
     if (AC_Run) data [2] = 0b00000101;
     else data [2] = 0b00000100; 
     data [3] = 0;
     data [4] = 0;
     data [5] = 0;
     data [6] = 0;
     data [9] = meincheck (data, DB, ENHANCED);
     Lin (data, DB);                               
    }
   break;
   case 1:                                          //Lin Botschaft für Batterie Heizung 
    {                                               // fill data vor heater  
     DB=4;                                                                                
     data [0] = PID[BH_ID]; 
     data [1] = BH_Power; // Leistung für Heizung
     if (BH_Run) data [2] = 0b00000001;  //Heizung ein
     else data [2] = 0b00000000;
     data [3] = 0;
     data [4] = 0;
     data [9] = meincheck (data, DB, ENHANCED);
     Lin (data, DB);                                
    }
   break;
   case 2:                                           //LIN Anfrage für Drucksensor
    {                         
     DB=0;                                           // DB = 0 cause asking
     data [0] = PID[DS_R_ID];
     Lin (data, DB);
     //delay (153600/LIN_baud);
    }
   break;
   case 3:                                           //LIN Anfrage für AC Kompressor
    {
     DB=0;
     data [0] = PID[AC_R_ID];
     Lin (data, DB);
     //delay (153600/LIN_baud);
    }
   break;
   case 4:                                           //LIN Anfrage für Batterie Heizung  
    {
     DB=0;
     data [0] = PID[BH_R_ID];
     Lin (data, DB);
     //delay (153600/LIN_baud);
    }
   break;
   default:
    {
     
    }
   break;
  }
  MSG_CNT++;
  if (MSG_CNT > 4) MSG_CNT=0;
}
User avatar
7yatna
Posts: 65
Joined: Wed Jul 06, 2022 2:49 am
Location: San Diego, CA
Has thanked: 4 times
Been thanked: 3 times

Re: VW A/C Compressor

Post by 7yatna »

muehlpower wrote: Wed Apr 12, 2023 7:06 pm here the whole code, running on arduino due
PID[AC_ID]=0x20
PID[BH_ID]=0x9C
PID[AC_R_ID] =0x61
PID[BH_R_ID]=0xF0
PID[DS_R_ID]=0x80

Code: Select all

uint8_t buff[42]="";

void Lin (uint8_t msg[10],uint8_t len)  //this manages the serial output to the LIN tranceiver
{ 
  Serial1.begin(LIN_baud*10/16,SERIAL_8N1);
  Serial1.write((byte)0);                // 16 bit langes low
  Serial1.end();  // UART ausschalten
  Serial1.begin(LIN_baud,SERIAL_8N1);
  Serial1.write(0b01010101);             //synkronbyte senden
  for (uint8_t i=0; i<=len; ++i)
   { 
    Serial1.write(data[i]);             //daten senden  
   }
  if (len > 0) Serial1.write(data[9]);  //checksum senden
}

void serialEvent1()
{
 Serial1.readBytes(buff, 12);
}

void clearbuffer (void)
{
 for (uint8_t i=0; i<11; ++i)
  {
   buff[i]= 0;
  }
}

uint8_t meincheck (uint8_t * pdata, uint8_t len, uint8_t mode)  // this adds the cecksum
{
 uint16_t tmp;
 if (mode == CLASSIC) tmp = 0;
 else tmp = pdata[0];
 for (uint8_t i=1; i<=len; i++)
  {
   tmp = tmp + pdata[i];
   if (tmp>255) tmp = tmp-255;
  }
  //tmp = pdata[3]+11;
  tmp = 255-tmp;
  return  tmp;
}






void send_LIN ()  // this runs every 50ms and read/write data
{
 if (buff[1] == PID[AC_R_ID])   //set AC
    {
     AC_R_HV = buff[7];
     AC_R_Temp = buff[6]/2;
     AC_R_Speed = buff[3];
     AC_R_HV_OK = buff[4]&1<<6; 
     AC_R_Run = buff[4]&1<<5;
     //Anzeigen ();
    }
 if (buff[1] == PID[BH_R_ID])   //set Heater
    {
     BH_R_LV = buff[6];          //LV Spannung  90=9V,  135= 13,5V
     BH_R_Temp_In = buff[7];    //Wassereintritt Themperatur
     BH_R_Temp_Out = buff[8];   //Wasseraustritt Themperatur
     BH_R_Power = buff[2];      //Heizleistung ca x30 = W
     BH_R_LV_OK = buff[4]&1<<3; //Bit3=1 bei LV Untespannung, Bit5+6=Empfang OK 
     //Anzeigen (); 
    }
  if (buff[1] == PID[DS_R_ID])    //read  presure sensor
    {
      DS_Druck = (buff [2]+ buff[3]*256)*0.818;       //Druck Niederdruckseite AC in 10mbar schritten
     //Anzeigen ();
    } 
  if (buff[1] == PID[AC_ID])                   // does nothing
    {
     //Anzeigen ();
    } 
  if (buff[1] == PID[BH_ID])                   // does nothing
    {
     //Anzeigen ();
    }     
 clearbuffer ();   
 switch (MSG_CNT)
  {
   case 0:                                         //Lin botschaft für A/C Kompressor
    {                                              // fill data vor AC
     DB=6;                                         // DB = amount of data bytes
     data [0] = PID[AC_ID]; 
     data [1] = AC_Speed; // Drehzahl für Kompressor
     if (AC_Run) data [2] = 0b00000101;
     else data [2] = 0b00000100; 
     data [3] = 0;
     data [4] = 0;
     data [5] = 0;
     data [6] = 0;
     data [9] = meincheck (data, DB, ENHANCED);
     Lin (data, DB);                               
    }
   break;
   case 1:                                          //Lin Botschaft für Batterie Heizung 
    {                                               // fill data vor heater  
     DB=4;                                                                                
     data [0] = PID[BH_ID]; 
     data [1] = BH_Power; // Leistung für Heizung
     if (BH_Run) data [2] = 0b00000001;  //Heizung ein
     else data [2] = 0b00000000;
     data [3] = 0;
     data [4] = 0;
     data [9] = meincheck (data, DB, ENHANCED);
     Lin (data, DB);                                
    }
   break;
   case 2:                                           //LIN Anfrage für Drucksensor
    {                         
     DB=0;                                           // DB = 0 cause asking
     data [0] = PID[DS_R_ID];
     Lin (data, DB);
     //delay (153600/LIN_baud);
    }
   break;
   case 3:                                           //LIN Anfrage für AC Kompressor
    {
     DB=0;
     data [0] = PID[AC_R_ID];
     Lin (data, DB);
     //delay (153600/LIN_baud);
    }
   break;
   case 4:                                           //LIN Anfrage für Batterie Heizung  
    {
     DB=0;
     data [0] = PID[BH_R_ID];
     Lin (data, DB);
     //delay (153600/LIN_baud);
    }
   break;
   default:
    {
     
    }
   break;
  }
  MSG_CNT++;
  if (MSG_CNT > 4) MSG_CNT=0;
}
Oh My god, thank you so much, right on time as i was asking around for a sketch.

i will now play with and see if we have lift off.

thanks again.
Karim
Hammer, Duct tape, WD-40 that`s it :D
1973 Beetle with SDU swap.
scootcoupe
Posts: 3
Joined: Fri May 22, 2020 1:25 pm

Re: VW A/C Compressor

Post by scootcoupe »

So I have the compressor out of a US VW E-Golf with PN# 5QE820803 and I have tried to send the enable message 0x00 0x01 0x00 0x00 0x00 0x00 to address 0x20 and I am getting no response from the compressor. I don't have the high voltage hooked up to the compressor but I have +12V supplied.

I have the bus set to 9200 baud and enhanced checksum on the message.

I am using a Peak PLIN with their PLIN-View PRO software. Does anyone have access to a US spec car or have they taken a LIN log from one?
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: VW A/C Compressor

Post by Pete9008 »

scootcoupe wrote: Fri May 12, 2023 12:32 am So I have the compressor out of a US VW E-Golf with PN# 5QE820803 and I have tried to send the enable message 0x00 0x01 0x00 0x00 0x00 0x00 to address 0x20 and I am getting no response from the compressor. I don't have the high voltage hooked up to the compressor but I have +12V supplied.

I have the bus set to 9200 baud and enhanced checksum on the message.

I am using a Peak PLIN with their PLIN-View PRO software. Does anyone have access to a US spec car or have they taken a LIN log from one?
I've had a response from mine without HV connected (UK spec compressor though). Do you mean 19200baud there (as that's what you need)?

Do you get a response to the status message (0x21)?

Edit - thinking about it I only remember seeing the status message on 0x21 without HV. Not sure whether the control message did anything (or whether I even tried it!).
User avatar
muehlpower
Posts: 570
Joined: Fri Oct 11, 2019 10:51 am
Location: Germany Fürstenfeldbruck
Has thanked: 12 times
Been thanked: 96 times

Re: VW A/C Compressor

Post by muehlpower »

scootcoupe wrote: Fri May 12, 2023 12:32 am So I have the compressor out of a US VW E-Golf with PN# 5QE820803 and I have tried to send the enable message 0x00 0x01 0x00 0x00 0x00 0x00 to address 0x20 and I am getting no response from the compressor. I don't have the high voltage hooked up to the compressor but I have +12V supplied.

I have the bus set to 9200 baud and enhanced checksum on the message.

I am using a Peak PLIN with their PLIN-View PRO software. Does anyone have access to a US spec car or have they taken a LIN log from one?
I'm not sure if you understood LIN. You are the master, you either send a whole message to control a device or just the address to get a response. With the A/C compressor you will receive a response to 0x61. You will not receive any messages without a request. The 0x20 controls the compressor, but does not trigger a response!
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: VW A/C Compressor

Post by Pete9008 »

Just in case it's confusing matters the status message is on ID 0x21 or PID 0x61. The PID is essentially the 6-bit ID with an extra two bits (the top two) of parity added and is only really useful if you write your own LIN code and it doesn't do the parity bit calculation for you. Muehlpower posted a table of ID to PID conversions earlier in this thread for reference.

I think PLIN-View PRO uses the ID.
scootcoupe
Posts: 3
Joined: Fri May 22, 2020 1:25 pm

Re: VW A/C Compressor

Post by scootcoupe »

Ah okay,

I thought LIN was like broadcast CAN where once you wake up the device it continues to broadcast its status on the bus. I sent a message on ID 0x20 and then sent an empty frame on ID 0x21 requesting 7 bytes and it responded back. I'll work on getting some HV hooked up to the compressor and see if anything changes but so far it looks like the US compressors use the same communication matrix.
User avatar
7yatna
Posts: 65
Joined: Wed Jul 06, 2022 2:49 am
Location: San Diego, CA
Has thanked: 4 times
Been thanked: 3 times

Re: VW A/C Compressor

Post by 7yatna »

golfdubcrazy wrote: Sun Apr 02, 2023 7:10 pm After making lots of adaptors and brackets im ready to start testing my AC setup. I decided to use a watercooled condenser and evaporator.

ESP32 for commutation. once i know its reliable and wont try to blow up anything I will put the code on my GitHub.

I have also found the actual datasheet for the pressure sensor will add it shortly needless to say the error i had from my data was 0.0001 :D 8-)
Hey Golfdubcrazy,

back at the VW AC and Heater LIN.

still trying to get to it but because the TJA1027 is almost non existent and my HW (Zombie is using TJA1020 which doesnt support 2.2 Lin)

did you get a wroking sketch for both AC and Heater or at least one of them ? Muehle posted a snip of his code am pretty much sure that is part of his main code for his controller so it is missing bunch of headers and declaratiuons and stuff.

LIN is weird i got can OK and got a working library for that but LIN is a little bit tricky library wise.

can you guide me to your Github if you shared anything there? or post a working sletch for the AC or heater? im upgrading the LIN trancever on Zombie and will try to make a module on Zombie to control Lin devices (VW Heater and AC).

let me know if you can guide me in any way.
thanks
karim
Hammer, Duct tape, WD-40 that`s it :D
1973 Beetle with SDU swap.
golfdubcrazy
Posts: 75
Joined: Thu Jan 28, 2021 6:15 pm
Has thanked: 1 time
Been thanked: 5 times

Re: VW A/C Compressor

Post by golfdubcrazy »

Hi,

CAN bus and LIN run in different ways. Lin is a lot simpler. On CAN once the module has power it will constantly transmit its data regardless of if anything is listening.

Lin works on a master/slave principal. so the master module has can transmit any control data it wants. but the slave module will not reply unless the master requests it. this is done by the master sending out the ID of the slave and once the slave see it responds with its message. this has to be done every 10ms to 500ms

E.G (Master module ID 20 (ac control) and Slave id 61 (ac response))
master transmit RED and slave responce in BLUE

id ¦ Data ¦ cks
20 ¦ 00 00 00 00 00 ¦00
61 ¦ 00 00 00 00 00 ¦ 00

Sorry i have not had much time for testing, but i will add my lin read/write code onto there once i get a chance.
User avatar
7yatna
Posts: 65
Joined: Wed Jul 06, 2022 2:49 am
Location: San Diego, CA
Has thanked: 4 times
Been thanked: 3 times

Re: VW A/C Compressor

Post by 7yatna »

golfdubcrazy wrote: Wed May 24, 2023 8:11 am Hi,

CAN bus and LIN run in different ways. Lin is a lot simpler. On CAN once the module has power it will constantly transmit its data regardless of if anything is listening.

Lin works on a master/slave principal. so the master module has can transmit any control data it wants. but the slave module will not reply unless the master requests it. this is done by the master sending out the ID of the slave and once the slave see it responds with its message. this has to be done every 10ms to 500ms

E.G (Master module ID 20 (ac control) and Slave id 61 (ac response))
master transmit RED and slave responce in BLUE

id ¦ Data ¦ cks
20 ¦ 00 00 00 00 00 ¦00
61 ¦ 00 00 00 00 00 ¦ 00

Sorry i have not had much time for testing, but i will add my lin read/write code onto there once i get a chance.

Thnk you so much for your response and confirming my understanding.

I wrote a code based on muehlepower sketch. i didn't test it yet as I'm waiting for the correct TJA Lin Transceivers. they are coming on board a slow ship from china.

i will test and post it if i have any success.

thanks
Karim
Hammer, Duct tape, WD-40 that`s it :D
1973 Beetle with SDU swap.
User avatar
muehlpower
Posts: 570
Joined: Fri Oct 11, 2019 10:51 am
Location: Germany Fürstenfeldbruck
Has thanked: 12 times
Been thanked: 96 times

Re: VW A/C Compressor

Post by muehlpower »

why shouldn't the TJA1020 work with the VAG components? have you tried it? My first attempts were with a simple NPN trasistor and it worked.
User avatar
7yatna
Posts: 65
Joined: Wed Jul 06, 2022 2:49 am
Location: San Diego, CA
Has thanked: 4 times
Been thanked: 3 times

Re: VW A/C Compressor

Post by 7yatna »

muehlpower wrote: Wed May 24, 2023 8:40 pm why shouldn't the TJA1020 work with the VAG components? have you tried it? My first attempts were with a simple NPN trasistor and it worked.
I didnt try to be honest i just looked at the datasheets and TJA 1020 is Lin 1.3 Only

and i know the VW is 2.2 so didnt try.

I have TJA1020 i will connect it through the code i wrote and see if it comes alive. either way the new transceivers will be delivered in a week.
Hammer, Duct tape, WD-40 that`s it :D
1973 Beetle with SDU swap.
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: VW A/C Compressor

Post by Pete9008 »

At the electrical level LIN bus is always Ver1.3. Ver 2.0 and up just add extra messaging types at the software level but at the electrical layer is the same.

Fairly sure the TJA1020 is compatible with all of them (it's what I've used to talk to my VW compressor and heater).
User avatar
7yatna
Posts: 65
Joined: Wed Jul 06, 2022 2:49 am
Location: San Diego, CA
Has thanked: 4 times
Been thanked: 3 times

Re: VW A/C Compressor

Post by 7yatna »

Pete9008 wrote: Wed May 24, 2023 8:51 pm At the electrical level LIN bus is always Ver1.3. Ver 2.0 and up just add extra messaging types at the software level but at the electrical layer is the same.

Fairly sure the TJA1020 is compatible with all of them (it's what I've used to talk to my VW compressor and heater).
Hi Pete,

thank you for confirming. if you got the Compressor and heater to talk would you mind sharing a rough code ? i will try my code tonight but a verfied working code is always appreciated.

thanks
karim
Hammer, Duct tape, WD-40 that`s it :D
1973 Beetle with SDU swap.
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: VW A/C Compressor

Post by Pete9008 »

My code is here https://github.com/Pete9008/LIN_Analyser but not sure how much help it will be.

It runs on a PC using Qt and is more for reverse engineering than for controlling a specific device. I was able to talk to the VW heater and compressor though.
User avatar
7yatna
Posts: 65
Joined: Wed Jul 06, 2022 2:49 am
Location: San Diego, CA
Has thanked: 4 times
Been thanked: 3 times

Re: VW A/C Compressor

Post by 7yatna »

Thanks Pete,

this is great help.

Karim
Hammer, Duct tape, WD-40 that`s it :D
1973 Beetle with SDU swap.
User avatar
7yatna
Posts: 65
Joined: Wed Jul 06, 2022 2:49 am
Location: San Diego, CA
Has thanked: 4 times
Been thanked: 3 times

Re: VW A/C Compressor

Post by 7yatna »

Hey Guys,

SO im back at coding and getting the Heater and AC compressor to work.

I copied Meuhl sketch and it was missing bunch of variables i added them up and now we have working Setup.

I can send the control messages and ping the response messages and the is spot on. Both control and response.

Here is the couple of issues i got:
1- it looks like i have a variation of the AC compressor. Mine came off Audi Etron A3 2017.
since i didnt know the messages i tried one by one from the IDs in the table previously.

I found the Status for this compressor is on ID27, ID Hex 0x1B and PID 0x5B.

now i cant find the control ID so dont know what to do else. i tried like i did on the status ID but it looks like the format on the control message is different than posted here. and the response message as well is reporting different than what the Byte should indicate so if im sending to an ID i don't know if it is the actual ID message cant see difference on the response message.

2- the heater message both control and response they are spot on. but im not sure if we set the power is it in hex or decimal?

or how we set the power level anyway on the heater ?

for the reference i attached a screenshot of the serial monitor for the messages. I powered them on and no HV is connected to any of them
Screenshot 2023-06-30 231236.png
as well the Part number of the AC compressor if it make any sense
12E820803D and the HW and SW numbers are 04 and 02 not sure which one is which.

any ideas how to proceed?

need to identify the control message for the Compressor and the format for control messages both Heater and AC compressor.
Hammer, Duct tape, WD-40 that`s it :D
1973 Beetle with SDU swap.
m.art.y
Posts: 550
Joined: Sat Jun 06, 2020 6:54 pm
Location: UK
Has thanked: 24 times
Been thanked: 17 times

Re: VW A/C Compressor

Post by m.art.y »

Hi guys, is this VW heater that you got working made by Ebersprächer? There are so many different versions of these VW heaters.. How many pins have your LV voltage connector got?
User avatar
muehlpower
Posts: 570
Joined: Fri Oct 11, 2019 10:51 am
Location: Germany Fürstenfeldbruck
Has thanked: 12 times
Been thanked: 96 times

Re: VW A/C Compressor

Post by muehlpower »

everything I wrote refers to the DBK heater.

connectors are:
HVA 280 KEY_E from TE +HV near to the body, -HV far from the body
1J0973714 1= +12V , 2= GND, 4= LIN

Have you already tried it with the same LIN messages? I can imagine that this also works for Eberspächer
User avatar
7yatna
Posts: 65
Joined: Wed Jul 06, 2022 2:49 am
Location: San Diego, CA
Has thanked: 4 times
Been thanked: 3 times

Re: VW A/C Compressor

Post by 7yatna »

Hi Guys,

here is an arduino scketch based on Muehlpower code i just added couple of things. this did control my heater and ran it about 720W. and it the log i posted earlier was from this code session.

Code: Select all

int LIN_baud = 19200;
int DB = 0;
uint8_t data1[10];
uint8_t buff[42];

int AC_ID = 0xBF;

int BH_ID = 0x9C;
//int AC_R_ID = 0xF0;
int AC_R_ID = 0x5B;
int BH_R_ID = 0xF0;

int AC_Run = 1;
int AC_Speed = 125;
int BH_Run = 1;
int BH_Power = 13;

uint8_t AC_R_HV = 0;
uint8_t AC_R_Temp = 0;
uint8_t AC_R_Speed = 0;
uint8_t AC_R_HV_OK = 0;
uint8_t AC_R_Run = 0;
uint8_t BH_R_LV = 0;
uint8_t BH_R_Temp_In = 0;
uint8_t BH_R_Temp_Out = 0;
uint8_t BH_R_Power = 0;
uint8_t BH_R_LV_OK = 0;

int MSG_CNT = 0;


void setup() 
{
 Serial.begin(115200);
}

void loop() 
{
send_LIN();
delay(50);
}

void feedback(uint8_t len)
{
  for (uint8_t i=0; i<=len; ++i)
   { 
    Serial.write(buff[i]);             //daten senden  
   }  

}


void Lin (uint8_t msg[10],uint8_t len)  //this manages the serial output to the LIN tranceiver
{ 
  Serial1.begin(LIN_baud*10/16,SERIAL_8N1);
  Serial1.write((byte)0);                // 16 bit langes low
  Serial1.end();  // UART ausschalten
  Serial1.begin(LIN_baud,SERIAL_8N1);
  Serial1.write(0b01010101);             //synkronbyte senden
  for (uint8_t i=0; i<=len; ++i)
   { 
    Serial1.write(msg[i]);             //daten senden  
    //Serial1.write(data1[i]);             //daten senden  
   }
  if (len > 0) Serial1.write(msg[9]);  //checksum senden
}

void serialEvent1()
{
 Serial1.readBytes(buff, 12);
 for (uint8_t i=1; i<=12; ++i)
   { 
    Serial.print(buff[i], HEX);
    Serial.print(",");
   }
   Serial.println();
}

void clearbuffer (void)
{
 for (uint8_t i=0; i<11; ++i)
  {
   buff[i]= 0;
  }
}

uint8_t meincheck (uint8_t * pdata, uint8_t len) //, uint8_t mode)  // this adds the cecksum
{
 uint16_t tmp;
// if (mode == CLASSIC) tmp = 0;
// else 
 tmp = pdata[0];
 for (uint8_t i=1; i<=len; i++)
  {
   tmp = tmp + pdata[i];
   if (tmp>255) tmp = tmp-255;
  }
  //tmp = pdata[3]+11;
  tmp = 255-tmp;
  return  tmp;
}


void send_LIN ()  // this runs every 50ms and read/write data
{
 if (buff[1] == AC_R_ID)   //set AC
    {
     AC_R_HV = buff[7];
     AC_R_Temp = buff[6]/2;
     AC_R_Speed = buff[3];
     AC_R_HV_OK = buff[4]&1<<6; 
     AC_R_Run = buff[4]&1<<5;
     //feedback(DB);
     //Anzeigen ();
    }
 if (buff[1] == BH_R_ID)   //set Heater
    {
     BH_R_LV = buff[6];          //LV Spannung  90=9V,  135= 13,5V
     BH_R_Temp_In = buff[7];    //Wassereintritt Themperatur
     BH_R_Temp_Out = buff[8];   //Wasseraustritt Themperatur
     BH_R_Power = buff[2];      //Heizleistung ca x30 = W
     BH_R_LV_OK = buff[4]&1<<3; //Bit3=1 bei LV Untespannung, Bit5+6=Empfang OK 
     //feedback(DB);
     //Anzeigen (); 
    }
    /*
  if (buff[1] == PID[DS_R_ID])    //read  presure sensor
    {
      DS_Druck = (buff [2]+ buff[3]*256)*0.818;       //Druck Niederdruckseite AC in 10mbar schritten
     //Anzeigen ();
    } 
    */
  if (buff[1] == AC_ID)                   // does nothing
    {
     //Anzeigen ();
    } 
  if (buff[1] == BH_ID)                   // does nothing
    {
     //Anzeigen ();
    }     
 clearbuffer ();   
 
 switch (MSG_CNT)
 {
 /*switch (3)
  {
   case 0:                                         //Lin botschaft für A/C Kompressor
    {                                              // fill data vor AC
     DB=6;                                         // DB = amount of data bytes
     data1 [0] = AC_ID; 
     data1 [1] = AC_Speed; // Drehzahl für Kompressor
     if (AC_Run) data1 [2] = 0b00000101;
     else data1 [2] = 0b00000100; 
     data1 [3] = 0;
     data1 [4] = 0;
     data1 [5] = 0;
     data1 [6] = 0;
     data1 [9] = meincheck (data1, DB); //, ENHANCED);
     Lin (data1, DB);                               
    }
   break;
*/
   case 1:                                          //Lin Botschaft für Batterie Heizung 
    {                                               // fill data vor heater  
     DB=4;                                                                                
     data1 [0] = BH_ID; 
     data1 [1] = BH_Power; // Leistung für Heizung
     if (BH_Run) data1 [2] = 0b00000001;  //Heizung ein
     else data1 [2] = 0b00000000;
     data1 [3] = 0;
     data1 [4] = 0;
     data1 [9] = meincheck (data1, DB); //, ENHANCED);
     Lin (data1, DB);                                
    }
   break;
/*
   case 2:                                           //LIN Anfrage für Drucksensor
    {                         
     //DB=0;                                           // DB = 0 cause asking
     //data1 [0] = PID[DS_R_ID];
     //Lin (data1, DB);
     //delay (153600/LIN_baud);
    }
   break;

   case 3:                                           //LIN Anfrage für AC Kompressor
    {
     DB=0;
     data1 [0] = AC_R_ID;
     Lin (data1, DB);
     //delay (153600/LIN_baud);
    }
   break;
   */
   case 4:                                           //LIN Anfrage für Batterie Heizung  
    {
     DB=0;
     data1 [0] = BH_R_ID;
     Lin (data1, DB);
     //delay (153600/LIN_baud);
    }
   break;
   default:
    {
     
    }
   break;
  }
  MSG_CNT++;
  if (MSG_CNT > 4) MSG_CNT=0;
}
for the AC im using a diffrent SW/HW number and might need help as those Ids didnt match my ac compressor.

i verified the LV connection to match the donor vehicle. just the IDs are diffrent.

I managed to find the feedback/response for the compressor i got which is PID 0x5B.

and i can confirm that the baud rate is 19200 for that SW/HW revision.

that ac compressor came out of Audi A3 Etron 2017. and it is the same PN like posted here but only rev D

@muehl, do you have any strategy to try and get the control ID ? i tried sending the control message you put in your code to all the IDs but the feedback never changed.

HV was not connected.

thanks, Karim
Hammer, Duct tape, WD-40 that`s it :D
1973 Beetle with SDU swap.
User avatar
muehlpower
Posts: 570
Joined: Fri Oct 11, 2019 10:51 am
Location: Germany Fürstenfeldbruck
Has thanked: 12 times
Been thanked: 96 times

Re: VW A/C Compressor

Post by muehlpower »

i tried all the addresses one after the other to find the control address and noticed a change in the response to the correct one.
User avatar
7yatna
Posts: 65
Joined: Wed Jul 06, 2022 2:49 am
Location: San Diego, CA
Has thanked: 4 times
Been thanked: 3 times

Re: VW A/C Compressor

Post by 7yatna »

muehlpower wrote: Tue Jul 04, 2023 7:52 am i tried all the addresses one after the other to find the control address and noticed a change in the response to the correct one.
i did the same thing but it looks like the control message format for my compressor is a little bit diffrent so no change in the feedback message.

i will take another try at it or i will go tesla can controlled compressor.

thank you for your help on the heater it worked as you mentioned.
Hammer, Duct tape, WD-40 that`s it :D
1973 Beetle with SDU swap.
m.art.y
Posts: 550
Joined: Sat Jun 06, 2020 6:54 pm
Location: UK
Has thanked: 24 times
Been thanked: 17 times

Re: VW A/C Compressor

Post by m.art.y »

I wonder if it would be possible to get a LIN log from a working car and what software could be used to find out control messages for these LIN devices?
User avatar
7yatna
Posts: 65
Joined: Wed Jul 06, 2022 2:49 am
Location: San Diego, CA
Has thanked: 4 times
Been thanked: 3 times

Re: VW A/C Compressor

Post by 7yatna »

m.art.y wrote: Tue Jul 04, 2023 10:02 am I wonder if it would be possible to get a LIN log from a working car and what software could be used to find out control messages for these LIN devices?
It will be a great resource but as usually, people whop are willing to tap into their busses and taking pieces off to connect a sniffer are very very very few. specially if they are not doing it for their own projects.
Hammer, Duct tape, WD-40 that`s it :D
1973 Beetle with SDU swap.
Post Reply