Author Topic: Volvo 2002 s60 CAN bus readings  (Read 4558 times)

0 Members and 1 Guest are viewing this topic.

Offline zerorisersTopic starter

  • Regular Contributor
  • *
  • Posts: 132
  • Country: us
  • young noobie, my apologies for low knowledge base.
Volvo 2002 s60 CAN bus readings
« on: June 06, 2015, 05:55:43 pm »
Hello I was wondering if there was some special way to read info from a CAN bus after it has been turned into hex, or if it was generalized over all cars/items that use CAN
 

Offline AustinEngy

  • Regular Contributor
  • *
  • Posts: 56
  • Country: us
Re: Volvo 2002 s60 CAN bus readings
« Reply #1 on: November 21, 2015, 12:13:51 am »
I know I'm late to the party, but the best way to read CAN bus from a car is to find a wiring diagram and splice into the bus already in the car.  You might have wires going to your radio, or the OBD2 connector that would be the easiest to get at, but you'll have to look up information for your specific car.  The cheapest and easiest thing to do IMO would be to buy an Arduino Uno and a CAN Shield.  The one I bought is made by SeeedStudios and they also have their own CAN library with some example codes.  You can buy the shield here: http://www.amazon.com/CAN-BUS-Shield-Compatible-Arduino-Seeeduino/dp/B00NQVH666

Once you have all of that, you will need to figure out the baud rate that your car is communicating at, this might have to be trial and error if you can't find it online.  Try changing the rate in the example receive code.  If you take a look at the library files, you will be able to find the speeds the library is capable of using, I don't remember them off the top of my head.  Load up your board with the example receive code and use some sort of serial interface with logging capabilities like PuTTY.  From there, I'll let you figure out how you want to use this, since I don't know the specific thing you're trying to figure out.  This code will simply print all the data being transmitted on the bus.  Use Excel and separate them by their identifier.  Hint: use the HEX2DEC function.

Here's the example code:

Code: [Select]
// demo: CAN-BUS Shield, receive data with check mode
// send data coming to fast, such as less than 10ms, you can use this way
// loovee, 2014-6-13


#include <SPI.h>
#include "mcp_can.h"


// the cs pin of the version after v1.1 is default to D9
// v0.9b and v1.0 is default D10
const int SPI_CS_PIN = 9;

MCP_CAN CAN(SPI_CS_PIN);                                    // Set CS pin

void setup()
{
    Serial.begin(115200);

START_INIT:

    if(CAN_OK == CAN.begin(CAN_500KBPS))                   // init can bus : baudrate = 500k
    {
        Serial.println("CAN BUS Shield init ok!");
    }
    else
    {
        Serial.println("CAN BUS Shield init fail");
        Serial.println("Init CAN BUS Shield again");
        delay(100);
        goto START_INIT;
    }
}


void loop()
{
    unsigned char len = 0;
    unsigned char buf[8];

    if(CAN_MSGAVAIL == CAN.checkReceive())            // check if data coming
    {
        CAN.readMsgBuf(&len, buf);    // read data,  len: data length, buf: data buf

        unsigned char canId = CAN.getCanId();
       
        Serial.println("-----------------------------");
        Serial.println("get data from ID: ");
        Serial.println(canId);

        for(int i = 0; i<len; i++)    // print the data
        {
            Serial.print(buf[i]);
            Serial.print("\t");
        }
        Serial.println();
    }
}

/*********************************************************************************************************
  END FILE
*********************************************************************************************************/
When people say "Oh you're in engineering, you must be one of the smart kids," they don't know I just watch the eevblog and pretend to know what I'm doing.  Ah, of course, the reciprocal reactance in the flyback capacitor.  That's your problem!  Better just buy a whole new module.
 

Offline ozwolf

  • Regular Contributor
  • *
  • Posts: 166
  • Country: au
Re: Volvo 2002 s60 CAN bus readings
« Reply #2 on: November 27, 2015, 10:14:52 am »
Yup, my stepson and I did exactly that on his VW Golf GTI.  Hooked into the Canbus behind the speedo I think it was.  Many sessions later with Putty, we built some code and now can display the gear status from the transmission.  Kinda cool to watch.

More work to be done however.

Ozwolf
I reject your reality and substitute my own.
 

Offline max_torque

  • Super Contributor
  • ***
  • Posts: 1282
  • Country: gb
    • bitdynamics
Re: Volvo 2002 s60 CAN bus readings
« Reply #3 on: November 27, 2015, 02:01:58 pm »
I think the OPs question is more about the format of the particular message protocol used by passenger car manufacturers than how to get that data!

And the answer is:  There is no "standard" protocol.  Assuming you haven't got the bus data definition files (.dbc etc) from the manufacturer, you'll have to log the data, separate the message ids (and any multiplex indexing), then one data byte at a time attempt to work out the likely variable being sent, it's byte length, Endianness,scaling, and offset.  For some things this will be easy, as you can control that variable directly (for example engine speed or vehicle speed) for others virtually impossible within a sensible time frame.

You will find however that the manufacturers do share message formats between models and even between manufacturers using the same engine or powertrain (ie, Ford and mazda for example).
 

Offline fleuroman

  • Contributor
  • Posts: 27
  • Country: au
Re: Volvo 2002 s60 CAN bus readings
« Reply #4 on: November 29, 2015, 08:10:26 pm »
there's 8 different protocols used across the manufacturers, depending on what you're trying to do, if you're just trying to extract fault codes, for under $10au you can get a wifi adapter that plugs into the OBDII DLC, some free software on your smart phone, and your done. All cars  using CAN BUS should have a TX and RX pin in the OBDII connector. In most cars, the cluster has a digital display that can display a fair bit of the info on the CAN, ie: gear position or evap temp. It's just a matter of researching how to access that data for a particular vehicle.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf