Volvo 2002 s60 CAN bus readings - Page 1
Forum section: electronics / beginners

author: zerorisers
author_rank: Regular Contributor
timestamp: June 06, 2015, 05:55:43 pm
content: 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

author: AustinEngy
author_rank: Regular Contributor
timestamp: November 21, 2015, 12:13:51 am
content: 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/B00NQVH666Once 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:// 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 D10const int SPI_CS_PIN = 9;MCP_CAN CAN(SPI_CS_PIN); // Set CS pinvoid 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;if(CAN_MSGAVAIL == CAN.checkReceive()) // check if data coming{CAN.readMsgBuf(&len, buf); // read data, len: data length, buf: data bufunsigned 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);Serial.print("\t");}Serial.println();}}/*********************************************************************************************************END FILE*********************************************************************************************************/

author: ozwolf
author_rank: Regular Contributor
timestamp: November 27, 2015, 10:14:52 am
content: 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

author: max_torque
author_rank: Super Contributor
timestamp: November 27, 2015, 02:01:58 pm
content: 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).

author: fleuroman
author_rank: Contributor
timestamp: November 29, 2015, 08:10:26 pm
content: 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.