Show Posts
Pages: [1] 2 3 ... 12
1  Community / Gigs and Collaborations / looking to pay someone to help, digital speedometer and tach project on: June 16, 2014, 07:20:16 pm
Hey guys,

I'm overworked (day job), have a kid on the way and I can't seem to get a handle on a personal project i'm trying to finish up.  

I'm building a digital instrument panel for a classic car.  I will have 4 analog gauges for various functions, but I need to be able to get speed and tach information to my processing script via serial csv's.  

I played around with gps, but think i want something that is self contained.  I tried two different obd-ii boards; but since my engine is pre can-bus, i wasn't completely happy with the speed.

I then looked into mpguino:  http://mpguino.wiseman.ee/eng  which would be awesome (being able to better calculate fuel consumption).  The problem with that is it will only update 2 time a second.  
this was from the developer:
Quote
update rate is 2 times/second - same rate applies to serial print and LCD print.
Instant MPG reading is actually 500ms average MPG.
You can probably change it in code but I think atmega is not fast enough for 10Hz
Serial communication is also quite slow by nature.

So you probably cannot use it for realtime tach readout when accellerating.
When driving normally (not racing), then it is usable.

So this leads me to this point.  Would anyone be able to do some side work and help me with the circuitry and code for reading the vss wire for speed and the injector pulse for rpm?   (or better yet, if you can simply improve the speed of the mpguino.. that would be ideal)

I will be able to handle the soldering.  it's just the code and possibly components.  For instance, if we choose the lm2907/lm2917 frequency to voltage converter, i'd like some direction on which resistor values to use.  

I'm open to advice as to what is the best way to go about this project, i'm not set on any one solution. 

If interested, please pm me or reply to this thread and we can explore the scope of this project as well as compensation.

thanks in advance,

scott
2  Using Arduino / Programming Questions / Re: How to speed up OBDII uart? on: May 19, 2014, 11:01:16 am
Code:
void OBD_read(void)
    {
      char c;
      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
      rxIndex = 0; //Set this to 0 so next time we call the read we get a "clean buffer"
   
    }
Sure would be a good idea to make sure that there is room in the array (rxData) BEFORE you write to the next position in the array (which might not actually be part of the array).

Code:
      Serial1.print("010C1\r");
      OBD_read();
      return ((strtol(&rxData[6], 0, 16) * 256) + strtol(&rxData[9], 0, 16)) / 4;
The OBD thing is not expecting synchronous communication. It is asynchronous. You send it a command. Sometime later, it provides you an answer.

You are blocking waiting for a response. That is NOT the way to increase performance.

First,  Thank you for taking the time to help out a novice like myself, it's very appreciated. 
Being a novice and having this be my first foray into the world of serial communication I'm a bit confused.  Your first point about making sure there was room in the rxData array.  could i solve that by clearing out the array at the beginning of the loop with rxData = 0;? 

on the second part.  If i understand this correctly I need to figure out a way to recieve the data without a 'while' loop?


thank you and please excuse my ignorance, just trying to grasp this.

3  Using Arduino / Programming Questions / Re: How to speed up OBDII uart? on: May 18, 2014, 03:20:14 pm
Thanks again for your help so far.    I finally got some free time to work on the project again (pregnant wife and getting ready for our firstborn is taking up my project time)  

anyways  here are the results from my tests this morning.  I guess i was mistaken about the Serial.flush   I commented out all the Serial.flush lines.  no real speed up in response but it didn't break the script so they are gone now.

I tried a bunch of different baud rates on Serial1 (kept Serial0 at 9600) and didn't get a response from the obd-ii uart board in my serial monitor.  I tried 115200, 38400, 41600, 10400, 500000, and 250000.  no luck.

next i tried to play with the timeouts and it helped TREMENDOUSLY with speed but the data i retrieve isn't consistent.  I will read back the correct rpm for a few cycles then it'll jump up to 21071 or down to ~53 or 0.  The only way i could solve this is to add a delay:

          delay(75);
 but it slows it down (still faster then w/o the timeouts)
Here is a [demo](http://youtu.be/GrkIU5mSe-4) of the processing app in action if you want to see how well it's working.  Optimally I'd like to get those times down even more but I think it's satisfactory for now (unless you have any other suggestions)

issue no 2:  When I add the second value to poll (speed),  it goes a bit out of whack with random numbers.   If i don't do the internal timeout method it works fine, just slow.  If i do the internal timeout method but alternate the readings (cycle 1: read rpm, cycle 2: read speed, cycle 3: read rpm... and so on) it works fine.  again just slower



here is the initial sketch that's working with just one reading:

  
Code:
 //Set up ring buffer
    char rxData[20];
    char rxIndex = 0;
    int rpmstored = 0;
    void setup()
    {
      Serial.begin(9600); // prints to serial monitor
      Serial1.begin(9600); //Hardware serial connection to the obdii uart
      OBD_init(); //initiates obd link
    }
    
    void loop()
    
      rpmstored = getRPM();
    
      //int mph = (int)((getSPEED() * 10000L + 5) / 16090); //convert to mph
      //  Serial.print (mph);
      Serial.print (0);
      Serial.print (",");
      Serial.print (rpmstored);
      Serial.print (",");
      //  Serial.print (getWATERTEMP());
      Serial.print (0);
      Serial.print (",");
      //  Serial.print (getOILTEMP());
      Serial.print (0);
      Serial.print (",");
      //  Serial.print (getFUEL());
      // Serial.print (",");
      Serial.println (0);
      //  Serial.println (getVOLT());
      delay(75);
    
    
    
    
    }
    
    void OBD_init(void)
    {
      //Wait for a little while before sending the reset command to the OBD-II-UART
      delay(2000);
      //Reset the OBD-II-UART
      Serial1.print("ATZ\r");
      //Wait for a bit before starting to send commands after the reset.
      delay(2);
      OBD_read();
      Serial1.print("ATE0\r");
      OBD_read();
      //Serial1.flush();
    }
    
    int getRPM(void)
    {
      //Query the OBD-II-UART for the Vehicle rpm
      Serial1.print("010C1\r");
      OBD_read();
      return ((strtol(&rxData[6], 0, 16) * 256) + strtol(&rxData[9], 0, 16)) / 4;
    
    }
    
    int getSPEED(void)
    {
      //Query the OBD-II-UART for the vehicle speed
      Serial1.print("010D1\r");
      OBD_read();
    
      return strtol(&rxData[6], 0, 16);
    }
    
    
    void OBD_read(void)
    {
      char c;
      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
      rxIndex = 0; //Set this to 0 so next time we call the read we get a "clean buffer"
    
    }
        
4  Using Arduino / Programming Questions / Re: How to speed up OBDII uart? on: May 14, 2014, 10:38:09 am
Code:
  Serial1.begin(9600); //Hardware serial connection to the obdii uart
Could this be set to a higher baud rate ?
according to the product page:  https://www.sparkfun.com/products/9555
UART interface (baud rates from 38 bps to 10 Mbps)
I will try the other baud rates to see if i get any better results

Get rid of all the Serial.flush() commands.

I was trying a a bunch of thing to try to optimize and commenting those out was one of them.  for some reason i remember not getting any value in my serial monitor after i did that though.  I will have to test that again and give you a better explanation of what happened.

5  Using Arduino / Programming Questions / How to speed up OBDII uart? on: May 14, 2014, 12:00:52 am
Hey guys,

I have the sparkfun obdii uart board (https://www.sparkfun.com/products/9555) that i'm using to get data for a Digital instrument cluster that I'm designing in processing. It's working just fine, but it's extremely slow. Could you guys take a look at my code and tell me if it's a problem with my code or if the sparkfun board is just really that slow?

Code:
//Set up ring buffer
char rxData[20];
char rxIndex = 0;

void setup()
{
  Serial.begin(9600); // prints to serial monitor
  Serial1.begin(9600); //Hardware serial connection to the obdii uart
  OBD_init(); //initiates obd link
}

void loop()
{
  //Delete any data that may be left over in the serial port.
  Serial1.flush();

  int mph = (int)((getSPEED() * 10000L + 5) / 16090); //convert kmh to mph
  Serial.print (mph);
  Serial.print (",");
  Serial.print (getRPM());
  Serial.print (",");
  Serial.print (getWATERTEMP());
  Serial.print (",");
  Serial.print (getOILTEMP());
  Serial.print (",");
  Serial.print (getFUEL());
  Serial.print (",");
  Serial.println (getVOLT());
  // delay(10);//wait .5 seconds and grab another reading
}

void OBD_init(void)
{
  //Wait for a little while before sending the reset command to the OBD-II-UART
  delay(2000);
  //Reset the OBD-II-UART
  Serial1.print("ATZ\r");
  //Wait for a bit before starting to send commands after the reset.
  delay(2);
  OBD_read();
  Serial1.print("ATE0\r");
  OBD_read();
  Serial1.flush();
}

int getRPM(void)
{
  //Query the OBD-II-UART for the Vehicle rpm
  Serial1.flush();
  Serial1.print("010C\r");
  OBD_read();

  return ((strtol(&rxData[6], 0, 16) * 256) + strtol(&rxData[9], 0, 16)) / 4;
}

int getSPEED(void)
{
  //Query the OBD-II-UART for the vehicle speed
  Serial1.flush();
  Serial1.print("010D\r");
  OBD_read();

  return strtol(&rxData[6], 0, 16);
}

int getOILTEMP(void)
{
  //Query the OBD-II-UART for the vehicle speed
  Serial1.flush();
  Serial1.print("015C\r");
  OBD_read();

  return strtol(&rxData[6], 0, 16);
}

int getFUEL(void)
{
  //Query the OBD-II-UART for the vehicle speed
  Serial1.flush();
  Serial1.print("012F\r");
  OBD_read();

  return strtol(&rxData[6], 0, 16);
}

int getVOLT(void)
{
  //Query the OBD-II-UART for the vehicle speed
  Serial1.flush();
  Serial1.print("0142\r");
  OBD_read();

  return strtol(&rxData[6], 0, 16);
}

int getWATERTEMP(void)
{
  //Query the OBD-II-UART for the Engine Coolant Temp
  Serial1.flush();
  Serial1.print("0105\r");
  OBD_read();

  return strtol(&rxData[6], 0, 16) - 40;
}


void OBD_read(void)
{
  char c;
  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
  rxIndex = 0; //Set this to 0 so next time we call the read we get a "clean buffer"
}

any help would be greatly appreciated

thanks
6  Community / Exhibition / Gallery / Re: "The Brick" - All In One - Arduino Platform Compatible on: May 08, 2014, 01:58:28 am
This is a feat idea. Can't wait to see it in production.  I have a project that this would almost be perfect for (just need 15 amp relay.. Guess I could easily add those on)
7  Using Arduino / Programming Questions / Re: Arduino, Processing and Obd-ii. [serial communication between 3 devices?] on: May 04, 2014, 04:52:35 pm
actually this one looks like a better option for me

http://arduinodev.com/hardware/obd-kit/

it has an i2c version that will solve the need to use a leonardo to pass the serial information to the pcduino.  I'll be able to read directly from it
8  Using Arduino / Programming Questions / Re: Arduino, Processing and Obd-ii. [serial communication between 3 devices?] on: May 04, 2014, 04:35:23 pm
the processing sketch will be running on a pcduino3 wired to a 7" transflective lcd screen (that will be mounted where the gauges are now)


this is an early test:

https://www.youtube.com/watch?v=77vv5QnnjBM

it has since gone through a few revisions on look and scope
9  Using Arduino / Programming Questions / Re: Arduino, Processing and Obd-ii. [serial communication between 3 devices?] on: May 04, 2014, 04:29:40 pm
Where, in this classic car, is Processing going to run?

To ease your hesitation a bit... it's a pro-touring restoration.   both rear qtr's and front fenders are getting new metal, it's getting modern suspension and a 6.0 ls engine.  I didn't take a cherry example and restomod it smiley

it's going in the dash of a 66 chevelle same location that the gauges are in now

Quote
If you don't need the extra memory, and only need 2 serial ports - one of which only talks to the PC - then, yes, the Leonardo would work, too.
yes memory isn't an issue.  the arduino is going to handle passing obd-ii data to the host.   Not sure that obd-ii is fast enough for tach and speed though.  I may offload this to gps  and counting a the pulses off the coil or reading the tach pickup wire (have to research that one more.  not sure exactly what my engine will have available
10  Using Arduino / Programming Questions / Re: Arduino, Processing and Obd-ii. [serial communication between 3 devices?] on: May 04, 2014, 11:27:13 am
Quote
It sends data to the Arduino via the serial pins
It doesn't have to. Use two other pins and SoftwareSerial.

Quote
Would I read the obdii via hardware serial then use software serial to pass the values to my sketch?
You could, if you have an FTDI cable to use instead of the USB cable, or if you had a Leonardo. But, since the device doesn't need to connect to the hardware serial pins, it's simplest to just move it.


Pauls i appreciate your  help/guidance.  I have another question.  You mentioned the Leonardo as an option.  on the product page it states:
Quote
Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data using the ATmega32U4 hardware serial capability. Note that on the Leonardo, the Serial class refers to USB (CDC) communication; for TTL serial on pins 0 and 1, use the Serial1 class.
Would this mean that i could accomplish the same result as using the mega?
11  Using Arduino / Programming Questions / Re: Arduino, Processing and Obd-ii. [serial communication between 3 devices?] on: May 04, 2014, 11:14:38 am
 

Quote
Quote
as soon as i open the serial monitor it interrupts the communication with the obdii-urt board.  
Of course it does. Either don't do that, or use a SoftwareSerial port to talk to the OBD device. Which will be challenging when using SoftwareSerial to talk to an LCD too.

Really, the best thing you can do is to get a Mega, and forget about SoftwareSerial. Or, get a I2C LCD and eliminate the need to use SoftwareSerial to talk to the LCD.

Thank you.

 so part of my issue was the code i was using from sparkfun doesn't work for some reason.  I am using another snippet of code i found and it's working! (using mega's serial1 to communicate with the obd-ii device) and now i can write to Serial0 and get a readout in the serial monitor... not a big accomplishment for most of you, but serial communication is very new to me.  

getting an i2c lcd isn't an option because I'm creating a processing sketch for a digital dashboard to replace an instrument cluster in a classic car:
https://www.youtube.com/watch?v=kyP22Sg0_Tg


Thank you guys for your guidance


here is the code that i'm using:
Code:
   //Set up ring buffer
    char rxData[20];
    char rxIndex=0;

    void setup()
    {
       Serial.begin(9600); //
       Serial1.begin(9600); //Hardware serial connection to the obdii uart
 
    
      ODB_init();
    }

    void loop()
    {


      //Delete any data that may be left over in the serial port.
      Serial1.flush();
        Serial.print  ("RPM:  ");
     Serial.println (getRPM());
      Serial1.flush();
    
       Serial.print  ("TEMP:  ");
       Serial.println (getTemp());
     // delay(10);//wait .5 seconds and grab another reading
    

    
    
    
    }

    void ODB_init(void)
    {
      //Wait for a little while before sending the reset command to the OBD-II-UART
      delay(2);
      //Reset the OBD-II-UART
      Serial1.print("ATZ\r");
      //Wait for a bit before starting to send commands after the reset.
      delay(2);
      OBD_read();
      Serial1.print("ATE0\r");
      OBD_read();
      Serial1.flush();
    }

    int getRPM(void)
    {
      //Query the OBD-II-UART for the Vehicle rpm
      Serial1.flush();
      Serial1.print("010C\r");
      OBD_read();
    
      return ((strtol(&rxData[6],0,16)*256)+strtol(&rxData[9],0,16))/4;
    }

    int getTemp(void)
    {
      //Query the OBD-II-UART for the Engine Coolant Temp
      Serial1.flush();
      Serial1.print("0105\r");
      OBD_read();
    
      return strtol(&rxData[6],0,16)-40;
    }


    void OBD_read(void)
    {
      char c;
      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
      rxIndex=0; //Set this to 0 so next time we call the read we get a "clean buffer"
    }


original was found from here:
https://forum.sparkfun.com/viewtopic.php?f=14&t=35507
12  Using Arduino / Programming Questions / Re: Arduino, Processing and Obd-ii. [serial communication between 3 devices?] on: May 03, 2014, 11:08:13 pm
thanks for your input.  

i've started with the sketch that sparkfun provided:
https://github.com/sparkfun/OBD-II_UART/blob/master/Firmware/obdIIUartQuickstart.ino

i'm have been searching the web and trying different configs in my car all day and haven't been able to figure this out. 
as soon as i open the serial monitor it interrupts the communication with the obdii-urt board. 

  I'd love to get some guidance on how to be able to view the data in the serial monitor or better yet in a processing app.  

would i have to create a slave arduino and communicate to the master via i2c in order to view the obdii data on a serial monitor?
13  Using Arduino / Programming Questions / Arduino, Processing and Obd-ii. [serial communication between 3 devices?] on: May 03, 2014, 10:58:33 am
Hey guys,

I have a obd urthttps://learn.sparkfun.com/tutorials/obd-ii-uart-hookup-guide/connecting-to-an-arduino board from sparkfun. It sends data to the Arduino via the serial pins. I want to pass this information to a processing sketch but I'm not sure the proper way to do it. I have used an arduino and processing before, but it only dealt with passing rotary encoder and button press information. Would I read the obdii via hardware serial then use software serial to pass the values to my sketch?

Additional information. The project will be using a pcduino for the final install, but I have an uno r3, mega and digix (due clone) at my disposal to use for testing or to add to the project if necessary)

Thanks and I apologize for the n00b question.
14  Using Arduino / Programming Questions / Re: Serial communication between two programs via USB ? on: April 13, 2014, 01:58:25 am
Thanks for the quick response.   Would it be a possible/better solution to have vc communicate with processing on one port and then pass that through to the arduino?
15  Using Arduino / Programming Questions / Serial communication between two programs via USB ? on: April 13, 2014, 01:45:56 am
Hey guys,

I'm developing a device for my car that will give me a ui to control various functions in my classic car (power locks, windows, etc) I am designing the ui in processing and it's working great.  Now I want to add some voice recognition features using voxcommando   Vc uses a python script to communicate with the arduino via serial USB.  Is there a way to have both processing and box communicate with an Arduino from the same com port?

For those unfamiliar with vc:
http://voxcommando.com/forum/index.php?topic=1452.0
Pages: [1] 2 3 ... 12