Pages: [1] 2
Author Topic: Generating CAN messages from Arduino for ME7.5  (Read 16069 times)
timr72
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 8


« on: June 13, 2022, 01:28:43 AM »

Hi All,

I've got as far as I can, but I'm hitting an issue.  I have an ME7.5 ECU and 1.8T engine in my kitcar, none of the other units are there; so no ABS, no Airco, no Dashboard etc.  Although the car runs I am missing a speedo input for the ECU.  I've tried generating ABS pseudo traffic but this is not having the desired effect, I have also tried as Kombi1/2/3 same result.

Is there a way (And how do I do it) to check where the ECU expects to get the speed from Can Kombi, ABS or physical?
..and can I change the ECU to use VSS pulse on I think pin 54?

Binary and data useful attached; ECU and engine are BF/ME7.5 from a 2005 Audi A4 Convertible.


Code:
// CAN Receive and send Example
//

#include <mcp_can.h>
#include <SPI.h>

long unsigned int rxId;
unsigned char len = 0;
unsigned char rxBuf[8];
int EngineTemp;
int RoadSpeed;
int val;
char msgString[128];                        // Array to store serial string
char input[3];

#define CAN0_INT 2                              // Set INT to pin 2
MCP_CAN CAN0(10);                               // Set CS to pin 10


void setup()
{
  Serial.begin(115200);
 
  // Initialize MCP2515 running at 16MHz with a baudrate of 500kb/s and the masks and filters disabled.
  if(CAN0.begin(MCP_ANY, CAN_500KBPS, MCP_16MHZ) == CAN_OK)
    Serial.println("MCP2515 Initialized Successfully!");
  else
    Serial.println("Error Initializing MCP2515...");
 
  CAN0.setMode(MCP_NORMAL);                     // Set operation mode to normal so the MCP2515 sends acks to received data.

  pinMode(CAN0_INT, INPUT);                            // Configuring pin for /INT input
 
  Serial.println("MCP2515 Library Receive Example...");
}

void loop()
{
  if(!digitalRead(CAN0_INT))                         // If CAN0_INT pin is low, read receive buffer
  {
    CAN0.readMsgBuf(&rxId, &len, rxBuf);      // Read data: len = data length, buf = data byte(s)
   
    if((rxId & 0x80000000) == 0x80000000)     // Determine if ID is standard (11 bits) or extended (29 bits)
      sprintf(msgString, "Extended ID: 0x%.8lX  DLC: %1d  Data:", (rxId & 0x1FFFFFFF), len);
    else
      if(rxId==0x288){
        byte data320[8] = {0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x00}; // Kombi1
        byte data420[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; // Kombi2
        byte data520[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; // kombi 3
        // 050H - Airbag 1,
        // 2C0 - Rad 1, 8mms raster, 5 bytes
        // 590 - Level 1, 48ms raster 6 byte
        // 5E0 - Climate, 20ms rast 8 byte
        // 573 - ZAS 1, 2 byte ?
        byte data1A0[8] = {0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x00}; //ABS1
        byte data4A0[8] = {0x00, 0x36, 0x00, 0x36, 0x00, 0x36, 0x00, 0x36}; //ABS3
       
        byte sndStat = CAN0.sendMsgBuf(0x320, 0, 8, data320);
        if(sndStat == CAN_OK){
          Serial.print("320 okay");
        } else {
          Serial.print("320 error");
        }
        sndStat = CAN0.sendMsgBuf(0x420, 0, 8, data420);
        if(sndStat == CAN_OK){
          Serial.print("\t420 okay");
        } else {
          Serial.print("\t420 error");
        }
        sndStat = CAN0.sendMsgBuf(0x520, 0, 8, data520);
        if(sndStat == CAN_OK){
          Serial.print("\t520 okay");
        } else {
          Serial.print("\t520 error");
        }

        sndStat = CAN0.sendMsgBuf(0x1A0, 0, 8, data1A0);
        if(sndStat == CAN_OK){
          Serial.print("\t1A0 okay");
        } else {
          Serial.print("\t1A0 error");
        }

        sndStat = CAN0.sendMsgBuf(0x4A0, 0, 8, data4A0);
        if(sndStat == CAN_OK){
          Serial.print("\t4A0 okay");
        } else {
          Serial.print("\t4A0 error");
        }
        Serial.println();
      } 
  }
}
Logged
fknbrkn
Hero Member
*****

Karma: +177/-18
Online Online

Posts: 1401


mk4 1.8T AUM


« Reply #1 on: June 13, 2022, 02:29:47 AM »

http://nefariousmotorsports.com/forum/index.php?topic=17021.0title=

Motor canbus runs at 1mbit
Logged
timr72
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 8


« Reply #2 on: June 14, 2022, 05:28:04 AM »


Thanks for the link, I had read that thread.  What's interesting is the Arduino code I'm running reads CAN data reliably 0288 0280 etc and I can get all of that data.  I'll have a play around with 1000k and see if that influences the outcome.

Logged
BlackT
Hero Member
*****

Karma: +79/-39
Offline Offline

Posts: 1419



« Reply #3 on: June 14, 2022, 07:39:15 AM »

Motor CAN use 500 kbs, you have good config in code
Logged
tao13
Sr. Member
****

Karma: +16/-46
Offline Offline

Posts: 460


« Reply #4 on: January 30, 2023, 11:33:27 AM »

Do you tried to send some requests on CANBBUS (like pids) and did ecu respond?
I tried something but i think me7.5 doesn't know to respond on CANBUS, it only sent continously some ids.
Logged
prj
Hero Member
*****

Karma: +915/-426
Offline Offline

Posts: 5836


« Reply #5 on: January 30, 2023, 11:43:31 AM »

Do you tried to send some requests on CANBBUS (like pids) and did ecu respond?
I tried something but i think me7.5 doesn't know to respond on CANBUS, it only sent continously some ids.
There is no diagnostics on CAN on ME7.5, only on K-Line.
Logged

PM's will not be answered, so don't even try.
Log your car properly.
tao13
Sr. Member
****

Karma: +16/-46
Offline Offline

Posts: 460


« Reply #6 on: February 01, 2023, 09:25:28 AM »

Thanks again PRJ. From time to time you can be CUTE!
Please tell me if on KWP2000 can see and delete DTC? I saw in NefMotoECUFlasher exist something for DTC.
The initialisation procedure is the same with read variable from memory like ME7logger or not?
Thansk in advance!
« Last Edit: February 01, 2023, 09:32:21 AM by tao13 » Logged
musicleecher
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 5


« Reply #7 on: February 12, 2023, 08:24:43 PM »

Hi All,

I've got as far as I can, but I'm hitting an issue.  I have an ME7.5 ECU and 1.8T engine in my kitcar, none of the other units are there; so no ABS, no Airco, no Dashboard etc.  Although the car runs I am missing a speedo input for the ECU.  I've tried generating ABS pseudo traffic but this is not having the desired effect, I have also tried as Kombi1/2/3 same result.

Is there a way (And how do I do it) to check where the ECU expects to get the speed from Can Kombi, ABS or physical?
..and can I change the ECU to use VSS pulse on I think pin 54?

Binary and data useful attached; ECU and engine are BF/ME7.5 from a 2005 Audi A4 Convertible.


Code:
// CAN Receive and send Example
//

#include <mcp_can.h>
#include <SPI.h>

long unsigned int rxId;
unsigned char len = 0;
unsigned char rxBuf[8];
int EngineTemp;
int RoadSpeed;
int val;
char msgString[128];                        // Array to store serial string
char input[3];

#define CAN0_INT 2                              // Set INT to pin 2
MCP_CAN CAN0(10);                               // Set CS to pin 10


void setup()
{
  Serial.begin(115200);
  
  // Initialize MCP2515 running at 16MHz with a baudrate of 500kb/s and the masks and filters disabled.
  if(CAN0.begin(MCP_ANY, CAN_500KBPS, MCP_16MHZ) == CAN_OK)
    Serial.println("MCP2515 Initialized Successfully!");
  else
    Serial.println("Error Initializing MCP2515...");
  
  CAN0.setMode(MCP_NORMAL);                     // Set operation mode to normal so the MCP2515 sends acks to received data.

  pinMode(CAN0_INT, INPUT);                            // Configuring pin for /INT input
  
  Serial.println("MCP2515 Library Receive Example...");
}

void loop()
{
  if(!digitalRead(CAN0_INT))                         // If CAN0_INT pin is low, read receive buffer
  {
    CAN0.readMsgBuf(&rxId, &len, rxBuf);      // Read data: len = data length, buf = data byte(s)
    
    if((rxId & 0x80000000) == 0x80000000)     // Determine if ID is standard (11 bits) or extended (29 bits)
      sprintf(msgString, "Extended ID: 0x%.8lX  DLC: %1d  Data:", (rxId & 0x1FFFFFFF), len);
    else
      if(rxId==0x288){
        byte data320[8] = {0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x00}; // Kombi1
        byte data420[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; // Kombi2
        byte data520[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; // kombi 3
        // 050H - Airbag 1,
        // 2C0 - Rad 1, 8mms raster, 5 bytes
        // 590 - Level 1, 48ms raster 6 byte
        // 5E0 - Climate, 20ms rast 8 byte
        // 573 - ZAS 1, 2 byte ?
        byte data1A0[8] = {0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x00}; //ABS1
        byte data4A0[8] = {0x00, 0x36, 0x00, 0x36, 0x00, 0x36, 0x00, 0x36}; //ABS3
        
        byte sndStat = CAN0.sendMsgBuf(0x320, 0, 8, data320);
        if(sndStat == CAN_OK){
          Serial.print("320 okay");
        } else {
          Serial.print("320 error");
        }
        sndStat = CAN0.sendMsgBuf(0x420, 0, 8, data420);
        if(sndStat == CAN_OK){
          Serial.print("\t420 okay");
        } else {
          Serial.print("\t420 error");
        }
        sndStat = CAN0.sendMsgBuf(0x520, 0, 8, data520);
        if(sndStat == CAN_OK){
          Serial.print("\t520 okay");
        } else {
          Serial.print("\t520 error");
        }

        sndStat = CAN0.sendMsgBuf(0x1A0, 0, 8, data1A0);
        if(sndStat == CAN_OK){
          Serial.print("\t1A0 okay");
        } else {
          Serial.print("\t1A0 error");
        }

        sndStat = CAN0.sendMsgBuf(0x4A0, 0, 8, data4A0);
        if(sndStat == CAN_OK){
          Serial.print("\t4A0 okay");
        } else {
          Serial.print("\t4A0 error");
        }
        Serial.println();
      }  
  }
}


I'm doing something similar on my 1.8T swapped '82 Toyota Carina. I'm using an ESP32 and a CAN transceiver to communicate with the ECU. Indeed the CAN is 500kbps not 1mbps. I am doing this to build a custom Dashboard for it. Right now I can get RPM and Engine temp. I'd like to get a bit more information but I'm not sure how I'll decode the CAN frames the ECU outputs.
I'm also using the ESP32 to feed VSS to the ECU, I'm getting the actual speed from GPS. I think I might have been able to send good data to the ECU because I felt a difference in power but I haven't been able to test it thoroughly yet.
These are the frames I'm currently sending (not tested thoroughly, might still not be working fine after all):

Code:
#define lo8(x) ((int)(x)&0xff)
#define hi8(x) ((int)(x) >> 8)

... ... ...

    speedL = lo8(speed);
    speedH = hi8(speed);

    CAN_frame_t tx_frame;

    tx_frame.FIR.B.FF = CAN_frame_std;
    tx_frame.MsgID = 0x320; //( 320 Kombi 1 ID - 420 Kombi 2)
    tx_frame.FIR.B.DLC = 8;
    tx_frame.data.u8[0] = 0x00;
    tx_frame.data.u8[1] = (speedL * 100);
    tx_frame.data.u8[2] = (speedH * 100);
    tx_frame.data.u8[3] = 0x00;
    tx_frame.data.u8[4] = 0x00;
    tx_frame.data.u8[5] = 0x00;
    tx_frame.data.u8[6] = 0x00;
    tx_frame.data.u8[7] = 0x00;
    ESP32Can.CANWriteFrame(&tx_frame);

    tx_frame.FIR.B.FF = CAN_frame_std;
    tx_frame.MsgID = 0x1A0; //(ABS1 ID)
    tx_frame.FIR.B.DLC = 8;
    tx_frame.data.u8[0] = 0x18;
    tx_frame.data.u8[1] = speedL;
    tx_frame.data.u8[2] = speedH;
    tx_frame.data.u8[3] = 0x00;
    tx_frame.data.u8[4] = 0xFE;
    tx_frame.data.u8[5] = 0xFE;
    tx_frame.data.u8[6] = 0x00;
    tx_frame.data.u8[7] = 0xFF;
    ESP32Can.CANWriteFrame(&tx_frame);

    tx_frame.FIR.B.FF = CAN_frame_std;
    tx_frame.MsgID = 0x5A0; //(ABS2 ID)
    tx_frame.FIR.B.DLC = 8;
    tx_frame.data.u8[0] = 0xFF;
    tx_frame.data.u8[1] = speedL;
    tx_frame.data.u8[2] = speedH;
    tx_frame.data.u8[3] = 0x01;
    tx_frame.data.u8[4] = 0x00;
    tx_frame.data.u8[5] = lo8(12345);
    tx_frame.data.u8[6] = hi8(12345);
    tx_frame.data.u8[7] = 0xAD;
    ESP32Can.CANWriteFrame(&tx_frame);


The Library I'm using for the CAN comms is called ESP32CAN.
I believe you have to have your ECU configured to accept VSS through CAN instead with CWGGVFZG = 1 (I did not have the opportunity to check your file)

I hope it helps and if you get to test it please post an update Smiley
« Last Edit: February 12, 2023, 08:34:14 PM by musicleecher » Logged
prj
Hero Member
*****

Karma: +915/-426
Offline Offline

Posts: 5836


« Reply #8 on: February 13, 2023, 03:28:02 AM »

Speed via GPS is horrible, better not send any speed at all.

All the info about can frames of this ECU is in the FR.
Logged

PM's will not be answered, so don't even try.
Log your car properly.
musicleecher
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 5


« Reply #9 on: February 13, 2023, 10:07:23 AM »

Speed via GPS is horrible, better not send any speed at all.

All the info about can frames of this ECU is in the FR.

Why do you think it is horrible?


I can always resort to reading the ABS rings on the front wheels and calculating Km/h
Logged
prj
Hero Member
*****

Karma: +915/-426
Offline Offline

Posts: 5836


« Reply #10 on: February 13, 2023, 10:12:13 AM »

Why do you think it is horrible?
Because speed especially matters to ECU during starting/stopping. And GPS is too slow for that.
Quote
I can always resort to reading the ABS rings on the front wheels and calculating Km/h
Much better option.
Logged

PM's will not be answered, so don't even try.
Log your car properly.
musicleecher
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 5


« Reply #11 on: February 13, 2023, 11:46:25 AM »

Because speed especially matters to ECU during starting/stopping. And GPS is too slow for that.

Thanks for the clarification! Much appreciated!

BTW, If you're willing to help, do you know at what rate the ECU expects the VSS messages? Like I can flood the ECU with the CAN messages but I'd much rather send them from x ms to x ms..
Logged
fknbrkn
Hero Member
*****

Karma: +177/-18
Online Online

Posts: 1401


mk4 1.8T AUM


« Reply #12 on: February 13, 2023, 11:54:55 AM »

Thanks for the clarification! Much appreciated!

BTW, If you're willing to help, do you know at what rate the ECU expects the VSS messages? Like I can flood the ECU with the CAN messages but I'd much rather send them from x ms to x ms..

Just read the FR, CAN module
but imo its not worth, works fine without
Logged
musicleecher
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 5


« Reply #13 on: February 13, 2023, 01:01:54 PM »

Just read the FR, CAN module
but imo its not worth, works fine without

Does it? I'd say otherwise because the engine feels like it's not producing full power without VSS
Logged
prj
Hero Member
*****

Karma: +915/-426
Offline Offline

Posts: 5836


« Reply #14 on: February 13, 2023, 03:37:41 PM »

Does it? I'd say otherwise because the engine feels like it's not producing full power without VSS
VSS does not affect power.
Also, leave your "feels" for your partner and use logging for the ECU.
Logged

PM's will not be answered, so don't even try.
Log your car properly.
Pages: [1] 2
  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Page created in 0.026 seconds with 18 queries. (Pretty URLs adds 0.001s, 0q)