Honda CBR 1000RR Forums banner

1 - 13 of 13 Posts

·
Registered
Joined
·
1,002 Posts
Discussion Starter #1
Whipped up a simple circuit to interface with the K-Line interface found on that red adapter under the seat. The goal is to be able to read things like throttle position, rpm, speed and log that with GPS data and 3-axis info.

Also got some basic python code working to initialize the ecu and request some data.



Code:
[email protected]:~# python kline2.py 
====== INIT ======
['fe', '04', 'ff', 'ff']
['72', '05', '00', 'f0', '99']
['02', '04', '00', 'fa']

====== INFO ======
['72', '07', '72', '11', '00', '14', 'f0']
['02', '1a', '72', '11', '00', '00', '00', '18', '00', 'b5', '34', 'af', '36', '8f', '61', 'ff', 'ff', '78', '00', '00', '00', '80', '57', '1d', 'f7', '2a']
('RPM', ['00', '00'], 0)
('TPS', ['18', '00'], 24)
('ECT', ['b5', '34'], 13493)
('IAT', ['af', '36'], 13999)
Code:
from pylibftdi import Device, BitBangDevice
import time
from struct import unpack

def imsg(i):
	return ["{:02x}".format(ord(c)) for c in i]

port = BitBangDevice()
port.open()
port.direction = 0x01
port.port = 0
time.sleep(.07)
port.port = 1
time.sleep(.130)
port.close()

with Device() as dev:
	print("====== INIT ======")
	dev.ftdi_fn.ftdi_set_bitmode(1, 0x01)
	dev.write('\x00')
	time.sleep(.050)
	dev.write('\x01')
	time.sleep(.130)
	dev.ftdi_fn.ftdi_set_bitmode(0, 0x00)
	dev.ftdi_fn.ftdi_set_line_property(8, 1, 0)
	dev.baudrate = 10400
	dev.flush()
	dev.write('\xfe\x04\xff\xff')
	time.sleep(.05)
	print(imsg(dev.read(4)))
	dev.write('\x72\x05\x00\xf0\x99')
	time.sleep(.05)
	print(imsg(dev.read(5)))
	print(imsg(dev.read(4)))
	print("")
	print("====== INFO ======")
	dev.write('\x72\x07\x72\x11\x00\x14\xf0')
	time.sleep(.05)
	print(imsg(dev.read(7)))
	i = dev.read(26)
	print(imsg(i))
	print("RPM",imsg(i[5:7]), unpack('h', i[5:7])[0])
	print("TPS",imsg(i[7:9]), unpack('h', i[7:9])[0])
	print("ECT",imsg(i[9:11]), unpack('h', i[9:11])[0])
	print("IAT",imsg(i[11:13]), unpack('h', i[11:13])[0])
 

·
Registered
Joined
·
1,041 Posts
Whoa hold on a sec here - you mean a stock pre-2017 has an interface under the seat and a 3-axis accelerometer is built in?????
 

·
Premium Member
Joined
·
1,516 Posts
I interpreted that he was getting accelerometer data from something like a smartphone or other external GPS device. I recommend something with at least a 10Hz sample rate.
 

·
Registered
Joined
·
1,002 Posts
Discussion Starter #5
Whoa hold on a sec here - you mean a stock pre-2017 has an interface under the seat and a 3-axis accelerometer is built in?????
No, the only thing under the seat is the DLC connector, which has the K-Line signal, its basically OBD1. Some bikes vendors seem to use the KWP2000 message format to communicate along the K-Line, but Honda uses a slight variation of it.

I am building a laptimer/datalogger system based on the $35 dollar Raspberry Pi 3. I have found a 20hz GPS module for it that runs about $40 and there are various 3-axis chips for under $20 that could be used.
 

·
Registered
Joined
·
1,002 Posts
Discussion Starter #6
The code is getting cleaner, was able to process more of the fields from table 16:

Code:
[email protected]:~# python kline.py 
['02', '1a', '72', '11', '00', '00', '00', '18', '00', 'b6', '33', 'b1', '35', '8f', '61', 'ff', 'ff', '75', '00', '00', '00', '80', '57', '1e', '85', '9d']
['00', '00', '18', '00', 'b6', '33', 'b1', '35', '8f', '61', 'ff', 'ff', '75', '00', '00', '00', '80', '57', '1e', '85']
(0, 24, 0, 182, 51, 177, 53, 143, 97, 255, 255, 117, 0, 0, 0, 128, 87, 30, 133)
('RPM', 0)
('TPS_volt', 0.46875)
('TPS_percent', 0.0)
('ECT_volt', 3.5546875)
('ECT_deg_C', 11)
('IAT_volt', 3.45703125)
('IAT_deg_C', 13)
('MAP_volt', 2.79296875)
('MAP_kpa', 97)
('BATT_volt', 11.7)
('SPEED_kph', 0)
 

·
Registered
Joined
·
1,002 Posts
Discussion Starter #7
New code is up: https://github.com/RyanHope/HondaECU/blob/master/HondaECU.py

Also, I've scanned all of the data tables from 0-255 and these are the ones that return something:

Code:
['02', '0f', '71', '00', '01', '00', 'f3', '04', '01', '01', '00', '00', '00', '00', '84']
['02', '19', '71', '11', '00', '00', '17', '00', 'b6', '33', 'af', '36', '8f', '61', 'ff', 'ff', '81', '00', '00', '00', '80', '57', '1e', '85', '95']
['02', '08', '71', '20', 'ff', '80', '00', 'e6']
['02', '19', '71', '61', '00', '00', '11', '00', 'a8', '39', 'ff', '00', 'fd', 'b0', 'ff', 'ff', '7b', '05', '00', '00', '80', '00', '00', '00', '77']
['02', '08', '71', '70', 'ff', '80', '00', '96']
['02', '13', '71', 'd0', '8b', '00', '00', '00', '00', '73', '72', '00', '00', '00', '00', '00', '00', '00', '3a']
['02', '0b', '71', 'd1', '01', '00', '00', '00', '00', '00', 'b0']
 

·
Registered
Joined
·
1,041 Posts
No, the only thing under the seat is the DLC connector, which has the K-Line signal, its basically OBD1. Some bikes vendors seem to use the KWP2000 message format to communicate along the K-Line, but Honda uses a slight variation of it.

I am building a laptimer/datalogger system based on the $35 dollar Raspberry Pi 3. I have found a 20hz GPS module for it that runs about $40 and there are various 3-axis chips for under $20 that could be used.
Gotcha. I picked up a few GY-521 3-axis gyroscope + accelerometers on ebay for a few dollars each. I had a crazy plan to make a headlight with projectors that stayed oriented to the road when the bike leaned.

I also had an idea to make my own 3d-mapped QS which would need that data to determine cut times. I was going to use the Pi Zero since neither would require that much computing power.
 

·
Registered
Joined
·
1,002 Posts
Discussion Starter #9
Need some help trying to decode some information:
Code:
off-cold-N-1700-0: ('20', 3, ['ff', '80', '00'])
on-cold-N-1700-0: ('20', 3, ['ff', '80', '00'])
on-38C-N-1700-0: ('20', 3, ['ff', '80', '00'])
on-44C-N-1700-0: ('20', 3, ['28', '80', '01'])
on-65C-N-1400-0: ('20', 3, ['2e', '80', '01'])
on-74C-1-1300-14: ('20', 3, ['2e', '80', '01'])
on-76C-N-1220-0: ('20', 3, ['2c', '80', '01'])
^^ This seems to be related to startup procedure since the values change as the bike is warming up.
 

·
Registered
Joined
·
1,002 Posts
Discussion Starter #10
Well this just keeps getting more and more fun. I have found some trouble code related info and I have managed to dump the whole ECU. Shouldn't be long before I can do my own flashes :D
 

·
Registered
Joined
·
4 Posts
Hi ! I'm very interested by your work.
I actually try to connect an arduino with the ECU. Could you help me for the code ?
I fail to initilize the device and I don't understand python (never used that).

Here is the begining of my code, could you tell my what's wrong? :
byte wakeup[]={0xFE, 0x04, 0xFF, 0xFF};
byte initialise[]={0x72, 0x05, 0x00, 0xF0, 0x99};
byte answer[]={0x02,0x04,0x00,0xFA};
byte message[24];
int RX1 = PA10;
int TX1 = PA9;
bool connection=false;
bool goodrep=false;

void setup() {
delay(2000);
pinMode(TX1,OUTPUT);
pinMode(RX1,INPUT);
Serial1.begin(5); // 5 Baud init
Serial.begin(115200);
while(connection==false){
delay(3000);
Serial.println("Starting initilization");
// digitalWrite(TX1,HIGH);
// delay(10);
digitalWrite(TX1,LOW);
delay(70);
digitalWrite(TX1,HIGH);
delay(120);
Serial1.end();
delay(20);
Serial.println("WAKEUP signal");
Serial1.begin(10400);
for (int i=0;i<sizeof(wakeup);i++){
Serial1.write(wakeup);
delay(5);
}
delay(50);
for (int i=0;i<sizeof(initialise);i++){
Serial1.write(initialise);
delay(5);
}

Serial.println("Waiting response");
for (int i=0;i<4;i++){
while(Serial1.available()==0);
Serial.println("In progress...");
message = Serial1.read();
Serial.print(message,HEX);
Serial.print(" ");
}

Serial.println("response analysis");
int j=0;
while(j<4){
if(answer[j]==message[j]){
j++;
goodrep=true;
}else{
goodrep=false;
Serial.println("Bad response, re-trying");
break;
}
}
if (goodrep==true){
connection=true;
Serial.println("Connected !");
}
}
}
 
1 - 13 of 13 Posts
Top