Go Back   EcoModder Forum > EcoModding > Instrumentation > OpenGauge / MPGuino FE computer
Register Now
 Register Now
 

Reply  Post New Thread
 
Submit Tools LinkBack Thread Tools
Old 03-06-2012, 04:18 AM   #41 (permalink)
toc
EcoModding Apprentice
 
Join Date: Jan 2011
Location: Australia
Posts: 179

Sonata97 - '97 Hyundai Sonata GL
90 day: 25.96 mpg (US)

Pulsar - '03 Nissan Pulsar ST
Team Nissan
90 day: 36.09 mpg (US)

Lancer - '04 Mitsubishi Lancer
90 day: 31.11 mpg (US)

Lancer 2.0 - '09 Mitsubishi Lancer
90 day: 27.1 mpg (US)
Thanks: 9
Thanked 16 Times in 13 Posts
Set it to 100 or 200. Won't matter much.

#define MAX_WAIT_TIME 100


int fetch_data(byte cmd) {
int dat[3];
int temp;
int i;
Serial.write(cmd);
starttime = millis();
while ((Serial.available()<2) && ( (millis() - starttime) < MAX_WAIT_TIME) ) {
//do nothing
}
if (Serial.available()<2) {
wireless.print("Error - 2 Bytes not found - We did get:");
wireless.println(Serial.read(), HEX);
Serial.flush();
} else {
i = 0;
delay(10);
while (Serial.available() > 0) {

temp = Serial.read();
wireless.print("Dat ");
wireless.print(i);
wireless.print(": ");
wireless.print(temp, HEX);
dat[i] = temp;
i++;
//dat[0] should be the cmd we sent
//dat[1] should be the result of the cmd.
}
Serial.flush();
return dat[1];
}

}

void loop()
{
int temp_val;
int temp_real_val;
wireless.println("Testing at 1920bps");
wireless.print("RPM: Result:");
temp_val = fetch_data(0x21);
temp_real_val = temp_val * 31.25;
wireless.print(temp_val, HEX);
wireless.print("|RPM Val: ");
wireless.println(temp_real_val);

You should be able to fetch the HEX value - 0x21, and convert to DEC then multiply by 31.25.

Looks like I missed the convert to dec perhaps..


If you are still having problems, give us a look at the parameter you are requesting (RPM is a good one), tell us the hex value of the response, and what value you are getting..

__________________
  Reply With Quote
Alt Today
Popular topics

Other popular topics in this forum...

   
Old 03-06-2012, 08:55 PM   #42 (permalink)
EcoModding Lurker
 
Join Date: Nov 2011
Location: malaysia
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Thanks again TOC,

I will give the result as soon as possible TOC. By the way, i still do not know why in MMCd source code using the function below to get the value. Have a look at the source code:

Code:
// Engine speed, 0..8000 rpm
// 31.25 * x
Int16 f_ERPM(UInt8 d, Char *s) {
	Int32 v = 2048000L * d;
	return StrPrintF(s, "%ldrpm", v >> 16);
}
Where does the value 2048000L is coming. If I'm not wrong the 'L" is use for formatting the data value

Arduino IntegerConstants
arduino.cc/en/Reference/IntegerConstants

Quote:
U & L formatters

By default, an integer constant is treated as an int with the attendant limitations in values. To specify an integer constant with another data type, follow it with:

a 'u' or 'U' to force the constant into an unsigned data format. Example: 33u
a 'l' or 'L' to force the constant into a long data format. Example: 100000L
a 'ul' or 'UL' to force the constant into an unsigned long constant. Example: 32767u
  Reply With Quote
Old 03-07-2012, 02:06 AM   #43 (permalink)
EcoModding Lurker
 
Join Date: Nov 2011
Location: malaysia
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Ok i get the clue now.

Since the maximum RPM was set to 8000, and the RPM range value is 0-255.
Therefore 8000/256 = 31.25

But still wondering about 31.25*8000=2048000
  Reply With Quote
Old 03-09-2012, 02:04 AM   #44 (permalink)
EcoModding Lurker
 
Join Date: Nov 2011
Location: malaysia
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Here is the 1G DSM, Mitsubishi 4g93,4g92,4g91 ecu protocol. I get it from the web archive of http://www.syndicate.evilsoft.org/pr..._Protocol.html

Code:
Sensor	 	    |	Address	   |	Data Min	 |	Data Max     | 		Function 	|	Sample
=============================================================================================================================
Accel Enrichment 	0x1D 		0x01 == 0% 		0xFF == 100% 		y = 100(x/255) 		%
Coolant Temp 		0x07 		0x01 == 307deg F 	0xFF == -62deg F 	y = -1.45x + 308 	deg F
Engine Speed 		0x21 		0x01 == 31 		0xFF == 7969 		y = 31.25x 		rpm
Fuel Trim High 		0x0E 		0x01 == 1% 		0xFF == 199% 		y = .78x 		%
Fuel Trim Low 		0x0C 		0x01 == 1% 		0xFF == 199% 		y = .78x 		%
Fuel Trim Middle 	0x0D 		0x01 == 1% 		0xFF == 199% 		y = .78x 		%
Injector Pulse Width 	0x29 		0x01 == .256ms 		0xFF == 65.3ms 		y = .256x 		ms
Oxygen Feedback Trim 	0x0F 		0x01 == 1% 		0xFF == 199% 		y = .78x 		%
Oxygen Sensor 		0x13 		0x01 == .02v 		0xFF == 4.98v 		y = .0195x 		v
Throttle Position 	0x17 		0x01 == 0% 		0xFF == 100% 		y = 100(x/255) 		%
Air Flow Hz 		0x1A 		0x01 == 6Hz 		0xFF == 1606Hz 		y = 6.29x 		Hz
Air Temperature 	0x3A 		0x01 == 356deg F 	0xFF == -74deg F 	y = -1.69x + 358 	deg F
Air Volume 		0x2C 		0x01 == 1 		0xFF == 255 		y = x 	
Barometer 		0x15 		0x01 == 0bar 		0xFF == 1.24bar 	y = .00486x 		bar
ISC Steps 		0x16 		0x01 == 1 		0xFF == 255 		y = x 	
Knock Sum 		0x26 		0x01 == 1 		0xFF == 255 		y = x 	
Timing Advance 		0x06 		0x01 == -9 deg 		0xFF == 245 deg 	y = x - 10 		deg
Battery 		0x14 		0x01 == 0.1v 		0xFF == 18.7v 		y = .0733x 		v
EGR Temperature 	0x12 		0x01 == 595deg F 	0xFF == -94deg F 	y = -2.7x + 597.7	deg F 
TDC 			0x02 		0x04 (inverted) 			
Power Steering 		0x02 		0x08 (inverted) 			
AC Switch 		0x02 		0x10 (inverted) 			
Park/Neutral 		0x02 		0x20 (inverted) 			
Idle Switch 		0x02 		0x80 (inverted) 			
AC Clutch 		0x00 		0x20 (inverted)
So i made a mistake on the last post calculation:
The correct formula for RPM (refer to calculation table)
7969/255 = 31.25 for each incremental number of 255
  Reply With Quote
Old 03-09-2012, 02:40 AM   #45 (permalink)
toc
EcoModding Apprentice
 
Join Date: Jan 2011
Location: Australia
Posts: 179

Sonata97 - '97 Hyundai Sonata GL
90 day: 25.96 mpg (US)

Pulsar - '03 Nissan Pulsar ST
Team Nissan
90 day: 36.09 mpg (US)

Lancer - '04 Mitsubishi Lancer
90 day: 31.11 mpg (US)

Lancer 2.0 - '09 Mitsubishi Lancer
90 day: 27.1 mpg (US)
Thanks: 9
Thanked 16 Times in 13 Posts
I'm not sure I see a problem ?
Are you getting data OK?
__________________
  Reply With Quote
Old 03-09-2012, 02:57 AM   #46 (permalink)
EcoModding Lurker
 
Join Date: Nov 2011
Location: malaysia
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Hi Toc,

I still don't have enough time to check the data because 2 of my sons were admitted in hospital.
Hopefully i can check it on this week. I will get you if all data still incorrect.

Thanks again...

  Reply With Quote
Reply  Post New Thread


Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
MPGuino release one workspace dcb OpenGauge / MPGuino FE computer 1061 01-17-2020 01:37 AM
NHW11 pig-tail fixes OBD scanner issue bwilson4web Hybrids 0 06-11-2010 08:45 AM
Graham mini scanner - Quick User's Guide bwilson4web Hybrids 2 11-27-2009 08:58 AM



Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Content Relevant URLs by vBSEO 3.5.2
All content copyright EcoModder.com