follow ft86club on our blog, twitter or facebook.
FT86CLUB
Ft86Club
Speed By Design
Register Garage Community Calendar Today's Posts Search

Go Back   Toyota GR86, 86, FR-S and Subaru BRZ Forum & Owners Community - FT86CLUB > Technical Topics > Electronics | Audio | NAV | Infotainment

Electronics | Audio | NAV | Infotainment Anything related to in-car electronics, navigation, and infotainment.

Register and become an FT86Club.com member. You will see fewer ads

User Tag List

Reply
 
Thread Tools Search this Thread
Old 08-04-2014, 03:14 AM   #71
robot
There are now 2 carseats!
 
Join Date: Nov 2012
Drives: 2013 DGM BRZ
Location: The Emerald City
Posts: 434
Thanks: 21
Thanked 166 Times in 75 Posts
Mentioned: 7 Post(s)
Tagged: 0 Thread(s)
Quote:
Originally Posted by mabviper View Post
Anytime I have timing issues, I usually relax all timings. For CAN, the identifier ID also relates to priority. The higher the number, the lower the priority. If you're reading all values by sending out a request for each value, I suggest increasing your loop delay.

Sent from my Nexus 4 using Tapatalk
I'm sending out a request like this:

Code:
 if (whichSensor.indexOf("obdbrzoiltempf") >= 0){
    Serial1.println("2101");
    getResponse2();
    Serial.println("brz oil temp");
    delay(40);
    value = ((float)strtol(&rxData[109],0,16) - 40) * 1.8 + 32;
    Serial.println(value);
Serial1 is the obd ii uart device.
Serial is just a usb serial monitor (standard arduino stuff)

There are two versions of getResponse() that I've been toying with. One of which uses peek in a nice way. I think that's the right one to work on. I need to modify it to pick up multiple lines in the return of a CAN message.

Code:
void getResponse(void){
  char obdIn=0;
  int i=0;
  int start=millis();
  //If nothing is currently available do nothing and break after 3 seconds
  while(Serial1.available()==0){if(millis()-start>3000){break;}}
  while(Serial1.available()){
    //check to see if end of line/message
    if (Serial1.peek()=='\r'){
      obdIn=Serial1.read();
      rxData[i]='\0';
      Serial.println(rxData);
      i=0;
    }
    // The prompt is sometimes the only thing recieved so this needs to be taken care of
    else if(Serial1.peek()=='>'){
      obdIn=Serial1.read();
      //Serial.write(obdIn);
    }
    // Add next character to string
    else{
      obdIn=Serial1.read();
      rxData[i++]=obdIn;
    }
  }
  Serial.print("rxData(in getResponse): ");
  Serial.println(rxData);
  rxIndex=0;
}

This is the other one:

Code:
//from:  https://forum.sparkfun.com/viewtopic.php?f=14&t=32457&start=60 and https://forum.sparkfun.com/viewtopic.php?f=14&t=38253
void getResponse2(void){
  char c;
   int start=millis();
  //If nothing is currently available do nothing and break after 3 seconds
  while(Serial1.available()==0){if(millis()-start>3000){break;}}
  do {
    if (Serial1.available() > 0)
    {
      c = Serial1.read();
      if ((c != '>') && (c != '\r') && (c != '\n')) //Keep these out of our buffer
      {
        rxData[rxIndex++] = c; //Add whatever we receive to the buffer
      }
    }
  } 
  while (c != '>'); //The ELM327 ends its response with this char so when we get it we exit out.
  rxData[rxIndex++] = '\0';  //Converts the array into a string
  Serial.print("rxData(in getResponse2): ");
  Serial.println(rxData);
  rxIndex = 0; //Set this to 0 so next time we call the read we get a "clean" buffer
}
I'm sure I've screwed something fundamental up here.

I can use a basic program to send typed commands directly to the device and it seems to work, which leads me to believe that this is timing related.

At the moment after doing an ATZ and ATE0 the first display page/sensor reading is water temp and it just returns "?".

If I stick entirely to using the second getResponse (without the peek). Everything works, except the water temp...this is what really has me stumped.
robot is offline   Reply With Quote
Old 08-04-2014, 03:35 AM   #72
robot
There are now 2 carseats!
 
Join Date: Nov 2012
Drives: 2013 DGM BRZ
Location: The Emerald City
Posts: 434
Thanks: 21
Thanked 166 Times in 75 Posts
Mentioned: 7 Post(s)
Tagged: 0 Thread(s)
So, using the getResponse() without the peek I added a reading of water temp in my initial setup routines. It reads correctly there, but screws up in the actual display code.

I must be close to solving it, right .

Sleep, or code, hmmm....
robot is offline   Reply With Quote
Old 08-04-2014, 03:53 AM   #73
robot
There are now 2 carseats!
 
Join Date: Nov 2012
Drives: 2013 DGM BRZ
Location: The Emerald City
Posts: 434
Thanks: 21
Thanked 166 Times in 75 Posts
Mentioned: 7 Post(s)
Tagged: 0 Thread(s)
I chose sleep: https://github.com/stirobot/arduinoM...6fd00e4247274e is where i left off. Maybe fresh eyes can figure out why all normal PID's and oil temp work but the !#$!@# coolant temp won't show up.

(yet it shows up in that initial setup if I put it there FFS)
robot is offline   Reply With Quote
 
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
EGT gauge SubBrZ Engine, Exhaust, Transmission 23 11-10-2015 10:31 PM
Gauge pod ikeryder13 Want-To-Buy Requests 4 03-30-2014 02:02 PM
WTB DCW gauge pod mikepaul21 Want-To-Buy Requests 1 03-26-2014 09:28 PM
FS DCW Gauge Pod whitefrs Interior Parts (Incl. Lighting) 7 03-26-2014 03:39 PM
Temperature Gauge a dummy gauge? bambbrose BRZ First-Gen (2012+) — General Topics 40 08-19-2012 05:29 PM


All times are GMT -4. The time now is 02:12 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
User Alert System provided by Advanced User Tagging v3.3.0 (Lite) - vBulletin Mods & Addons Copyright © 2026 DragonByte Technologies Ltd.

Garage vBulletin Plugins by Drive Thru Online, Inc.