i don’t know if there is another way
what i did is put the arduino on the bus
in a custom pid a program a standard PID that normally the ecu doesn’t answer
arduino is monitoring that request and then respond in it’s place like the ecu would normally do it
torque doesn’t see any difference
here is an exemple of my code
/*********************************************************************
* Mechanic – Hacking your car
*
* Copyright (C) 2013 Joerg Pleumann
*
* This example is free software; you can redistribute it and/or
* modify it under the terms of the Creative Commons Zero License,
* version 1.0, as published by the Creative Commons Organisation.
* This effectively puts the file into the public domain.
*
* This example 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
* LICENSE file for more details.
*/
#include
ObdInterface obd;
ObdMessage out;
ObdMessage in;
int SensorValue = 0;
float PsiValue = 0;
float Temp;
int ValuePID90xA;
int ValuePID90xB;
int ValuePID08xA;
void setup() {
Serial.begin(115200);
//while (!Serial);
Serial.println();
Serial.println();
Serial.println(” ADDR LN MO PI D0 D1 D2 D3 D4″);
Serial.println(“——– — — — — — — — –“);
obd.setSlow(false);
obd.setExtended(false);
obd.setDebug(false);
obd.setNoFilter(false); // Show all messages, not just ECU answers
obd.begin();
out.address = 0x7e8;
out.mode = 0x41;
}
void loop() {
if (obd.receiveMessage(in)) {
Serial.println(in);
if (in.pid == 0x90) { // Si pid est 90 envoie la valeur courante
Serial.println(“sending”);
Serial.print(” PID 0x90,Sensor “);Serial.print(SensorValue);
Serial.print(” Psi: “); Serial.print(PsiValue);
Serial.print(” A: “); Serial.print(ValuePID90xA);
Serial.print(” B: “); Serial.println(ValuePID90xB);
out.address = 0x7e8;
out.length = 0x4;
out.pid = 0x90;
out.values[0] = ValuePID90xA;
out.values[1] = ValuePID90xB;
obd.sendMessage(out);
}
if (in.pid == 0x08) { // Si pid est 08 envoie la valeur courante
Serial.println(“sending”);
Serial.print(” PID 0x08,Sensor “);Serial.print(SensorValue);
Serial.print(” A: “); Serial.println(ValuePID08xA);
out.address = 0x7e8;
out.length = 0x4;
out.pid = 0x08;
out.values[0] = ValuePID08xA;
out.values[1] = 0;
obd.sendMessage(out);
}
}
// Valeur pour PID 0x90
SensorValue = analogRead(A0) + 1;
PsiValue = (45.6125*SensorValue/1024) + 0.148721; // 5 Volts ou 1024 = 45.6125 Psi, 0.148721 il y a un leger offset dans les valeurs
ValuePID90xA = (int) PsiValue;
Temp = (PsiValue – ValuePID90xA) * 100;
ValuePID90xB = (int) Temp;
/*
Serial.print(” PID 0x90,Sensor “);Serial.print(SensorValue);
Serial.print(” Psi: “); Serial.print(PsiValue);
Serial.print(” A: “); Serial.print(ValuePID90xA);
Serial.print(” B: “); Serial.println(ValuePID90xB);
*/
// Valeur pour PID 0x08
ValuePID08xA = map(SensorValue,0,1024,0,256); // 5 Volts ou 1024 = 45.6125 Psi et modifier en 0 a 255 et envoye comme pid de short trim bank 2
/*
Serial.print(” PID 0x08,Sensor “);Serial.print(SensorValue);
Serial.print(” A: “); Serial.println(ValuePID08xA);
*/
delay(20);
}
|