SparkFun Forums 

Where electronics enthusiasts find answers.

General project discussion / help
Did you make a robotic coffee pot which implements HTCPCP and decafs unauthorized users? Show it off here!
By dsmith658
#195691
So I have one of the sparkfun obd-ii uart devices and my goal is fast data logging and controlling a few other functions. However the polling rate is a little slow for my application. To poll 5 PIDs I am seeing turnround times of around 400 ms.

The first thing I did was change the baud rate on the aprkfun device to 115200 and it worked fine at that baudrate, but the turrnaround for OBD requests was still in the 400 ms range. I know others have achieved faster polling with the ELM327 / STN1110 before so I know there must be some optimization I am missing.

I'm using a MEGA2560 arduino board for the project. Thanks for any advice you can give.
Code: Select all
#define ELM_BAUD_RATE 115200
#define ELM_TIMEOUT 1000
#define ELM_PORT Serial2
#include <ELM327.h>
Elm327 Elm;
long int startTime;
long int stopTime;

void setup() 
{
  Serial.begin(9600);
  // put your setup code here, to run once:
  byte status;
  status=Elm.begin();
  if (status != ELM_SUCCESS)
  {
    Serial.println("Elm begin failed with error: ");
    Serial.println(status);
  }
  else
  {
    Serial.println("YAHTZEE");
  }
}

void loop() 
{
  startTime = millis();  byte engineLoads;
  byte engineLoaded = Elm.engineLoad(engineLoads);
  int b1stft1;
  byte b1stft = Elm.fuelTrimBank1ShortTerm(b1stft1);
  int b2stft1;
  byte b2stft = Elm.fuelTrimBank1ShortTerm(b2stft1);
  int b1ltft1;
  byte b1ltft = Elm.fuelTrimBank1LongTerm(b1ltft1);
  int b2ltft1;
  byte b2ltft = Elm.fuelTrimBank1LongTerm(b2ltft1);
  stopTime = millis();
  Serial.println("ENGINE LOAD=" + String(engineLoads));
  Serial.println("STFT1=" + String(b1stft1));
  Serial.println("STFT2=" + String(b2stft1));
  Serial.println("LTFT1=" + String(b1ltft1));
  Serial.println("LTFT2=" + String(b2ltft1));
  Serial.println("TIME=" + String(stopTime - startTime));//print OBD poll time
}
By dsmith658
#195694
I actually solved my own problem. I turned off the adaptive timing "AT0" then reduced the time out "AT ST xx" now I am seeing about 10ms per PID.