Hay guys i working on project for datalogging from car ECU (Honda Civic 92 Chipped P28 Ecu)
Now my problem is when i plug in and my car don't want to start seems like arduino sending some packets to ecu unless just reciving it :/
int Display_Rpm = 0;
int Display_Vss = 0;
float Display_BATT = 0;
float Display_TPS = 0;
float Display_IGN = 0;
float Display_CONSUM = 0;
#include <EEPROM.h>
#include <LiquidCrystal_I2C.h>
#include <avr/pgmspace.h>
#include "Wire.h"
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
void setup()
{
Serial.begin(38400);
Screen();
GetData();
}
void loop()
{
GetData();
Refresh_data();
}
Script no2 by Boulet Marc:
//Set Your Injector Size. Default : 240cc
int injsize = 240;
//Set the Datalogging Addresse to the correct one for your ECU (these addresse are for Crome >= 1.4, Work with P30 bin)
byte ADDR_RPMLOW = 0x10;
byte ADDR_RPMHIGH = 0x11;
byte ADDR_TPS = 0x15;
byte ADDR_INJLOW = 0x17;
byte ADDR_INJHIGH = 0x18;
byte ADDR_IGN = 0x19;
byte ADDR_VSS = 0x1C;
byte ADDR_BATT = 0x1F;
unsigned int ecuTimeout = 5000;
void GetData()
{
//Get RPM&Speed Raw Values
float speedRaw=ecuRead(ADDR_VSS);
unsigned int rpmLowRaw=ecuRead(ADDR_RPMLOW);
unsigned int rpmHighRaw=ecuRead(ADDR_RPMHIGH);
int RPM = 1851562/((rpmHighRaw * 256) + rpmLowRaw);
//Reset Rpm Display
if (RPM < 0) {
RPM = 0;
} else if (RPM > 9999) {
RPM = 9999;
}
//Set RPM & Speed Display
Display_Rpm = RPM;
Display_Vss = speedRaw; //KMH
//Get&Set All Others Displays
float tpsRaw=ecuRead(ADDR_TPS);
unsigned int lowInjRaw=ecuRead(ADDR_INJLOW);
unsigned int highInjRaw=ecuRead(ADDR_INJHIGH);
unsigned int ignRaw=ecuRead(ADDR_IGN);
float batteryRaw = ecuRead(ADDR_BATT);
Display_BATT = (26.0 * batteryRaw) / 270.0;
Display_TPS = constrain(tpsRaw, 0, 100);
Display_IGN = (0.25 * ignRaw) - 6;
Display_CONSO = constrain(calcConso(), 0.0001, 50.0);
if(Display_Rpm<30)
{
Display_Rpm = 0;
}
}
byte ecuRead(byte ecuAddress)
{
Serial.write(ecuAddress);
unsigned int time=0;
while(Serial.available() == 0 && time < ecuTimeout) time+=1;
if (time >= ecuTimeout) return 0x00;
else return Serial.read();
}
float calcConso()
{
unsigned int lowInjRaw=ecuRead(ADDR_INJLOW);
unsigned int highInjRaw=ecuRead(ADDR_INJHIGH);
float injValue = ((highInjRaw * 256) + lowInjRaw) / 352;
float dutyCycle = (Display_Rpm * injValue) / 1200;
float hundredkm = ((60 / Display_Vss) * 100) / 60; //minutes needed to travel 100km
return (hundredkm * ((injsize / 100) * dutyCycle)) / 1000;
}
Screen Script:
void Screen()
{
lcd.begin(20, 4);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("hY IM WORKING!");
delay(1500);
lcd.clear();
}
void Refresh_data()
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("R:");
lcd.setCursor(2,0);
lcd.print(Display_Rpm);
}