Splitting up the call and receive?

Inquiry and support for Freematics products
Post Reply
mike944
Posts: 2
Joined: Fri Jul 01, 2016 12:07 pm

Splitting up the call and receive?

Post by mike944 »

I'm using the OBDII UART adapter in an application, hooked up to an Arduino Mega, where i want to read OBDII data, in addition to reading 16 analog inputs off the Mega (and other things)

The problem comes in that i can process the 16 channels of analog WAY faster than i can read from the OBDII port. I can read and process the 16 channels of analog data at like 80HZ. The OBDII data, depending on how many requests i send, can maybe be read at 2-10HZ. the more requests i send, the slower the loop.

So, my goal is that I don't want to slow down the loop, while waiting for OBDII data. I thought perhaps that i could send a "call" to the OBDII port for data, continue processing my other things, and then maybe some number of loops later (10-20), i'd read data waiting at the incoming buffer. I can't seem to figure out how to do this.


I've been trying to figure out the code posted on Github, and trying to separate it into send & receive, but no luck. Anyone try this before with any luck?
stanley
Site Admin
Posts: 1039
Joined: Sat Mar 01, 2014 3:15 am

Re: Splitting up the call and receive?

Post by stanley »

The access speed of OBD-II PIDs really depend on how fast your car's ECU can work and this varies a lot among different cars. You can do all your jobs while waiting for OBD data in your derived dataIdleLoop() which is a callback function. You can refer to MegaLogger sketch (line 73) for how to do this.
mike944
Posts: 2
Joined: Fri Jul 01, 2016 12:07 pm

Re: Splitting up the call and receive?

Post by mike944 »

Ok, i see the DataIdleLoop() function defined, as you pointed out, but how do i use it? I searched and can't seem to find an example of it in-use. I'm a less-experienced programmer, and really need to see an example of it being used.

I did some testing, and for my ECU, it seems to take about 120MS to return a result after requesting a single piece of data. for example, obd.readPID(PID_RPM, value).

So, for maximum speed, let's say i'd like to read RPM & throttle position maybe 2-4 times per second, other values (like temperatures) maybe once every few seconds

help?
Post Reply