New!!OBD2 Com with Xsim3 and Arduino-New!!

Dashboard, gauge projects etc.
Please use the image gallery for your pictures, a short tutorial can be found here.
The first image in the first post will be shown in the project gallery.

Re: New!!OBD2 Com with Xsim3 and Arduino-New!!

Postby sliversgyj » Fri 27. Sep 2013, 15:50

vicpopo wrote:Hi Prodigy ,

Here is the answer for the request about the obd2 pid available on xsim .

OBD2 does only output:

//05 coolant temperature
//0C RPM *4
//0D Speed in kmh
//E0 GEAR with 1 as offset (not elm327 complaint)
//E1 Position (not elm327 complaint)
//E2 Current Lap (not elm327 complaint)
//E3 Best laptime (not elm327 complaint)

Regards

How to get BestLaptime?
my code as follows,but always get -1 return back.What's wrong?

int GetOBD2BestLapTimeValue()
{
Serial.write('0');
Serial.write('1');
Serial.write('e');
Serial.write('3');
Serial.write('\r');
return ReceiveValueWithTimeout('4','E','3',10);
}
sliversgyj
X-Sim Supporter
 
Posts: 37
Images: 34
Joined: Sun 3. Mar 2013, 13:00
Has thanked: 2 times
Been thanked: 2 times

Re: New!!OBD2 Com with Xsim3 and Arduino-New!!

Postby sliversgyj » Sat 28. Sep 2013, 09:55

I will use RPM to trigger the rpm led,But following code make the RPM show very slowly
for(int z=0; z < 1500; z++)//1500ms timeout should be enough
I try to chang 1500 to 200,it much better,but still not quick enough.When I change to 100,the receive will be failure.
I also want to change "Serial.begin(9600);",but it also not possible to do that.
Is there any way to make the OBD2 comunication more real time?
BTW,when I use USO,I never met such realtime issue.Acctucally I also not know why OBD2 is better than USO till * ;)
sliversgyj
X-Sim Supporter
 
Posts: 37
Images: 34
Joined: Sun 3. Mar 2013, 13:00
Has thanked: 2 times
Been thanked: 2 times

Re: New!!OBD2 Com with Xsim3 and Arduino-New!!

Postby sirnoname » Sat 28. Sep 2013, 17:22

OBD2 is realtime and faster than USO.
You have other problems with your written code as your last post shows with laptime.
If a answer is correct or did help you for a solution, please use the solve button.
User avatar
sirnoname
Site Admin
 
Posts: 1829
Images: 45
Joined: Thu 1. Sep 2011, 22:02
Location: Munich, Germany
Has thanked: 35 times
Been thanked: 128 times

Re: New!!OBD2 Com with Xsim3 and Arduino-New!!

Postby sliversgyj » Sat 28. Sep 2013, 19:22

sirnoname wrote:OBD2 is realtime and faster than USO.
You have other problems with your written code as your last post shows with laptime.

Hi sirnoname,
Is that mean because of the wrong laptime receive function,which let the "for" loop cost 1500ms? then make the display unrealtime?

And How should I change laptime receive function?
int GetOBD2BestLapTimeValue()
{
Serial.write('0');
Serial.write('1');
Serial.write('e');
Serial.write('3');
Serial.write('\r');
return ReceiveValueWithTimeout('4','E','3',10);
}

Please help,Thanks!
sliversgyj
X-Sim Supporter
 
Posts: 37
Images: 34
Joined: Sun 3. Mar 2013, 13:00
Has thanked: 2 times
Been thanked: 2 times

Re: New!!OBD2 Com with Xsim3 and Arduino-New!!

Postby sirnoname » Sat 28. Sep 2013, 20:33

You are right, there cannot be a -1 which is a maximum wait delay :)
You must ask vicpopo if he has same problems with laptime. Or you simple use a very old X-Sim version where laptime is not included.
If a answer is correct or did help you for a solution, please use the solve button.
User avatar
sirnoname
Site Admin
 
Posts: 1829
Images: 45
Joined: Thu 1. Sep 2011, 22:02
Location: Munich, Germany
Has thanked: 35 times
Been thanked: 128 times

Re: New!!OBD2 Com with Xsim3 and Arduino-New!!

Postby vicpopo » Sat 28. Sep 2013, 21:00

sirnoname wrote:You are right, there cannot be a -1 which is a maximum wait delay :)
You must ask vicpopo if he has same problems with laptime. Or you simple use a very old X-Sim version where laptime is not included.

Hi ,

I not tested yet the laptime with the arduino code.The only thing I noticed when checking in input values menu on converter is that during the first lap just the value -1000 sent.After one lap drived the value laptime began to be counted (game gtr2) .

User avatar
vicpopo
 
Posts: 645
Joined: Fri 20. Apr 2012, 18:04
Location: Strasbourg France
Has thanked: 39 times
Been thanked: 80 times

Re: New!!OBD2 Com with Xsim3 and Arduino-New!!

Postby sliversgyj » Sun 29. Sep 2013, 07:18

sirnoname wrote:You are right, there cannot be a -1 which is a maximum wait delay :)
You must ask vicpopo if he has same problems with laptime. Or you simple use a very old X-Sim version where laptime is not included.

Thank for your confirm!
The value of laptime can be seen in "input setup",so I think it is supported.
I will debug ParseReceiveBuffer function try to find out the reason.
BTW,I found another inconvience issue.When I set OBD2,the com port will not be use by my arduino IDE.I have to close the Extractor to let the com port release(it also not work,when I remove the OBD2 com port in setting pannel),then I can upload the code to my arduino board.After that open x-sim again to have a test.
Is there any easy way to upload code and test?
Thanks again!
sliversgyj
X-Sim Supporter
 
Posts: 37
Images: 34
Joined: Sun 3. Mar 2013, 13:00
Has thanked: 2 times
Been thanked: 2 times

Re: New!!OBD2 Com with Xsim3 and Arduino-New!!

Postby sliversgyj » Sun 29. Sep 2013, 08:41

vicpopo wrote:
sirnoname wrote:You are right, there cannot be a -1 which is a maximum wait delay :)
You must ask vicpopo if he has same problems with laptime. Or you simple use a very old X-Sim version where laptime is not included.

Hi ,

I not tested yet the laptime with the arduino code.The only thing I noticed when checking in input values menu on converter is that during the first lap just the value -1000 sent.After one lap drived the value laptime began to be counted (game gtr2) .

402087557.781988.jpg

Hi vicpopo,
I also test "curent position",it also not work,have you test it?
Acctually,I'm also not clear with the OBD2 command we use.
Is such command(like E0,E1...) is defined by Xsim or defined by OBD2 protocol?
And How do we know it is supported or not in xsim?
Thanks!
sliversgyj
X-Sim Supporter
 
Posts: 37
Images: 34
Joined: Sun 3. Mar 2013, 13:00
Has thanked: 2 times
Been thanked: 2 times

Re: New!!OBD2 Com with Xsim3 and Arduino-New!!

Postby vicpopo » Sun 29. Sep 2013, 10:20

Hi ,

First you remember this post :http://www.x-sim.de/forum/viewtopic.php?f=40&t=1083&start=30#p9937

That means for me that the pid for current lap is given by obd2 protocol that Sirnoname programed.

I didn't yet tested but below my proposition to proceed :

1- As I wrote in a previous post you have tu drive one complete lap before showing current lap time counted .The first thing is to check in input menu that the current lap time will change form -1000 to numerical value . I didn't remember which data format but in thousands (32 547?) .Write both values the one in input value and the one in game display .After you can calculate the data format.
Sirnoname wrote that the 2 word 4* ** 00 00 the last two words represents ms .The thing I not checked is if this value is the difference or the total current time lap.

Exemple : you finished a lap and your time is 1min 42 s 23 43 ,
that means that the value in ms is 102 234 ms or 01 8F 5A in Hex .There are 3 words not 2 as the pid give.

That the point I 'm with ths current time lap.
User avatar
vicpopo
 
Posts: 645
Joined: Fri 20. Apr 2012, 18:04
Location: Strasbourg France
Has thanked: 39 times
Been thanked: 80 times

Re: New!!OBD2 Com with Xsim3 and Arduino-New!!

Postby sliversgyj » Sun 29. Sep 2013, 14:46

I try to test the time cost of ReceiveValueWithTimeout for a successful received command.
I will also cost about 50~80ms.that's mean if we received 3 type of data(speed,gear,rpm) it will cost about 200ms,
I'm not sure if it is realtime enough? if not how to improve it?
sliversgyj
X-Sim Supporter
 
Posts: 37
Images: 34
Joined: Sun 3. Mar 2013, 13:00
Has thanked: 2 times
Been thanked: 2 times

PreviousNext

Return to Peripheral Projects

Who is online

Users browsing this forum: No registered users and 2 guests